OSC: Create new surface struct for ALL incoming messages
[ardour.git] / libs / surfaces / osc / osc.h
index 444e3536a4b12d8a2456f06c1efe3c57b7ad94b5..902e0e73d6646313bb52cb41bbb0110bfd83b872 100644 (file)
@@ -37,6 +37,7 @@
 #include "pbd/abstract_ui.h"
 
 #include "ardour/types.h"
+#include "ardour/send.h"
 #include "control_protocol/control_protocol.h"
 
 #include "pbd/i18n.h"
@@ -45,6 +46,7 @@ class OSCControllable;
 class OSCRouteObserver;
 class OSCGlobalObserver;
 class OSCSelectObserver;
+class OSCCueObserver;
 
 namespace ARDOUR {
 class Session;
@@ -75,6 +77,8 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
        XMLNode& get_state ();
        int set_state (const XMLNode&, int version);
 
+       void stripable_selection_changed () {}
+
        bool has_editor () const { return true; }
        void* get_gui () const;
        void  tear_down_gui ();
@@ -93,15 +97,26 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
                All
        };
 
+       enum JogMode {
+               JOG,
+               NUDGE,
+               SCRUB,
+               SHUTTLE,
+               MARKER,
+               SCROLL,
+               TRACK,
+               BANK
+       };
+
        typedef std::vector<boost::shared_ptr<ARDOUR::Stripable> > Sorted;
-       Sorted get_sorted_stripables(std::bitset<32> types);
-       // cue
-       //Sorted cue_get_sorted_stripables(boost::shared_ptr<Route> aux);
+       Sorted get_sorted_stripables(std::bitset<32> types, bool cue);
 
 // keep a surface's global setup by remote server url
        struct OSCSurface {
        public:
                std::string remote_url;         // the url these setting belong to
+               bool no_clear;                          // don't send osc clear messages on strip change
+               JogMode jogmode;                        // current jogmode
                uint32_t bank;                          // current bank
                uint32_t bank_size;                     // size of banks for this surface
                std::bitset<32> strip_types;// what strip types are a part of this bank
@@ -112,6 +127,9 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
                bool expand_enable;                     // use expand instead of select
                OSCSelectObserver* sel_obs;     // So we can sync select feedback with selected channel
                Sorted strips;                          // list of stripables for this surface
+               bool cue;                                       // is this a cue surface
+               uint32_t aux;                           // aux index for this cue surface
+               Sorted sends;                           // list of sends for cue aux
        };
                /*
                 * feedback bits:
@@ -180,6 +198,9 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
        uint32_t default_gainmode;
        bool tick;
        bool bank_dirty;
+       float scrub_speed;              // Current scrub speed
+       double scrub_place;             // place of play head at latest jog/scrub wheel tick
+       int64_t scrub_time;             // when did the wheel move last?
        bool global_init;
        boost::shared_ptr<ARDOUR::Stripable> _select;   // which stripable out of /surface/stripables is gui selected
 
@@ -196,6 +217,7 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
        std::string get_unix_server_url ();
        lo_address get_address (lo_message msg);
        OSCSurface * get_surface (lo_address addr);
+       int check_surface (lo_message msg);
        uint32_t get_sid (boost::shared_ptr<ARDOUR::Stripable> strip, lo_address addr);
        boost::shared_ptr<ARDOUR::Stripable> get_strip (uint32_t ssid, lo_address addr);
        void global_feedback (std::bitset<32> feedback, lo_address addr, uint32_t gainmode);
@@ -208,6 +230,8 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
        int catchall (const char *path, const char *types, lo_arg **argv, int argc, void *data);
        static int _catchall (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data);
 
+       int set_automation (const char *path, size_t len, lo_arg **argv, int argc, lo_message msg);
+
        int route_get_sends (lo_message msg);
        int route_get_receives(lo_message msg);
        void routes_list (lo_message msg);
@@ -215,6 +239,23 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
        void transport_speed (lo_message msg);
        void record_enabled (lo_message msg);
 
+       // cue
+       Sorted cue_get_sorted_stripables(boost::shared_ptr<ARDOUR::Stripable> aux, uint32_t id, lo_message msg);
+       int cue_parse (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg);
+       int cue_set (uint32_t aux, lo_message msg);
+       int _cue_set (uint32_t aux, lo_address addr);
+       int cue_next (lo_message msg);
+       int cue_previous (lo_message msg);
+       int cue_send_fader (uint32_t id, float position, lo_message msg);
+       int cue_send_enable (uint32_t id, float state, lo_message msg);
+       int cue_aux_fader (float position, lo_message msg);
+       int cue_aux_mute (float state, lo_message msg);
+       void cue_set_aux (uint32_t aux, lo_message msg);
+       int cue_float_message (std::string, float value, lo_address addr);
+       int text_message (std::string path, std::string val, lo_address addr);
+       boost::shared_ptr<ARDOUR::Send> cue_get_send (uint32_t id, lo_address addr);
+       // end cue
+
 #define OSC_DEBUG \
        if (_debugmode == All) { \
                debugmsg (dgettext(PACKAGE, "OSC"), path, types, argv, argc); \
@@ -245,8 +286,9 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
        static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data) { \
                return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, data); \
        } \
-       int cb_ ## name (const char *path, const char *types, lo_arg ** argv, int argc, void *) { \
+       int cb_ ## name (const char *path, const char *types, lo_arg ** argv, int argc, void *data) { \
                OSC_DEBUG; \
+               check_surface (data); \
                if (argc > 0 && !strcmp (types, "f") && argv[0]->f != 1.0) { return 0; } \
                name (); \
                return 0; \
@@ -312,8 +354,9 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
        static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data) { \
                return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, data); \
        } \
-       int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *) { \
+       int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data) { \
                OSC_DEBUG; \
+               check_surface (data); \
                if (argc > 0) { \
                        name (optional argv[0]->type); \
                } \
@@ -331,6 +374,9 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
        PATH_CALLBACK1(master_set_mute,i,);
        PATH_CALLBACK1(monitor_set_gain,f,);
        PATH_CALLBACK1(monitor_set_fader,f,);
+       PATH_CALLBACK1(monitor_set_mute,i,);
+       PATH_CALLBACK1(monitor_set_dim,i,);
+       PATH_CALLBACK1(monitor_set_mono,i,);
 
 #define PATH_CALLBACK1_MSG(name,arg1type) \
        static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data) { \
@@ -347,6 +393,9 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
        // pan position needs message info to send feedback
        PATH_CALLBACK1_MSG(master_set_pan_stereo_position,f);
 
+       PATH_CALLBACK1_MSG(scrub,f);
+       PATH_CALLBACK1_MSG(jog,f);
+       PATH_CALLBACK1_MSG(jog_mode,f);
        PATH_CALLBACK1_MSG(set_surface_bank_size,i);
        PATH_CALLBACK1_MSG(set_surface_strip_types,i);
        PATH_CALLBACK1_MSG(set_surface_feedback,i);
@@ -381,8 +430,9 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
        static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data) { \
                return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, data); \
        } \
-       int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *) { \
+       int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data) { \
                OSC_DEBUG; \
+               check_surface (data); \
                if (argc > 1) { \
                        name (argv[0]->arg1type, argv[1]->arg2type); \
                } \
@@ -519,6 +569,9 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
        int set_surface_gainmode (uint32_t gm, lo_message msg);
        int refresh_surface (lo_message msg);
 
+       int scrub (float delta, lo_message msg);
+       int jog (float delta, lo_message msg);
+       int jog_mode (float mode, lo_message msg);
        int master_set_gain (float dB);
        int master_set_fader (float position);
        int master_set_trim (float dB);
@@ -526,6 +579,9 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
        int master_set_mute (uint32_t state);
        int monitor_set_gain (float dB);
        int monitor_set_fader (float position);
+       int monitor_set_mute (uint32_t state);
+       int monitor_set_dim (uint32_t state);
+       int monitor_set_mono (uint32_t state);
        int sel_recenable (uint32_t state, lo_message msg);
        int sel_recsafe (uint32_t state, lo_message msg);
        int sel_mute (uint32_t state, lo_message msg);
@@ -575,6 +631,7 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
        bool periodic (void);
        sigc::connection periodic_connection;
        PBD::ScopedConnectionList session_connections;
+       PBD::ScopedConnectionList cueobserver_connections;
 
        int route_send_fail (std::string path, uint32_t ssid, float val, lo_address addr);
        int sel_send_fail (std::string path, uint32_t id, float val, lo_address addr);
@@ -587,6 +644,9 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
        typedef std::list<OSCGlobalObserver*> GlobalObservers;
        GlobalObservers global_observers;
 
+       typedef std::list<OSCCueObserver*> CueObservers;
+       CueObservers cue_observers;
+
        void debugmsg (const char *prefix, const char *path, const char* types, lo_arg **argv, int argc);
 
        static OSC* _instance;