mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-23 21:57:16 +01:00
OSC: add /select/plugin/activate cause some add deactivated
And clean up plugin code as well
This commit is contained in:
parent
3856d525fb
commit
06ea56a2ce
4 changed files with 187 additions and 85 deletions
|
|
@ -582,6 +582,7 @@ OSC::register_callbacks()
|
|||
REGISTER_CALLBACK (serv, "/select/send_page", "f", sel_send_page);
|
||||
REGISTER_CALLBACK (serv, "/select/plug_page", "f", sel_plug_page);
|
||||
REGISTER_CALLBACK (serv, "/select/plugin", "f", sel_plugin);
|
||||
REGISTER_CALLBACK (serv, "/select/plugin/activate", "f", sel_plugin_activate);
|
||||
REGISTER_CALLBACK (serv, "/select/expand", "i", sel_expand);
|
||||
REGISTER_CALLBACK (serv, "/select/pan_elevation_position", "f", sel_pan_elevation);
|
||||
REGISTER_CALLBACK (serv, "/select/pan_frontback_position", "f", sel_pan_frontback);
|
||||
|
|
@ -2358,7 +2359,7 @@ OSC::sel_plug_pagesize (uint32_t size, lo_message msg)
|
|||
OSCSurface *s = get_surface(get_address (msg));
|
||||
if (size != s->plug_page_size) {
|
||||
s->plug_page_size = size;
|
||||
s->sel_obs->renew_plugin();
|
||||
s->sel_obs->set_plugin_size(size);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -2366,15 +2367,35 @@ OSC::sel_plug_pagesize (uint32_t size, lo_message msg)
|
|||
int
|
||||
OSC::sel_plug_page (int page, lo_message msg)
|
||||
{
|
||||
if (!page) {
|
||||
return 0;
|
||||
}
|
||||
int new_page = 0;
|
||||
OSCSurface *s = get_surface(get_address (msg));
|
||||
s->plug_page = s->plug_page + page;
|
||||
s->sel_obs->renew_plugin();
|
||||
if (page > 0) {
|
||||
new_page = s->plug_page + s->plug_page_size;
|
||||
if ((uint32_t) new_page > s->plug_params.size ()) {
|
||||
new_page = s->plug_page;
|
||||
}
|
||||
} else {
|
||||
new_page = s->plug_page - s->plug_page_size;
|
||||
if (new_page < 1) {
|
||||
new_page = 1;
|
||||
}
|
||||
}
|
||||
if (new_page != s->plug_page) {
|
||||
s->plug_page = new_page;
|
||||
s->sel_obs->set_plugin_page(s->plug_page);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
OSC::sel_plugin (int delta, lo_message msg)
|
||||
{
|
||||
if (!delta) {
|
||||
return 0;
|
||||
}
|
||||
OSCSurface *sur = get_surface(get_address (msg));
|
||||
return _sel_plugin (sur->plugin_id + delta, get_address (msg));
|
||||
}
|
||||
|
|
@ -2383,12 +2404,7 @@ int
|
|||
OSC::_sel_plugin (int id, lo_address addr)
|
||||
{
|
||||
OSCSurface *sur = get_surface(addr);
|
||||
boost::shared_ptr<Stripable> s;
|
||||
if (sur->expand_enable) {
|
||||
s = get_strip (sur->expand, addr);
|
||||
} else {
|
||||
s = _select;
|
||||
}
|
||||
boost::shared_ptr<Stripable> s = sur->select;
|
||||
if (s) {
|
||||
boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route>(s);
|
||||
if (!r) {
|
||||
|
|
@ -2412,24 +2428,28 @@ OSC::_sel_plugin (int id, lo_address addr)
|
|||
if (!pi->is_channelstrip()) {
|
||||
#endif
|
||||
sur->plugins.push_back (nplugs);
|
||||
nplugs++;
|
||||
#ifdef MIXBUS
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
plugs = true;
|
||||
nplugs++;
|
||||
}
|
||||
} while (plugs);
|
||||
|
||||
// limit plugin_id to actual plugins
|
||||
if (!sur->plugins.size()) {
|
||||
if (sur->plugins.size() < 1) {
|
||||
sur->plugin_id = 0;
|
||||
sur->plug_page = 1;
|
||||
if (sur->sel_obs) {
|
||||
sur->sel_obs->set_plugin_id(-1, 1);
|
||||
}
|
||||
return 0;
|
||||
} else if (id < 1) {
|
||||
sur->plugin_id = 1;
|
||||
} else if (sur->plugins.size() < (uint32_t) id) {
|
||||
sur->plugin_id = sur->plugins.size();
|
||||
} else if (sur->plugins.size() && !id) {
|
||||
sur->plugin_id = 1;
|
||||
} else {
|
||||
sur->plugin_id = id;
|
||||
}
|
||||
|
|
@ -2459,7 +2479,7 @@ OSC::_sel_plugin (int id, lo_address addr)
|
|||
sur->plug_page = 1;
|
||||
|
||||
if (sur->sel_obs) {
|
||||
sur->sel_obs->renew_plugin();
|
||||
sur->sel_obs->set_plugin_id(sur->plugins[sur->plugin_id - 1], sur->plug_page);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -3627,10 +3647,11 @@ OSC::_strip_select (boost::shared_ptr<Stripable> s, lo_address addr)
|
|||
OSCSelectObserver* so = dynamic_cast<OSCSelectObserver*>(sur->sel_obs);
|
||||
if (sur->feedback[13]) {
|
||||
if (so != 0) {
|
||||
delete so;
|
||||
so->refresh_strip (s, nsends, true);
|
||||
} else {
|
||||
OSCSelectObserver* sel_fb = new OSCSelectObserver (*this, sur);
|
||||
sur->sel_obs = sel_fb;
|
||||
}
|
||||
OSCSelectObserver* sel_fb = new OSCSelectObserver (*this, sur);
|
||||
sur->sel_obs = sel_fb;
|
||||
sur->sel_obs->set_expand (sur->expand_enable);
|
||||
uint32_t obs_expand = 0;
|
||||
if (sur->expand_enable) {
|
||||
|
|
@ -4286,12 +4307,7 @@ OSC::select_plugin_parameter (const char *path, const char* types, lo_arg **argv
|
|||
if (sur->plug_page_size && (paid > (int)sur->plug_page_size)) {
|
||||
return float_message_with_id ("/select/plugin/parameter", paid, 0, sur->feedback[2], get_address (msg));
|
||||
}
|
||||
boost::shared_ptr<Stripable> s;
|
||||
if (sur->expand_enable) {
|
||||
s = get_strip (sur->expand, get_address (msg));
|
||||
} else {
|
||||
s = _select;
|
||||
}
|
||||
boost::shared_ptr<Stripable> s = sur->select;
|
||||
boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route>(s);
|
||||
if (!r) {
|
||||
return 1;
|
||||
|
|
@ -4304,7 +4320,7 @@ OSC::select_plugin_parameter (const char *path, const char* types, lo_arg **argv
|
|||
}
|
||||
boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
|
||||
// paid is paged parameter convert to absolute
|
||||
int parid = paid + (int)(sur->plug_page_size * (sur->plug_page - 1));
|
||||
int parid = paid + (int)sur->plug_page - 1;
|
||||
if (parid > (int) sur->plug_params.size ()) {
|
||||
if (sur->feedback[13]) {
|
||||
float_message_with_id ("/select/plugin/parameter", paid, 0, sur->feedback[2], get_address (msg));
|
||||
|
|
@ -4337,6 +4353,36 @@ OSC::select_plugin_parameter (const char *path, const char* types, lo_arg **argv
|
|||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
OSC::sel_plugin_activate (float state, lo_message msg)
|
||||
{
|
||||
if (!session) {
|
||||
return -1;
|
||||
}
|
||||
OSCSurface *sur = get_surface(get_address (msg));
|
||||
boost::shared_ptr<Stripable> s = sur->select;
|
||||
|
||||
boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (s);
|
||||
|
||||
if (r) {
|
||||
boost::shared_ptr<Processor> redi=r->nth_plugin (sur->plugins[sur->plugin_id -1]);
|
||||
if (redi) {
|
||||
boost::shared_ptr<PluginInsert> pi;
|
||||
if ((pi = boost::dynamic_pointer_cast<PluginInsert>(redi))) {
|
||||
if(state > 0) {
|
||||
pi->activate();
|
||||
} else {
|
||||
pi->deactivate();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
float_message ("/select/plugin/activate", 0, get_address (msg));
|
||||
PBD::warning << "OSC: Select has no Plugin." << endmsg;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
OSC::route_plugin_list (int ssid, lo_message msg) {
|
||||
if (!session) {
|
||||
|
|
|
|||
|
|
@ -494,6 +494,7 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
|
|||
PATH_CALLBACK1_MSG(sel_send_page,f);
|
||||
PATH_CALLBACK1_MSG(sel_plug_page,f);
|
||||
PATH_CALLBACK1_MSG(sel_plugin,f);
|
||||
PATH_CALLBACK1_MSG(sel_plugin_activate,f);
|
||||
PATH_CALLBACK1_MSG(sel_comp_enable,f);
|
||||
PATH_CALLBACK1_MSG(sel_comp_threshold,f);
|
||||
PATH_CALLBACK1_MSG(sel_comp_speed,f);
|
||||
|
|
@ -661,6 +662,7 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
|
|||
int sel_plug_page (int page, lo_message msg);
|
||||
int sel_plugin (int delta, lo_message msg);
|
||||
int _sel_plugin (int id, lo_address addr);
|
||||
int sel_plugin_activate (float state, lo_message msg);
|
||||
int select_plugin_parameter (const char *path, const char* types, lo_arg **argv, int argc, lo_message msg);
|
||||
void processor_changed (lo_address addr);
|
||||
|
||||
|
|
|
|||
|
|
@ -64,8 +64,15 @@ OSCSelectObserver::OSCSelectObserver (OSC& o, ArdourSurface::OSC::OSCSurface* su
|
|||
feedback = sur->feedback;
|
||||
in_line = feedback[2];
|
||||
send_page_size = sur->send_page_size;
|
||||
plug_page_size = sur->plug_page_size;
|
||||
send_size = send_page_size;
|
||||
send_page = sur->send_page;
|
||||
plug_page_size = sur->plug_page_size;
|
||||
plug_page = sur->plug_page;
|
||||
if (sur->plugins.size () > 0) {
|
||||
plug_id = sur->plugins[sur->plugin_id - 1];
|
||||
} else {
|
||||
plug_id = -1;
|
||||
}
|
||||
refresh_strip (sur->select, sur->nsends, true);
|
||||
set_expand (sur->expand_enable);
|
||||
}
|
||||
|
|
@ -116,8 +123,6 @@ OSCSelectObserver::refresh_strip (boost::shared_ptr<ARDOUR::Stripable> new_strip
|
|||
|
||||
_strip->DropReferences.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::no_strip, this), OSC::instance());
|
||||
as = ARDOUR::Off;
|
||||
send_size = 0;
|
||||
plug_size = 0;
|
||||
_comp_redux = 1;
|
||||
nsends = s_nsends;
|
||||
_last_gain = -1.0;
|
||||
|
|
@ -253,20 +258,6 @@ OSCSelectObserver::set_expand (uint32_t expand)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
OSCSelectObserver::set_send_page (uint32_t page)
|
||||
{
|
||||
send_page = page;
|
||||
renew_sends ();
|
||||
}
|
||||
|
||||
void
|
||||
OSCSelectObserver::set_send_size (uint32_t size)
|
||||
{
|
||||
send_page_size = size;
|
||||
renew_sends ();
|
||||
}
|
||||
|
||||
void
|
||||
OSCSelectObserver::clear_observer ()
|
||||
{
|
||||
|
|
@ -321,6 +312,22 @@ OSCSelectObserver::clear_observer ()
|
|||
eq_end();
|
||||
}
|
||||
|
||||
void
|
||||
OSCSelectObserver::set_send_page (uint32_t page)
|
||||
{
|
||||
if (send_page != page) {
|
||||
send_page = page;
|
||||
renew_sends ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
OSCSelectObserver::set_send_size (uint32_t size)
|
||||
{
|
||||
send_page_size = size;
|
||||
renew_sends ();
|
||||
}
|
||||
|
||||
void
|
||||
OSCSelectObserver::renew_sends () {
|
||||
send_connections.drop_connections ();
|
||||
|
|
@ -328,12 +335,6 @@ OSCSelectObserver::renew_sends () {
|
|||
send_init();
|
||||
}
|
||||
|
||||
void
|
||||
OSCSelectObserver::renew_plugin () {
|
||||
plugin_end();
|
||||
plugin_init();
|
||||
}
|
||||
|
||||
void
|
||||
OSCSelectObserver::send_init()
|
||||
{
|
||||
|
|
@ -388,28 +389,93 @@ OSCSelectObserver::send_init()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
OSCSelectObserver::send_end ()
|
||||
{
|
||||
send_connections.drop_connections ();
|
||||
for (uint32_t i = 1; i <= send_size; i++) {
|
||||
if (gainmode) {
|
||||
_osc.float_message_with_id ("/select/send_fader", i, 0, in_line, addr);
|
||||
} else {
|
||||
_osc.float_message_with_id ("/select/send_gain", i, -193, in_line, addr);
|
||||
}
|
||||
// next enable
|
||||
_osc.float_message_with_id ("/select/send_enable", i, 0, in_line, addr);
|
||||
// next name
|
||||
_osc.text_message_with_id ("/select/send_name", i, " ", in_line, addr);
|
||||
}
|
||||
// need to delete or clear send_timeout
|
||||
send_size = 0;
|
||||
send_timeout.clear();
|
||||
}
|
||||
|
||||
void
|
||||
OSCSelectObserver::set_plugin_id (int id, uint32_t page)
|
||||
{
|
||||
plug_id = id;
|
||||
plug_page = page;
|
||||
renew_plugin ();
|
||||
}
|
||||
|
||||
void
|
||||
OSCSelectObserver::set_plugin_page (uint32_t page)
|
||||
{
|
||||
plug_page = page;
|
||||
renew_plugin ();
|
||||
}
|
||||
|
||||
void
|
||||
OSCSelectObserver::set_plugin_size (uint32_t size)
|
||||
{
|
||||
plug_page_size = size;
|
||||
renew_plugin ();
|
||||
}
|
||||
|
||||
void
|
||||
OSCSelectObserver::renew_plugin () {
|
||||
plugin_connections.drop_connections ();
|
||||
plugin_init();
|
||||
}
|
||||
|
||||
void
|
||||
OSCSelectObserver::plugin_init()
|
||||
{
|
||||
if (!sur->plugin_id || !sur->plugins.size ()) {
|
||||
if (plug_id < 0) {
|
||||
plugin_end ();
|
||||
return;
|
||||
}
|
||||
|
||||
boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route>(_strip);
|
||||
if (!r) {
|
||||
plugin_end ();
|
||||
return;
|
||||
}
|
||||
|
||||
// we have a plugin number now get the processor
|
||||
boost::shared_ptr<Processor> proc = r->nth_plugin (sur->plugins[sur->plugin_id - 1]);
|
||||
boost::shared_ptr<Processor> proc = r->nth_plugin (plug_id);
|
||||
boost::shared_ptr<PluginInsert> pi;
|
||||
if (!(pi = boost::dynamic_pointer_cast<PluginInsert>(proc))) {
|
||||
plugin_end ();
|
||||
return;
|
||||
}
|
||||
boost::shared_ptr<ARDOUR::Plugin> pip = pi->plugin();
|
||||
// we have a plugin we can ask if it is activated
|
||||
proc->ActiveChanged.connect (plugin_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::plug_enable, this, X_("/select/plugin/activate"), proc), OSC::instance());
|
||||
_osc.float_message ("/select/plugin/activate", proc->enabled(), addr);
|
||||
|
||||
bool ok = false;
|
||||
nplug_params = sur->plug_params.size ();
|
||||
// put only input controls into a vector
|
||||
plug_params.clear ();
|
||||
uint32_t nplug_params = pip->parameter_count();
|
||||
for ( uint32_t ppi = 0; ppi < nplug_params; ++ppi) {
|
||||
uint32_t controlid = pip->nth_parameter(ppi, ok);
|
||||
if (!ok) {
|
||||
continue;
|
||||
}
|
||||
if (pip->parameter_is_input(controlid)) {
|
||||
plug_params.push_back (ppi);
|
||||
}
|
||||
}
|
||||
nplug_params = plug_params.size ();
|
||||
|
||||
// default of 0 page size means show all
|
||||
plug_size = nplug_params;
|
||||
|
|
@ -417,20 +483,8 @@ OSCSelectObserver::plugin_init()
|
|||
plug_size = plug_page_size;
|
||||
}
|
||||
_osc.text_message ("/select/plugin/name", pip->name(), addr);
|
||||
uint32_t page_end = nplug_params;
|
||||
uint32_t max_page = 1;
|
||||
if (plug_size && nplug_params) {
|
||||
max_page = (uint32_t)((nplug_params - 1) / plug_size) + 1;
|
||||
}
|
||||
|
||||
if (sur->plug_page < 1) {
|
||||
sur->plug_page = 1;
|
||||
}
|
||||
if ((uint32_t)sur->plug_page > max_page) {
|
||||
sur->plug_page = max_page;
|
||||
}
|
||||
uint32_t page_start = ((sur->plug_page - 1) * plug_size);
|
||||
page_end = sur->plug_page * plug_size;
|
||||
uint32_t page_start = plug_page - 1;
|
||||
uint32_t page_end = page_start + plug_size;
|
||||
|
||||
int pid = 1;
|
||||
for ( uint32_t ppi = page_start; ppi < page_end; ++ppi, ++pid) {
|
||||
|
|
@ -440,7 +494,7 @@ OSCSelectObserver::plugin_init()
|
|||
continue;
|
||||
}
|
||||
|
||||
uint32_t controlid = pip->nth_parameter(sur->plug_params[ppi], ok);
|
||||
uint32_t controlid = pip->nth_parameter(plug_params[ppi], ok);
|
||||
if (!ok) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -461,25 +515,6 @@ OSCSelectObserver::plugin_init()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
OSCSelectObserver::send_end ()
|
||||
{
|
||||
send_connections.drop_connections ();
|
||||
for (uint32_t i = 1; i <= send_size; i++) {
|
||||
if (gainmode) {
|
||||
_osc.float_message_with_id ("/select/send_fader", i, 0, in_line, addr);
|
||||
} else {
|
||||
_osc.float_message_with_id ("/select/send_gain", i, -193, in_line, addr);
|
||||
}
|
||||
// next enable
|
||||
_osc.float_message_with_id ("/select/send_enable", i, 0, in_line, addr);
|
||||
// next name
|
||||
_osc.text_message_with_id ("/select/send_name", i, " ", in_line, addr);
|
||||
}
|
||||
// need to delete or clear send_timeout
|
||||
send_timeout.clear();
|
||||
}
|
||||
|
||||
void
|
||||
OSCSelectObserver::plugin_parameter_changed (int pid, bool swtch, boost::shared_ptr<PBD::Controllable> controllable)
|
||||
{
|
||||
|
|
@ -494,12 +529,14 @@ void
|
|||
OSCSelectObserver::plugin_end ()
|
||||
{
|
||||
plugin_connections.drop_connections ();
|
||||
_osc.float_message ("/select/plugin/activate", 0, addr);
|
||||
_osc.text_message ("/select/plugin/name", " ", addr);
|
||||
for (uint32_t i = 1; i <= plug_size; i++) {
|
||||
_osc.float_message_with_id ("/select/plugin/parameter", i, 0, in_line, addr);
|
||||
// next name
|
||||
_osc.text_message_with_id ("/select/plugin/parameter/name", i, " ", in_line, addr);
|
||||
}
|
||||
plug_size = 0;
|
||||
nplug_params = 0;
|
||||
}
|
||||
|
||||
|
|
@ -620,6 +657,15 @@ OSCSelectObserver::enable_message (string path, boost::shared_ptr<Controllable>
|
|||
|
||||
}
|
||||
|
||||
void
|
||||
OSCSelectObserver::plug_enable (string path, boost::shared_ptr<Processor> proc)
|
||||
{
|
||||
// with no delay value is wrong
|
||||
Glib::usleep(10);
|
||||
|
||||
_osc.float_message (path, proc->enabled(), addr);
|
||||
}
|
||||
|
||||
void
|
||||
OSCSelectObserver::change_message_with_id (string path, uint32_t id, boost::shared_ptr<Controllable> controllable)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -51,6 +51,9 @@ class OSCSelectObserver
|
|||
void set_expand (uint32_t expand);
|
||||
void set_send_page (uint32_t page);
|
||||
void set_send_size (uint32_t size);
|
||||
void set_plugin_id (int id, uint32_t page);
|
||||
void set_plugin_page (uint32_t page);
|
||||
void set_plugin_size (uint32_t size);
|
||||
|
||||
private:
|
||||
boost::shared_ptr<ARDOUR::Stripable> _strip;
|
||||
|
|
@ -81,9 +84,13 @@ class OSCSelectObserver
|
|||
uint32_t send_page_size;
|
||||
uint32_t send_size;
|
||||
uint32_t send_page;
|
||||
|
||||
uint32_t nplug_params;
|
||||
uint32_t plug_page_size;
|
||||
uint32_t plug_page;
|
||||
int plug_id;
|
||||
uint32_t plug_size;
|
||||
std::vector<int> plug_params;
|
||||
int eq_bands;
|
||||
bool _tick_busy;
|
||||
uint32_t _expand;
|
||||
|
|
@ -106,6 +113,7 @@ class OSCSelectObserver
|
|||
void plugin_parameter_changed (int pid, bool swtch, boost::shared_ptr<PBD::Controllable> controllable);
|
||||
void send_gain (uint32_t id, boost::shared_ptr<PBD::Controllable> controllable);
|
||||
void send_enable (std::string path, uint32_t id, boost::shared_ptr<ARDOUR::Processor> proc);
|
||||
void plug_enable (std::string path, boost::shared_ptr<ARDOUR::Processor> proc);
|
||||
void eq_init (void);
|
||||
void eq_end (void);
|
||||
void no_strip ();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue