diff --git a/gtk2_ardour/engine_dialog.cc b/gtk2_ardour/engine_dialog.cc index d0df37dc97..ec09d8d844 100644 --- a/gtk2_ardour/engine_dialog.cc +++ b/gtk2_ardour/engine_dialog.cc @@ -711,7 +711,7 @@ EngineControl::enumerate_devices (const string& driver) /* XXX hard code 16 track estimate... takes no account of stereo, sends, busses, etc. */ - soundgrid_init (16, 16, inputs_adjustment.get_value(), outputs_adjustment.get_value()); + soundgrid_init (inputs_adjustment.get_value(), outputs_adjustment.get_value(), 16); devices[driver] = SoundGrid::lan_port_names(); #else diff --git a/gtk2_ardour/soundgrid.mm b/gtk2_ardour/soundgrid.mm index 03f2490b07..2105e1db24 100644 --- a/gtk2_ardour/soundgrid.mm +++ b/gtk2_ardour/soundgrid.mm @@ -74,23 +74,14 @@ soundgrid_shutdown () } static bool -soundgrid_driver_init (uint32_t max_track_inputs, uint32_t max_track_outputs, - uint32_t max_phys_inputs, uint32_t max_phys_outputs) +soundgrid_driver_init (uint32_t max_phys_inputs, uint32_t max_phys_outputs, uint32_t max_tracks) { - if (ARDOUR::SoundGrid::instance().configure_driver (max_track_inputs + max_phys_inputs, max_track_outputs + max_phys_outputs) == 0) { - if (ARDOUR::SoundGrid::instance().map_io_as_jack_ports (max_phys_inputs, max_phys_inputs)) { - error << "Failed to map " << max_phys_inputs << " inputs and " - << max_phys_outputs << " outputs as JACK ports" - << endmsg; - } - } - + ARDOUR::SoundGrid::instance().configure_driver (max_phys_inputs, max_phys_outputs, max_tracks); return false; /* do not call again */ } int -soundgrid_init (uint32_t max_track_inputs, uint32_t max_track_outputs, - uint32_t max_phys_inputs, uint32_t max_phys_outputs) +soundgrid_init (uint32_t max_phys_inputs, uint32_t max_phys_outputs, uint32_t max_tracks) { /* create a new window that we don't display (at least not as of August 2012, but we can give it to the SoundGrid library @@ -107,8 +98,7 @@ soundgrid_init (uint32_t max_track_inputs, uint32_t max_track_outputs, ARDOUR::SoundGrid::Shutdown.connect (sg_connection, MISSING_INVALIDATOR, soundgrid_shutdown, gui_context()); - if (ARDOUR::SoundGrid::instance().initialize ([sg_window contentView], max_track_inputs, max_track_outputs, - max_phys_inputs, max_phys_inputs)) { + if (ARDOUR::SoundGrid::instance().initialize ([sg_window contentView], max_tracks)) { [sg_window release]; sg_window = 0; @@ -119,8 +109,7 @@ soundgrid_init (uint32_t max_track_inputs, uint32_t max_track_outputs, /* as of early August 2012, we need to wait 5 seconds before configuring the CoreAudio driver */ Glib::signal_timeout().connect (sigc::bind (sigc::ptr_fun (soundgrid_driver_init), - max_track_inputs, max_track_outputs, - max_phys_inputs, max_phys_outputs), 5000); + max_phys_inputs, max_phys_outputs, max_tracks), 5000); /* tell everyone/everything that we're using soundgrid */ diff --git a/libs/ardour/ardour/soundgrid.h b/libs/ardour/ardour/soundgrid.h index bbce2ab475..af1697ef2d 100644 --- a/libs/ardour/ardour/soundgrid.h +++ b/libs/ardour/ardour/soundgrid.h @@ -42,8 +42,7 @@ class SoundGrid : public boost::noncopyable public: ~SoundGrid (); - int initialize (void* window_handle, uint32_t max_track_inputs, uint32_t max_track_ouputs, - uint32_t max_phys_inputs, uint32_t max_phys_outputs); + int initialize (void* window_handle, uint32_t max_tracks); int teardown (); static SoundGrid& instance(); @@ -87,83 +86,136 @@ class SoundGrid : public boost::noncopyable static PBD::Signal0 Shutdown; - bool add_rack_synchronous (uint32_t clusterType, uint32_t &trackHandle); - bool add_rack_asynchronous (uint32_t clusterType); + bool add_rack_synchronous (uint32_t clusterType, int32_t process_group, uint32_t &trackHandle); + bool add_rack_asynchronous (uint32_t clusterType, int32_t process_group); bool remove_rack_synchronous (uint32_t clusterType, uint32_t trackHandle); bool remove_all_racks_synchronous (); int set_gain (uint32_t in_clusterType, uint32_t in_trackHandle, double in_gainValue); bool get_gain (uint32_t in_clusterType, uint32_t in_trackHandle, double &out_gainValue); - int configure_driver (uint32_t physical_inputs, uint32_t physical_outputs); + int configure_driver (uint32_t physical_inputs, uint32_t physical_outputs, uint32_t tracks); struct Port { - uint32_t type; - uint32_t id; - uint32_t channel; - uint32_t matrix_sub; - Port (uint32_t t, uint32_t i, uint32_t c, uint32_t ms) - : type (t) - , id (i) - , channel (c) - , matrix_sub (ms) {} + enum Position { + Pre, + Post + }; + + uint32_t ctype; + uint32_t cid; + uint32_t stype; + uint32_t sindex; + uint32_t sid; + uint32_t channel; + Position position; + + void set_source (WSAudioAssignment& assignment) const; + void set_destination (WSAudioAssignment& assignment) const; /* control sorting and use in STL containers */ bool operator<(const Port& other) const { - return type < other.type && id < other.id && channel < other.channel && matrix_sub < other.matrix_sub; + return ctype < other.ctype && + stype < other.stype && + cid < other.cid && + sid < other.sid && + sindex < other.sindex && + channel < other.channel && + position < other.position; } + + bool accepts_input () const { + if (ctype == eClusterType_Inputs) { + return true; + } else if (ctype == eClusterType_Outputs) { + return false; + } else { + if (position == Post) { + return false; + } + } + return true; + } + + EASGNSource sg_source () const { + switch (position) { + case Pre: + return kASGNPre; + default: + case Post: + return kASGNPost; + } + } + + protected: + Port (uint32_t ct, uint32_t ci, uint32_t st, uint32_t si, uint32_t sd, uint32_t c, Position p) + : ctype (ct) + , cid (ci) + , stype (st) + , sindex (si) + , sid (sd) + , channel (c) + , position (p) {} }; struct DriverInputPort : public Port { DriverInputPort (uint32_t channel) - : Port (eClusterType_Inputs, eClusterHandle_Physical_Driver, eChainerSub_NoSub, channel) {} + : Port (eClusterType_Inputs, eClusterHandle_Physical_Driver, + wvEnum_Unknown, wvEnum_Unknown, wvEnum_Unknown, channel, Port::Pre) {} }; struct DriverOutputPort : public Port { DriverOutputPort (uint32_t channel) - : Port (eClusterType_Outputs, eClusterHandle_Physical_Driver, eChainerSub_NoSub, channel) {} + : Port (eClusterType_Outputs, eClusterHandle_Physical_Driver, + wvEnum_Unknown, wvEnum_Unknown, wvEnum_Unknown, channel, Port::Post) {} }; struct PhysicalInputPort : public Port { PhysicalInputPort (uint32_t channel) - : Port (eClusterType_Inputs, eClusterHandle_Physical_IO, eChainerSub_NoSub, channel) {} + : Port (eClusterType_Inputs, eClusterHandle_Physical_IO, + wvEnum_Unknown, wvEnum_Unknown, wvEnum_Unknown, channel, Port::Pre) {} }; struct PhysicalOutputPort : public Port { PhysicalOutputPort (uint32_t channel) - : Port (eClusterType_Outputs, eClusterHandle_Physical_IO, eChainerSub_NoSub, channel) {} + : Port (eClusterType_Outputs, eClusterHandle_Physical_IO, + wvEnum_Unknown, wvEnum_Unknown, wvEnum_Unknown, channel, Port::Post) {} }; struct TrackInputPort : public Port { - TrackInputPort (uint32_t chainer_id, uint32_t channel, uint32_t position) - : Port (eClusterType_Input, chainer_id, channel, position) {} + TrackInputPort (uint32_t chainer_id, uint32_t channel) + : Port (eClusterType_InputTrack, chainer_id, + eControlType_Input, 0, eControlID_Input_Digital_Trim, channel, Port::Pre) {} }; struct TrackOutputPort : public Port { - TrackOutputPort (uint32_t chainer_id, uint32_t channel, uint32_t position) - : Port (eClusterType_Input, chainer_id, channel, position) {} + TrackOutputPort (uint32_t chainer_id, uint32_t channel) + : Port (eClusterType_InputTrack, chainer_id, + eControlType_Output, 0, eControlID_Output_Gain, channel, Port::Pre) {} }; - + struct BusInputPort : public Port { - BusInputPort (uint32_t chainer_id, uint32_t channel, uint32_t position) - : Port (eClusterType_Group, chainer_id, channel, position) {} + BusInputPort (uint32_t chainer_id, uint32_t channel) + : Port (eClusterType_GroupTrack, chainer_id, + eControlType_Input, 0, eControlID_Input_Digital_Trim, channel, Port::Pre) {} }; - struct BusOutputPort : public Port { - BusOutputPort (uint32_t chainer_id, uint32_t channel, uint32_t position) - : Port (eClusterType_Group, chainer_id, channel, position) {} + BusOutputPort (uint32_t chainer_id, uint32_t channel) + : Port (eClusterType_GroupTrack, chainer_id, + eControlType_Output, 0, eControlID_Output_Gain, channel, Port::Pre) {} }; + int connect (const Port& src, const Port& dst); int disconnect (const Port& src, const Port& dst); std::string sg_port_as_jack_port (const Port& port); bool jack_port_as_sg_port (const std::string& jack_port, Port& result); - int map_io_as_jack_ports (uint32_t ninputs, uint32_t noutputs); - + void parameter_updated (WEParamType paramID); + private: SoundGrid (); static SoundGrid* _instance; @@ -216,7 +268,12 @@ class SoundGrid : public boost::noncopyable }; void assignment_complete (WSCommand* cmd); - + bool get_driver_config (uint32_t& max_inputs, + uint32_t& max_outputs, + uint32_t& current_inputs, + uint32_t& current_outputs); + int connect_io_to_driver (uint32_t ninputs, uint32_t noutputs); + uint32_t _driver_ports; // how many total channels we tell the SG driver to allocate std::vector _driver_input_ports_in_use; std::vector _driver_output_ports_in_use; diff --git a/libs/ardour/automation_list.cc b/libs/ardour/automation_list.cc index 39e7bacc46..2dc69fe448 100644 --- a/libs/ardour/automation_list.cc +++ b/libs/ardour/automation_list.cc @@ -204,7 +204,7 @@ AutomationList::start_touch (double when) } void -AutomationList::stop_touch (bool mark, double when) +AutomationList::stop_touch (bool mark, double /*when*/) { if (g_atomic_int_get (&_touching) == 0) { /* this touch has already been stopped (probably by Automatable::transport_stopped), diff --git a/libs/ardour/coreaudiosource.cc b/libs/ardour/coreaudiosource.cc index 947c66e756..1e2ddffffb 100644 --- a/libs/ardour/coreaudiosource.cc +++ b/libs/ardour/coreaudiosource.cc @@ -266,7 +266,7 @@ CoreAudioSource::get_soundfile_info (string path, SoundFileInfo& _info, string&) } char buf[32]; - snprintf (buf, sizeof (buf), " %" PRIu32 " bit", absd.mBitsPerChannel); + snprintf (buf, sizeof (buf), " %" PRIu32 " bit", (uint32_t) absd.mBitsPerChannel); _info.format_name += buf; _info.format_name += '\n'; diff --git a/libs/ardour/sg_rack.cc b/libs/ardour/sg_rack.cc index f528a4bf73..de1b096797 100644 --- a/libs/ardour/sg_rack.cc +++ b/libs/ardour/sg_rack.cc @@ -22,6 +22,8 @@ #include "ardour/ardour.h" #include "ardour/debug.h" +#include "ardour/port.h" +#include "ardour/port_set.h" #include "ardour/route.h" #include "ardour/track.h" #include "ardour/session.h" @@ -43,19 +45,19 @@ SoundGridRack::SoundGridRack (Session& s, Route& r, const std::string& name) } if (dynamic_cast (&r) != 0) { - _cluster_type = eClusterType_Input; + _cluster_type = eClusterType_InputTrack; } else { /* bus */ if (r.is_master()) { - _cluster_type = eClusterType_Input; + _cluster_type = eClusterType_InputTrack; } else if (r.is_monitor()) { - _cluster_type = eClusterType_Input; + _cluster_type = eClusterType_InputTrack; } else { - _cluster_type = eClusterType_Input; + _cluster_type = eClusterType_InputTrack; } } - if (SoundGrid::instance().add_rack_synchronous (_cluster_type, _rack_id)) { + if (SoundGrid::instance().add_rack_synchronous (_cluster_type, 0, _rack_id)) { throw failed_constructor(); } @@ -83,32 +85,40 @@ SoundGridRack::make_connections () our output JACK ports to these JACK ports, thus establishing signal flow into the chainer. */ -#if 0 - string portname; - - portname = SoundGrid::instance().sg_port_as_jack_port (SoundGrid::TrackInputPort (_rack_id, eChainerSub_NoSub, (uint32_t) -1)); - - if (portname.empty()) { - return -1; - } -#endif - - _route.input()->disconnect (this); _route.output()->disconnect (this); - /* wire up the driver input to the chainer input, thus allowing us to pick up data from the native OS driver - (where JACK will deliver it) - */ +// SoundGrid::instance().connect (SoundGrid::PhysicalInputPort (0), +// SoundGrid::DriverOutputPort (0)); + + PortSet& ports (_route.output()->ports()); + uint32_t channel = 0; - SoundGrid::instance().connect (SoundGrid::PhysicalInputPort (0), - SoundGrid::DriverOutputPort (0)); + for (PortSet::iterator p = ports.begin(); p != ports.end(); ++p, ++channel) { - SoundGrid::instance().connect (SoundGrid::DriverInputPort (0), - SoundGrid::TrackInputPort (_rack_id, eChainerSub_NoSub, (uint32_t) -1)); + if (p->type() != DataType::AUDIO) { + continue; + } - SoundGrid::instance().connect (SoundGrid::TrackOutputPort (_rack_id, eChainerSub_Left, eMixMatrixSub_PostFader), - SoundGrid::PhysicalOutputPort (0)); + /* find a JACK port that will be used to deliver data to the chainer input */ + string portname = SoundGrid::instance().sg_port_as_jack_port (SoundGrid::TrackInputPort (_rack_id, channel)); + + if (portname.empty()) { + continue; + } + + /* connect this port to it */ + + p->connect (portname); + + /* Now wire up the output of our SG chainer to ... yes, to what precisely ? + + For now, wire it up to physical outputs 1 ( + 2, etc) + */ + + SoundGrid::instance().connect (SoundGrid::TrackOutputPort (_rack_id, channel), SoundGrid::PhysicalOutputPort (channel)); + } + return 0; } diff --git a/libs/ardour/soundgrid.mm b/libs/ardour/soundgrid.mm index 6ab8100a39..b50225b497 100644 --- a/libs/ardour/soundgrid.mm +++ b/libs/ardour/soundgrid.mm @@ -21,6 +21,7 @@ #include #include +#include #include @@ -103,22 +104,94 @@ SoundGrid::~SoundGrid() } int -SoundGrid::configure_driver (uint32_t inputs, uint32_t outputs) +SoundGrid::connect_io_to_driver (uint32_t ninputs, uint32_t noutputs) +{ + /* the JACK ports for the native OS audio driver already exist, + because JACK will have created them based on the native + driver will have told JACK how many there are. + + but we still need to connect the SG ports so that signal + does actually flow between the physical IO ports and the + native driver (thus enabling JACK to read/write data) + + this is a special case that benefits from not calling connect() many times. + */ + + DEBUG_TRACE (DEBUG::SoundGrid, string_compose ("setting up wiring for %1 inputs and %2 outputs\n", ninputs, noutputs)); + + if (ninputs) { + + WSAssignmentsCommand inputsCommand; + Init_WSAddAssignmentsCommand(&inputsCommand, ninputs, (WSDControllerHandle)this, 0); + + for (uint32_t n = 0; n < ninputs; ++n) { + + ARDOUR::SoundGrid::DriverOutputPort dst (n); // readable driver/JACK port + ARDOUR::SoundGrid::PhysicalInputPort src (n); // where the signal should come from + WSAudioAssignment &assignment (inputsCommand.in_Assignments.m_aAssignments[n]); + + src.set_source (assignment); + dst.set_destination (assignment); + } + + int ret = command (&inputsCommand.m_command); + + Dispose_WSAudioAssignmentBatch (&inputsCommand.in_Assignments); + + if (ret != 0) { + return -1; + } + } + + if (noutputs) { + + WSAssignmentsCommand outputsCommand; + Init_WSAddAssignmentsCommand(&outputsCommand, noutputs, (WSDControllerHandle)this, 0); + + for (uint32_t n = 0; n < noutputs; ++n) { + + ARDOUR::SoundGrid::DriverInputPort src (n); // writable driver/JACK port + ARDOUR::SoundGrid::PhysicalOutputPort dst (n); // physical channel where the signal should go + WSAudioAssignment &assignment (outputsCommand.in_Assignments.m_aAssignments[n]); + + src.set_source (assignment); + dst.set_destination (assignment); + } + + int ret = command (&outputsCommand.m_command); + + Dispose_WSAudioAssignmentBatch (&outputsCommand.in_Assignments); + + if (ret != 0) { + return -1; + } + } + + return 0; +} + +int +SoundGrid::configure_driver (uint32_t inputs, uint32_t outputs, uint32_t tracks) { WSConfigSGDriverCommand myCommand; + uint32_t in = inputs+tracks; + uint32_t out = outputs+tracks; - Init_WSConfigSGDriverCommand (&myCommand, inputs, outputs, (WSDControllerHandle)this, 0); + in = std::min (in, 32U); + out = std::min (out, 32U); - inputs = 32; - outputs = 32; + Init_WSConfigSGDriverCommand (&myCommand, in, out, (WSDControllerHandle)this, 0); - DEBUG_TRACE (DEBUG::SoundGrid, string_compose ("Initializing SG driver to use %1 inputs + %2 outputs\n", - inputs, outputs)); + DEBUG_TRACE (DEBUG::SoundGrid, string_compose ("Initializing SG driver to use %1 inputs + %2 outputs\n", in, out)); if (command (&myCommand.m_command)) { return -1; } + /* wire up inputs and outputs */ + + connect_io_to_driver (inputs, outputs); + /* set up the in-use bool vector */ _driver_output_ports_in_use.assign (outputs, false); @@ -128,8 +201,7 @@ SoundGrid::configure_driver (uint32_t inputs, uint32_t outputs) } int -SoundGrid::initialize (void* window_handle, uint32_t max_track_inputs, uint32_t /*max_track_outputs*/, - uint32_t /*max_phys_inputs*/, uint32_t /*max_phys_outputs*/) +SoundGrid::initialize (void* window_handle, uint32_t max_tracks) { if (!_sg) { WTErr ret; @@ -141,13 +213,13 @@ SoundGrid::initialize (void* window_handle, uint32_t max_track_inputs, uint32_t mixer_limits.m_clusterConfigs[eClusterType_Inputs].m_uiIndexNum = 2; // 1 for Ardour stuff, 1 for the coreaudio driver/JACK mixer_limits.m_clusterConfigs[eClusterType_Outputs].m_uiIndexNum = 2; // 1 for Ardour stuff, 1 for the coreaudio driver/JACK - max_track_inputs = 64; + max_tracks = 64; //the following is for the tracks that this app will create. - //This will probably be changed to eClusterType_Group in future. - mixer_limits.m_clusterConfigs[eClusterType_Input].m_uiIndexNum = max_track_inputs; + //This will probably be changed to eClusterType_GroupTrack in future. + mixer_limits.m_clusterConfigs[eClusterType_InputTrack].m_uiIndexNum = max_tracks; - DEBUG_TRACE (DEBUG::SoundGrid, string_compose ("Initializing SG Core with %1 tracks\n", max_track_inputs)); + DEBUG_TRACE (DEBUG::SoundGrid, string_compose ("Initializing SG Core with %1 tracks\n", max_tracks)); // XXX use portable, installable technique for this @@ -158,7 +230,7 @@ SoundGrid::initialize (void* window_handle, uint32_t max_track_inputs, uint32_t driver_path += "/../build/libs/soundgrid/SurfaceDriver_App.bundle"; if ((ret = InitializeMixerCoreDLL (&mixer_limits, driver_path.c_str(), window_handle, _sg_callback, this, &_sg)) != eNoErr) { - DEBUG_TRACE (DEBUG::SoundGrid, string_compose ("Initialized SG core, ret = %1 core handle %2\n", ret, _sg)); + DEBUG_TRACE (DEBUG::SoundGrid, string_compose ("Failed to initialize SG core, ret = %1 core handle %2\n", ret, _sg)); return -1; } @@ -209,18 +281,13 @@ SoundGrid::get (WSControlID* id, WSControlInfo* info) return -1; } - if (_callback_table.getControlInfoProc (_host_handle, this, id, info) != eNoErr) { + if (_callback_table.getControlInfoProc (_host_handle, id, info) != eNoErr) { return -1; } return 0; } -void -SoundGrid::event_completed (int) -{ -} - void SoundGrid::finalize (void* ecc, int state) { @@ -237,14 +304,13 @@ SoundGrid::_finalize (void* p, int state) } int -SoundGrid::set (WSEvent* ev, const std::string& what) +SoundGrid::set (WSEvent* ev, const std::string& /*what*/) { if (!_host_handle) { return -1; } ev->sourceController = (WSDControllerHandle) this; - ev->eventTicket = new EventCompletionClosure (what, boost::bind (&SoundGrid::event_completed, this, _1)); if (_callback_table.setEventProc (_host_handle, this, ev) != eNoErr) { return -1; @@ -342,6 +408,46 @@ SoundGrid::set_parameters (const std::string& device, int sr, int bufsize) return instance().set ((WSEvent*) &ev, __SG_WHERE); } +bool +SoundGrid::get_driver_config (uint32_t& max_inputs, + uint32_t& max_outputs, + uint32_t& current_inputs, + uint32_t& current_outputs) +{ + WSDriverConfigParam driverConfig; + WMSDErr errCode = _callback_table.getParamProc (_host_handle, eParamType_DriverConfig, + Init_WSDriverConfigParam (&driverConfig)); + + if (0 == errCode) { + max_inputs = driverConfig.out_MaxInputChannels; + max_outputs = driverConfig.out_MaxOutputChannels; + current_inputs = driverConfig.out_CurrentInputChannels; + current_outputs = driverConfig.out_CurrentOutputChannels; + return true; + } + + DEBUG_TRACE (DEBUG::SoundGrid, string_compose ("could not get soundgrid driver config, err = %1\n", errCode)); + return false; +} + +void +SoundGrid::parameter_updated (WEParamType paramID) +{ + uint32_t maxInputs=0, maxOutputs=0, curInputs=0, curOutputs=0; + + switch (paramID) { + case eParamType_DriverConfig: + if (get_driver_config (maxInputs, maxOutputs, curInputs, curOutputs)) { + // do something to tell the GUI ? + DEBUG_TRACE (DEBUG::SoundGrid, string_compose ("Driver configuration changed to max: %1/%2 current: %3/%4\n", + maxInputs, maxOutputs, curInputs, curOutputs)); + } + break; + default: + break; + } +} + vector SoundGrid::lan_port_names () { @@ -503,6 +609,9 @@ SoundGrid::sg_callback (const WSControlID* cid) void SoundGrid::driver_register (const WSDCoreHandle ch, const WSCoreCallbackTable* ct, const WSMixerConfig* mc) { + DEBUG_TRACE (DEBUG::SoundGrid, string_compose ("Register driver complete, handles are core: %1 callbacks: %2, config: %3\n", + ch, ct, mc)); + if (_instance) { _instance->_host_handle = ch; @@ -527,23 +636,32 @@ SoundGrid::assignment_complete (WSCommand* cmd) WSAssignmentsCommand* acmd = (WSAssignmentsCommand*) cmd; WSAudioAssignment& assignment (acmd->in_Assignments.m_aAssignments[0]); - DEBUG_TRACE (DEBUG::SoundGrid, string_compose ("assignment complete for %1:%2:%3 to %4:%5:%6\n", - assignment.m_asgnSrc.m_chainerID.clusterType, - assignment.m_asgnSrc.m_chainerID.clusterHandle, - assignment.m_asgnSrc.m_uiMixMtxSubIndex, - assignment.m_asgnDest.m_chainerID.clusterType, - assignment.m_asgnDest.m_chainerID.clusterHandle, - assignment.m_asgnDest.m_uiMixMtxSubIndex)); + WSControlID &destination (assignment.m_asgnDest.m_controlID); + WSControlID &source (assignment.m_asgnSrc.m_controlID); + + DEBUG_TRACE (DEBUG::SoundGrid, string_compose ("assignment complete for %1:%2:%3:%4:%5:%6 => %7:%8:%9:%10:%11:%12\n", + source.clusterID.clusterType, + source.clusterID.clusterHandle, + source.sectionControlID.sectionType, + source.sectionControlID.sectionIndex, + source.sectionControlID.channelIndex, + assignment.m_asgnSrc.m_PrePost, + destination.clusterID.clusterType, + destination.clusterID.clusterHandle, + destination.sectionControlID.sectionType, + destination.sectionControlID.sectionIndex, + destination.sectionControlID.channelIndex, + assignment.m_asgnDest.m_PrePost)); } /* Actually do stuff */ bool -SoundGrid::add_rack_synchronous (uint32_t clusterType, uint32_t &trackHandle) +SoundGrid::add_rack_synchronous (uint32_t clusterType, int32_t process_group, uint32_t &trackHandle) { WSAddTrackCommand myCommand; - command (Init_WSAddTrackCommand (&myCommand, clusterType, 1, (WSDControllerHandle)this, 0)); + command (Init_WSAddTrackCommand (&myCommand, clusterType, 1, process_group, (WSDControllerHandle)this, 0)); if (0 == myCommand.m_command.out_status) { trackHandle = myCommand.out_trackID.clusterHandle; @@ -554,10 +672,10 @@ SoundGrid::add_rack_synchronous (uint32_t clusterType, uint32_t &trackHandle) } bool -SoundGrid::add_rack_asynchronous (uint32_t clusterType) +SoundGrid::add_rack_asynchronous (uint32_t clusterType, int32_t process_group) { WSAddTrackCommand *pMyCommand = new WSAddTrackCommand; - WMSDErr errCode = command (Init_WSAddTrackCommand (pMyCommand, clusterType, 1, (WSDControllerHandle)this, pMyCommand)); + WMSDErr errCode = command (Init_WSAddTrackCommand (pMyCommand, clusterType, 1, process_group, (WSDControllerHandle)this, pMyCommand)); printf ("AddRack Command result = %d, command status = %d\n", errCode, pMyCommand->m_command.out_status); @@ -619,7 +737,7 @@ SoundGrid::get_gain (uint32_t in_clusterType, uint32_t in_trackHandle, double &o faderInfo.m_controlID.sectionControlID.sectionType = eControlType_Output; faderInfo.m_controlID.sectionControlID.sectionIndex = eControlType_Output_Local; - faderInfo.m_controlID.sectionControlID.channelIndex = 0; + faderInfo.m_controlID.sectionControlID.channelIndex = wvEnum_Unknown; faderInfo.m_controlID.sectionControlID.controlID = eControlID_Output_Gain; if (get (&faderInfo.m_controlID, &faderInfo) == 0) { @@ -663,7 +781,7 @@ SoundGrid::sg_port_as_jack_port (const Port& sgport) bool found = false; bool inputs = false; - if (sgport.type == eClusterType_Input || sgport.type == eClusterType_Inputs) { + if (sgport.accepts_input()) { inputs = true; @@ -712,12 +830,16 @@ SoundGrid::sg_port_as_jack_port (const Port& sgport) if (found) { if (inputs) { - Port driverport = DriverOutputPort (driver_channel); + Port driverport = DriverInputPort (driver_channel); + DEBUG_TRACE (DEBUG::SoundGrid, string_compose ("connecting driver_channel %2 to sgport %1\n", + sgport, driver_channel)); if (connect (driverport, sgport) != 0) { return string(); } } else { - Port driverport = DriverInputPort (driver_channel); + Port driverport = DriverOutputPort (driver_channel); + DEBUG_TRACE (DEBUG::SoundGrid, string_compose ("connecting sgport %1 to driver channel %2\n", + sgport, driver_channel)); if (connect (sgport, driverport) != 0) { return string(); } @@ -752,19 +874,16 @@ SoundGrid::connect (const Port& src, const Port& dst) Init_WSAddAssignmentsCommand(&myCommand, 1, (WSDControllerHandle)this, 0); WSAudioAssignment &assignment (myCommand.in_Assignments.m_aAssignments[0]); - assignment.m_asgnSrc.m_chainerID.clusterType = src.type; - assignment.m_asgnSrc.m_chainerID.clusterHandle = src.id; - assignment.m_asgnSrc.m_eChainerSubIndex = (WEChainerSub) src.channel; - assignment.m_asgnSrc.m_uiMixMtxSubIndex = src.matrix_sub; - - assignment.m_asgnDest.m_chainerID.clusterType = dst.type; - assignment.m_asgnDest.m_chainerID.clusterHandle = dst.id; - assignment.m_asgnDest.m_eChainerSubIndex = (WEChainerSub) dst.channel; - assignment.m_asgnDest.m_uiMixMtxSubIndex = dst.matrix_sub; + src.set_source (assignment); + dst.set_destination (assignment); DEBUG_TRACE (DEBUG::SoundGrid, string_compose ("connect %1 => %2\n", src, dst)); - return command (&myCommand.m_command); + int ret = command (&myCommand.m_command); + + Dispose_WSAudioAssignmentBatch (&myCommand.in_Assignments); + + return ret; } int @@ -775,104 +894,54 @@ SoundGrid::disconnect (const Port& src, const Port& dst) Init_WSRemoveAssignmentsCommand(&myCommand, 1, (WSDControllerHandle)this, 0); WSAudioAssignment &assignment (myCommand.in_Assignments.m_aAssignments[0]); - assignment.m_asgnSrc.m_chainerID.clusterType = src.type; - assignment.m_asgnSrc.m_chainerID.clusterHandle = src.id; - assignment.m_asgnSrc.m_eChainerSubIndex = (WEChainerSub) src.channel; - assignment.m_asgnSrc.m_uiMixMtxSubIndex = src.matrix_sub; + src.set_source (assignment); + dst.set_destination (assignment); - assignment.m_asgnDest.m_chainerID.clusterType = dst.type; - assignment.m_asgnDest.m_chainerID.clusterHandle = dst.id; - assignment.m_asgnDest.m_eChainerSubIndex = (WEChainerSub) dst.channel; - assignment.m_asgnDest.m_uiMixMtxSubIndex = dst.matrix_sub; - DEBUG_TRACE (DEBUG::SoundGrid, string_compose ("DIS-connect %1 ... %2\n", src, dst)); - return command (&myCommand.m_command); + int ret = command (&myCommand.m_command); + Dispose_WSAudioAssignmentBatch (&myCommand.in_Assignments); + + return ret; } -int -SoundGrid::map_io_as_jack_ports (uint32_t ninputs, uint32_t noutputs) +void +SoundGrid::Port::set_source (WSAudioAssignment& assignment) const { - return 0; + WSControlID &c (assignment.m_asgnSrc.m_controlID); - ninputs = 0; - noutputs = 1; + c.clusterID.clusterType = ctype; + c.clusterID.clusterHandle = cid; + c.sectionControlID.sectionType = stype; + c.sectionControlID.sectionIndex = sindex; + c.sectionControlID.controlID = sid; + c.sectionControlID.channelIndex = channel; - /* the JACK ports for the native OS audio driver already exist, - because JACK will have created them based on the native - driver will have told JACK how many there are. + assignment.m_asgnSrc.m_PrePost = sg_source(); +} - but we still need to connect the SG ports so that signal - does actually flow between the physical IO ports and the - native driver (thus enabling JACK to read/write data) +void +SoundGrid::Port::set_destination (WSAudioAssignment& assignment) const +{ + WSControlID &c (assignment.m_asgnDest.m_controlID); - this is a special case that benefits from not calling connect() many times. - */ + c.clusterID.clusterType = ctype; + c.clusterID.clusterHandle = cid; + c.sectionControlID.sectionType = stype; + c.sectionControlID.sectionIndex = sindex; + c.sectionControlID.controlID = sid; + c.sectionControlID.channelIndex = channel; - DEBUG_TRACE (DEBUG::SoundGrid, string_compose ("setting up wiring for %1 inputs and %2 outputs\n", ninputs, noutputs)); - - if (ninputs) { - - WSAssignmentsCommand inputsCommand; - Init_WSAddAssignmentsCommand(&inputsCommand, ninputs, (WSDControllerHandle)this, 0); - - for (uint32_t n = 0; n < ninputs; ++n) { - - WSAudioAssignment &assignment (inputsCommand.in_Assignments.m_aAssignments[n]); - ARDOUR::SoundGrid::DriverOutputPort dst (n); // readable driver/JACK port - ARDOUR::SoundGrid::PhysicalInputPort src (n); // where the signal should come from - - assignment.m_asgnSrc.m_chainerID.clusterType = src.type; - assignment.m_asgnSrc.m_chainerID.clusterHandle = src.id; - assignment.m_asgnSrc.m_eChainerSubIndex = (WEChainerSub) src.channel; - assignment.m_asgnSrc.m_uiMixMtxSubIndex = src.matrix_sub; - - assignment.m_asgnDest.m_chainerID.clusterType = dst.type; - assignment.m_asgnDest.m_chainerID.clusterHandle = dst.id; - assignment.m_asgnDest.m_eChainerSubIndex = (WEChainerSub) dst.channel; - assignment.m_asgnDest.m_uiMixMtxSubIndex = dst.matrix_sub; - } - - if (command (&inputsCommand.m_command) != 0) { - return -1; - } - } - - if (noutputs) { - - WSAssignmentsCommand outputsCommand; - Init_WSAddAssignmentsCommand(&outputsCommand, noutputs, (WSDControllerHandle)this, 0); - - for (uint32_t n = 0; n < noutputs; ++n) { - - WSAudioAssignment &assignment (outputsCommand.in_Assignments.m_aAssignments[n]); - ARDOUR::SoundGrid::DriverInputPort src (n); // writable driver/JACK port - ARDOUR::SoundGrid::PhysicalOutputPort dst (n); // physical channel where the signal should go - - assignment.m_asgnSrc.m_chainerID.clusterType = src.type; - assignment.m_asgnSrc.m_chainerID.clusterHandle = src.id; - assignment.m_asgnSrc.m_eChainerSubIndex = (WEChainerSub) src.channel; - assignment.m_asgnSrc.m_uiMixMtxSubIndex = src.matrix_sub; - - assignment.m_asgnDest.m_chainerID.clusterType = dst.type; - assignment.m_asgnDest.m_chainerID.clusterHandle = dst.id; - assignment.m_asgnDest.m_eChainerSubIndex = (WEChainerSub) dst.channel; - assignment.m_asgnDest.m_uiMixMtxSubIndex = dst.matrix_sub; - } - - if (command (&outputsCommand.m_command) != 0) { - return -1; - } - } - - return 0; + assignment.m_asgnDest.m_PrePost = sg_source(); } std::ostream& operator<< (std::ostream& out, const SoundGrid::Port& p) { - out << p.type << ':' << p.id << ':' << p.channel << ':' << p.matrix_sub; + out << p.ctype << ':' << p.cid + << ':' << p.stype << ':' << p.sindex << ':' << p.sid + << ':' << p.channel << ':' << p.position; return out; } diff --git a/libs/evoral/src/ControlList.cpp b/libs/evoral/src/ControlList.cpp index c4495485de..e0996b9758 100644 --- a/libs/evoral/src/ControlList.cpp +++ b/libs/evoral/src/ControlList.cpp @@ -548,7 +548,7 @@ ControlList::start_write_pass (double when) } void -ControlList::write_pass_finished (double when) +ControlList::write_pass_finished (double /*when*/) { if (did_write_during_pass) { thin (); diff --git a/libs/midi++2/midnam_patch.cc b/libs/midi++2/midnam_patch.cc index 2b32fee42e..4d6f27c379 100644 --- a/libs/midi++2/midnam_patch.cc +++ b/libs/midi++2/midnam_patch.cc @@ -423,7 +423,7 @@ MasterDeviceNames::find_patch(std::string mode, uint8_t channel, PatchPrimaryKey } int -MasterDeviceNames::set_state(const XMLTree& tree, const XMLNode& a_node) +MasterDeviceNames::set_state(const XMLTree& tree, const XMLNode& /*a_node*/) { // Manufacturer boost::shared_ptr manufacturer = tree.find("//Manufacturer"); @@ -540,7 +540,7 @@ MIDINameDocument::MIDINameDocument (const string& filename) } int -MIDINameDocument::set_state (const XMLTree& tree, const XMLNode& a_node) +MIDINameDocument::set_state (const XMLTree& tree, const XMLNode& /*a_node*/) { // Author diff --git a/libs/soundgrid/driver.cc b/libs/soundgrid/driver.cc index 651b8dec60..81f9e8fdbd 100644 --- a/libs/soundgrid/driver.cc +++ b/libs/soundgrid/driver.cc @@ -27,7 +27,7 @@ static const char* controller_type = PROGRAM_NAME; uint32_t WMSD_QueryInterfaceVersion() { - DEBUG_TRACE (DEBUG::SGDriver, string_compose ("ControllerDriver:%1\n", __FUNCTION__)); + DEBUG_TRACE (DEBUG::SGDriver, string_compose ("ControllerDriver:%1 - response = %2\n", __FUNCTION__, WMSD_INTERFACE_VERSION)); return WMSD_INTERFACE_VERSION; } @@ -130,9 +130,6 @@ WMSD_ControllerDisplayUpdate (const WSDControllerHandle controllerHandle, case eClusterType_Global_Channel: DEBUG_TRACE (DEBUG::SGDriver, "Channel\n"); break; - case eClusterType_Global_RequestTimeout: - DEBUG_TRACE (DEBUG::SGDriver, "RequestTimeout\n"); - break; case eClusterType_Global_SurfacesSetup: DEBUG_TRACE (DEBUG::SGDriver, "SurfacesSetup\n"); break; @@ -170,30 +167,12 @@ WMSD_ControllerDisplayUpdate (const WSDControllerHandle controllerHandle, break; } break; - case eClusterType_Input: + case eClusterType_InputTrack: // DEBUG_TRACE (DEBUG::SGDriver, "update, InputChannel\n"); break; - case eClusterType_Group: + case eClusterType_GroupTrack: // DEBUG_TRACE (DEBUG::SGDriver, "update, GroupChannel\n"); break; - case eClusterType_Aux: - // DEBUG_TRACE (DEBUG::SGDriver, "update, AuxChannel\n"); - break; - case eClusterType_Matrix: - // DEBUG_TRACE (DEBUG::SGDriver, "update, MatrixChannel\n"); - break; - case eClusterType_LCRM: - // DEBUG_TRACE (DEBUG::SGDriver, "update, LCRMChannel\n"); - break; - case eClusterType_DCA: - // DEBUG_TRACE (DEBUG::SGDriver, "update, DCAChannel\n"); - break; - case eClusterType_Cue: - // DEBUG_TRACE (DEBUG::SGDriver, "update, CueChannel\n"); - break; - case eClusterType_TB: - // DEBUG_TRACE (DEBUG::SGDriver, "update, TBChannel\n"); - break; case eClusterType_Inputs: // DEBUG_TRACE (DEBUG::SGDriver, "update, Inputs\n"); break; @@ -224,4 +203,18 @@ WMSD_GetTypeForController (const WSDControllerHandle /*controllerHandle*/, char return eNoErr; } +WMSDErr +WMSD_ControllerParamUpdate (const WSDControllerHandle controllerHandle, WEParamType paramID) +{ + SoundGrid* sg = (SoundGrid*) controllerHandle; + + DEBUG_TRACE (DEBUG::SGDriver, string_compose ("ControllerDriver:%1\n", __FUNCTION__)); + + if (sg) { + sg->parameter_updated (paramID); + } + + return eNoErr; +} + } /* extern "C" */