13
0

OSC: Expand gainmode to add two new options

fix bug where a surface might have more than one global observer
This commit is contained in:
Len Ovens 2018-01-09 19:19:29 -08:00
parent 7671268bc3
commit 7d6e6424c7
7 changed files with 47 additions and 40 deletions

View File

@ -2057,6 +2057,8 @@ OSC::get_surface (lo_address addr , bool quiet)
void
OSC::global_feedback (OSCSurface* sur)
{
OSCGlobalObserver* o = sur->global_obs;
delete o;
if (sur->feedback[4] || sur->feedback[3] || sur->feedback[5] || sur->feedback[6]) {
// create a new Global Observer for this surface
@ -3821,7 +3823,7 @@ 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) {
so->refresh_strip (s, nsends, true);
so->refresh_strip (s, nsends, sur->gainmode, true);
} else {
OSCSelectObserver* sel_fb = new OSCSelectObserver (*this, sur);
sur->sel_obs = sel_fb;

View File

@ -366,14 +366,16 @@ OSCGlobalObserver::send_gain_message (string path, boost::shared_ptr<Controllabl
}
if (gainmode) {
_osc.float_message (string_compose ("%1fader", path), controllable->internal_to_interface (controllable->get_value()), addr);
_osc.text_message (string_compose ("%1name", path), string_compose ("%1%2%3", std::fixed, std::setprecision(2), accurate_coefficient_to_dB (controllable->get_value())), addr);
if (ismaster) {
master_timeout = 8;
} else {
monitor_timeout = 8;
if (gainmode == 1) {
_osc.text_message (string_compose ("%1name", path), string_compose ("%1%2%3", std::fixed, std::setprecision(2), accurate_coefficient_to_dB (controllable->get_value())), addr);
if (ismaster) {
master_timeout = 8;
} else {
monitor_timeout = 8;
}
}
} else {
}
if (!gainmode || gainmode == 2) {
if (controllable->get_value() < 1e-15) {
_osc.float_message (string_compose ("%1gain",path), -200, addr);
} else {
@ -460,7 +462,6 @@ OSCGlobalObserver::mark_update ()
}
_osc.text_message (X_("/marker"), send_str, addr);
}
}

View File

@ -138,6 +138,8 @@ OSC_GUI::OSC_GUI (OSC& p)
table->attach (gainmode_combo, 1, 2, n, n+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
std::vector<std::string> gainmode_options;
gainmode_options.push_back (_("/strip/gain (dB)"));
gainmode_options.push_back (_("/strip/fader (Position) and dB in control name"));
gainmode_options.push_back (_("/strip/fader (Position) and /strip/gain (dB)"));
gainmode_options.push_back (_("/strip/fader (Position)"));
set_popdown_strings (gainmode_combo, gainmode_options);
@ -583,9 +585,15 @@ OSC_GUI::gainmode_changed ()
if (str == _("/strip/gain (dB)")) {
cp.set_gainmode (0);
}
else if (str == _("/strip/fader (Position)")) {
else if (str == _("/strip/fader (Position) and dB in control name")) {
cp.set_gainmode (1);
}
else if (str == _("/strip/fader (Position) and /strip/gain (dB)")) {
cp.set_gainmode (2);
}
else if (str == _("/strip/fader (Position)")) {
cp.set_gainmode (3);
}
else {
std::cerr << "Invalid OSC Gain Mode\n";
assert (0);

View File

@ -322,12 +322,6 @@ OSCRouteObserver::tick ()
}
gain_timeout--;
}
if (trim_timeout) {
if (trim_timeout == 1) {
_osc.text_message_with_id ("/strip/name", ssid, _strip->name(), in_line, addr);
}
trim_timeout--;
}
if (as == ARDOUR::Play || as == ARDOUR::Touch) {
if(_last_gain != _strip->gain_control()->get_value()) {
_last_gain = _strip->gain_control()->get_value();
@ -392,11 +386,6 @@ OSCRouteObserver::send_trim_message ()
} else {
return;
}
if (gainmode) {
_osc.text_message_with_id ("/strip/name", ssid, string_compose ("%1%2%3", std::fixed, std::setprecision(2), accurate_coefficient_to_dB (_last_trim)), in_line, addr);
trim_timeout = 8;
}
_osc.float_message_with_id ("/strip/trimdB", ssid, (float) accurate_coefficient_to_dB (_last_trim), in_line, addr);
}
@ -412,9 +401,12 @@ OSCRouteObserver::send_gain_message ()
if (gainmode) {
_osc.float_message_with_id ("/strip/fader", ssid, controllable->internal_to_interface (_last_gain), in_line, addr);
_osc.text_message_with_id ("/strip/name", ssid, string_compose ("%1%2%3", std::fixed, std::setprecision(2), accurate_coefficient_to_dB (controllable->get_value())), in_line, addr);
gain_timeout = 8;
} else {
if (gainmode == 1) {
_osc.text_message_with_id ("/strip/name", ssid, string_compose ("%1%2%3", std::fixed, std::setprecision(2), accurate_coefficient_to_dB (controllable->get_value())), in_line, addr);
gain_timeout = 8;
}
}
if (!gainmode || gainmode == 2) {
if (controllable->get_value() < 1e-15) {
_osc.float_message_with_id ("/strip/gain", ssid, -200, in_line, addr);
} else {

View File

@ -63,7 +63,6 @@ class OSCRouteObserver
ArdourSurface::OSC::OSCSurface* sur;
float _last_meter;
uint32_t gain_timeout;
uint32_t trim_timeout;
float _last_gain;
float _last_trim;
bool _init;

View File

@ -74,7 +74,7 @@ OSCSelectObserver::OSCSelectObserver (OSC& o, ArdourSurface::OSC::OSCSurface* su
} else {
plug_id = -1;
}
refresh_strip (sur->select, sur->nsends, true);
refresh_strip (sur->select, sur->nsends, gainmode, true);
set_expand (sur->expand_enable);
}
@ -104,12 +104,13 @@ OSCSelectObserver::no_strip ()
}
void
OSCSelectObserver::refresh_strip (boost::shared_ptr<ARDOUR::Stripable> new_strip, uint32_t s_nsends, bool force)
OSCSelectObserver::refresh_strip (boost::shared_ptr<ARDOUR::Stripable> new_strip, uint32_t s_nsends, uint32_t gm, bool force)
{
_init = true;
if (_tick_busy) {
Glib::usleep(100); // let tick finish
}
gainmode = gm;
if (_strip && (new_strip == _strip) && !force) {
_init = false;
@ -384,7 +385,7 @@ OSCSelectObserver::send_init()
_osc.float_message_with_id ("/select/send_enable", c, proc->enabled(), in_line, addr);
}
}
if (!gainmode && send_valid) {
if ((gainmode != 1) && send_valid) {
_osc.text_message_with_id ("/select/send_name", c, _strip->send_name(s), in_line, addr);
}
}
@ -732,10 +733,13 @@ OSCSelectObserver::gain_message ()
}
if (gainmode) {
_osc.text_message ("/select/name", string_compose ("%1%2%3", std::fixed, std::setprecision(2), accurate_coefficient_to_dB (value)), addr);
gain_timeout = 8;
_osc.float_message ("/select/fader", _strip->gain_control()->internal_to_interface (value), addr);
} else {
if (gainmode == 1) {
_osc.text_message ("/select/name", string_compose ("%1%2%3", std::fixed, std::setprecision(2), accurate_coefficient_to_dB (value)), addr);
gain_timeout = 8;
}
}
if (!gainmode || gainmode == 2) {
if (value < 1e-15) {
_osc.float_message ("/select/gain", -200, addr);
} else {
@ -812,20 +816,21 @@ OSCSelectObserver::send_gain (uint32_t id, boost::shared_ptr<PBD::Controllable>
#endif
if (gainmode) {
path = "/select/send_fader";
if (controllable) {
value = controllable->internal_to_interface (raw_value);
}
_osc.text_message_with_id ("/select/send_name" , id, string_compose ("%1%2%3", std::fixed, std::setprecision(2), db), in_line, addr);
if (send_timeout.size() > id) {
send_timeout[id] = 8;
_osc.float_message_with_id ("/select/send_fader", id, value, in_line, addr);
if (gainmode == 1) {
_osc.text_message_with_id ("/select/send_name" , id, string_compose ("%1%2%3", std::fixed, std::setprecision(2), db), in_line, addr);
if (send_timeout.size() > id) {
send_timeout[id] = 8;
}
}
} else {
path = "/select/send_gain";
value = db;
}
if (!gainmode || gainmode == 2) {
_osc.float_message_with_id ("/select/send_gain", id, db, in_line, addr);
}
_osc.float_message_with_id (path, id, value, in_line, addr);
}
void

View File

@ -47,7 +47,7 @@ class OSCSelectObserver
void renew_plugin (void);
void eq_restart (int);
void clear_observer (void);
void refresh_strip (boost::shared_ptr<ARDOUR::Stripable> new_strip, uint32_t nsends, bool force);
void refresh_strip (boost::shared_ptr<ARDOUR::Stripable> new_strip, uint32_t nsends, uint32_t g_mode, bool force);
void set_expand (uint32_t expand);
void set_send_page (uint32_t page);
void set_send_size (uint32_t size);