Note: Control-surfaces should always use interface_to_internal()
and internal_to_interface().
gain_adjustment.set_upper (GAIN_COEFF_UNITY);
gain_adjustment.set_step_increment (dB_coeff_step(Config->get_max_gain()) / 10.0);
gain_adjustment.set_page_increment (dB_coeff_step(Config->get_max_gain()));
gain_adjustment.set_upper (GAIN_COEFF_UNITY);
gain_adjustment.set_step_increment (dB_coeff_step(Config->get_max_gain()) / 10.0);
gain_adjustment.set_page_increment (dB_coeff_step(Config->get_max_gain()));
- gain_slider->set_default_value (gain_to_slider_position (GAIN_COEFF_UNITY));
+ gain_slider->set_default_value (gain_to_slider_position_with_max (GAIN_COEFF_UNITY, Config->get_max_gain()));
} else {
_data_type = DataType::MIDI;
gain_adjustment.set_lower (0.0);
} else {
_data_type = DataType::MIDI;
gain_adjustment.set_lower (0.0);
GainControl::internal_to_interface (double v) const
{
if (_desc.type == GainAutomation) {
GainControl::internal_to_interface (double v) const
{
if (_desc.type == GainAutomation) {
- return gain_to_slider_position (v);
+ return gain_to_slider_position_with_max (v, _desc.upper);
} else {
return (accurate_coefficient_to_dB (v) - lower_db) / range_db;
}
} else {
return (accurate_coefficient_to_dB (v) - lower_db) / range_db;
}
GainControl::interface_to_internal (double v) const
{
if (_desc.type == GainAutomation) {
GainControl::interface_to_internal (double v) const
{
if (_desc.type == GainAutomation) {
- return slider_position_to_gain (v);
+ return slider_position_to_gain_with_max (v, _desc.upper);
} else {
return dB_to_coefficient (lower_db + v * range_db);
}
} else {
return dB_to_coefficient (lower_db + v * range_db);
}
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string.hpp>
+#include "pbd/control_math.h"
+
#include "ardour/amp.h"
#include "ardour/dB.h"
#include "ardour/parameter_descriptor.h"
#include "ardour/amp.h"
#include "ardour/dB.h"
#include "ardour/parameter_descriptor.h"
/* dB_coeff_step gives a step normalized for [0, max_gain]. This is
like "slider position", so we convert from "slider position" to gain
to have the correct unit here. */
/* dB_coeff_step gives a step normalized for [0, max_gain]. This is
like "slider position", so we convert from "slider position" to gain
to have the correct unit here. */
- largestep = slider_position_to_gain(dB_coeff_step(upper));
- step = slider_position_to_gain(largestep / 10.0);
+ largestep = position_to_gain (dB_coeff_step(upper));
+ step = position_to_gain (largestep / 10.0);
smallstep = step;
} else {
/* note that LV2Plugin::get_parameter_descriptor ()
smallstep = step;
} else {
/* note that LV2Plugin::get_parameter_descriptor ()
#include <iostream>
#include "pbd/error.h"
#include <iostream>
#include "pbd/error.h"
+#include "pbd/compose.h"
#include "pbd/stacktrace.h"
#include "pbd/types_convert.h"
#include "pbd/stacktrace.h"
#include "pbd/types_convert.h"
-#include "pbd/compose.h"
#include "midi++/types.h" // Added by JE - 06-01-2009. All instances of 'byte' changed to 'MIDI::byte' (for clarification)
#include "midi++/port.h"
#include "midi++/types.h" // Added by JE - 06-01-2009. All instances of 'byte' changed to 'MIDI::byte' (for clarification)
#include "midi++/port.h"
#include "ardour/automation_control.h"
#include "ardour/controllable_descriptor.h"
#include "ardour/midi_ui.h"
#include "ardour/automation_control.h"
#include "ardour/controllable_descriptor.h"
#include "ardour/midi_ui.h"
-#include "ardour/utils.h"
#include "ardour/debug.h"
#include "midicontrollable.h"
#include "ardour/debug.h"
#include "midicontrollable.h"
MIDIControllable::control_to_midi (float val)
{
if (controllable->is_gain_like()) {
MIDIControllable::control_to_midi (float val)
{
if (controllable->is_gain_like()) {
- return gain_to_slider_position (val) * max_value_for_type ();
+ return controllable->internal_to_interface (val) * max_value_for_type ();
}
float control_min = controllable->lower ();
}
float control_min = controllable->lower ();
#include "pbd/gstdio_compat.h"
#include <glibmm.h>
#include "pbd/gstdio_compat.h"
#include <glibmm.h>
+#include "pbd/control_math.h"
#include <pbd/convert.h>
#include <pbd/pthread_utils.h>
#include <pbd/file_utils.h>
#include <pbd/convert.h>
#include <pbd/pthread_utils.h>
#include <pbd/file_utils.h>
REGISTER_CALLBACK (serv, "/select/eq_q", "if", sel_eq_q);
REGISTER_CALLBACK (serv, "/select/eq_shape", "if", sel_eq_shape);
REGISTER_CALLBACK (serv, "/select/eq_q", "if", sel_eq_q);
REGISTER_CALLBACK (serv, "/select/eq_shape", "if", sel_eq_shape);
- /* These commands require the route index in addition to the arg; TouchOSC (et al) can't use these */
+ /* These commands require the route index in addition to the arg; TouchOSC (et al) can't use these */
REGISTER_CALLBACK (serv, "/strip/mute", "ii", route_mute);
REGISTER_CALLBACK (serv, "/strip/solo", "ii", route_solo);
REGISTER_CALLBACK (serv, "/strip/solo_iso", "ii", route_solo_iso);
REGISTER_CALLBACK (serv, "/strip/mute", "ii", route_mute);
REGISTER_CALLBACK (serv, "/strip/solo", "ii", route_solo);
REGISTER_CALLBACK (serv, "/strip/solo_iso", "ii", route_solo_iso);
REGISTER_CALLBACK (serv, "/strip/send/enable", "iif", route_set_send_enable);
REGISTER_CALLBACK(serv, "/strip/name", "is", route_rename);
REGISTER_CALLBACK(serv, "/strip/sends", "i", route_get_sends);
REGISTER_CALLBACK (serv, "/strip/send/enable", "iif", route_set_send_enable);
REGISTER_CALLBACK(serv, "/strip/name", "is", route_rename);
REGISTER_CALLBACK(serv, "/strip/sends", "i", route_get_sends);
- REGISTER_CALLBACK(serv, "/strip/receives", "i", route_get_receives);
+ REGISTER_CALLBACK(serv, "/strip/receives", "i", route_get_receives);
REGISTER_CALLBACK(serv, "/strip/plugin/list", "i", route_plugin_list);
REGISTER_CALLBACK(serv, "/strip/plugin/descriptor", "ii", route_plugin_descriptor);
REGISTER_CALLBACK(serv, "/strip/plugin/reset", "ii", route_plugin_reset);
REGISTER_CALLBACK(serv, "/strip/plugin/list", "i", route_plugin_list);
REGISTER_CALLBACK(serv, "/strip/plugin/descriptor", "ii", route_plugin_descriptor);
REGISTER_CALLBACK(serv, "/strip/plugin/reset", "ii", route_plugin_reset);
if (!session) return -1;
boost::shared_ptr<Stripable> s = session->master_out();
if (s) {
if (!session) return -1;
boost::shared_ptr<Stripable> s = session->master_out();
if (s) {
- s->gain_control()->set_value (slider_position_to_gain_with_max (position, 2.0), PBD::Controllable::NoGroup);
+ s->gain_control()->set_value (slider_position_to_gain_with_max (position, 2.0), PBD::Controllable::NoGroup); // XXX use interface_to_internal, unhardcode 2.0
if (!session) return -1;
boost::shared_ptr<Stripable> s = session->monitor_out();
if (s) {
if (!session) return -1;
boost::shared_ptr<Stripable> s = session->monitor_out();
if (s) {
- s->gain_control()->set_value (slider_position_to_gain_with_max (position, 2.0), PBD::Controllable::NoGroup);
+ s->gain_control()->set_value (slider_position_to_gain_with_max (position, 2.0), PBD::Controllable::NoGroup); // XXX use internal_to_interface, unhardcode 2.0
lo_message_add_string(reply, isend->name().c_str());
lo_message_add_int32(reply, i);
boost::shared_ptr<Amp> a = isend->amp();
lo_message_add_string(reply, isend->name().c_str());
lo_message_add_int32(reply, i);
boost::shared_ptr<Amp> a = isend->amp();
- lo_message_add_float(reply, gain_to_slider_position(a->gain_control()->get_value()));
+ lo_message_add_float(reply, gain_to_position(a->gain_control()->get_value())); // XXX use internal_to_interface
lo_message_add_int32(reply, p->active() ? 1 : 0);
}
}
lo_message_add_int32(reply, p->active() ? 1 : 0);
}
}
lo_message_add_int32(reply, get_sid(tr, get_address(msg)));
lo_message_add_string(reply, tr->name().c_str());
lo_message_add_int32(reply, j);
lo_message_add_int32(reply, get_sid(tr, get_address(msg)));
lo_message_add_string(reply, tr->name().c_str());
lo_message_add_int32(reply, j);
- lo_message_add_float(reply, gain_to_slider_position(a->gain_control()->get_value()));
+ lo_message_add_float(reply, gain_to_position(a->gain_control()->get_value())); // XXX use internal_to_interface
lo_message_add_int32(reply, p->active() ? 1 : 0);
}
}
lo_message_add_int32(reply, p->active() ? 1 : 0);
}
}
- ret = route_set_gain_abs (ssid, slider_position_to_gain_with_max (pos, 2.0), msg);
+ ret = route_set_gain_abs (ssid, slider_position_to_gain_with_max (pos, 2.0), msg); // XXX use interface_to_internal, unhardcode 2.0
if (ret != 0) {
return route_send_fail ("fader", ssid, 0, get_address (msg));
}
if (ret != 0) {
return route_send_fail ("fader", ssid, 0, get_address (msg));
}
- abs = slider_position_to_gain_with_max (val, 2.0);
+ abs = slider_position_to_gain_with_max (val, 2.0); // XXX use interface_to_internal, unhardcode 2.0
if (s->gain_control()) {
fake_touch (s->gain_control());
s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
if (s->gain_control()) {
fake_touch (s->gain_control());
s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
#ifdef MIXBUS
abs = s->send_level_controllable(id)->interface_to_internal (val);
#else
#ifdef MIXBUS
abs = s->send_level_controllable(id)->interface_to_internal (val);
#else
- abs = slider_position_to_gain_with_max (val, 2.0);
+ abs = slider_position_to_gain_with_max (val, 2.0); // XXX use interface_to_internal, unhardcode 2.0
#endif
s->send_level_controllable (id)->set_value (abs, PBD::Controllable::NoGroup);
return 0;
#endif
s->send_level_controllable (id)->set_value (abs, PBD::Controllable::NoGroup);
return 0;
#ifdef MIXBUS
abs = s->send_level_controllable(send_id)->interface_to_internal (val);
#else
#ifdef MIXBUS
abs = s->send_level_controllable(send_id)->interface_to_internal (val);
#else
- abs = slider_position_to_gain_with_max (val, 2.0);
+ abs = slider_position_to_gain_with_max (val, 2.0); // XXX interface_to_internal, unhardcode 2.0
#endif
s->send_level_controllable (send_id)->set_value (abs, PBD::Controllable::NoGroup);
return 0;
#endif
s->send_level_controllable (send_id)->set_value (abs, PBD::Controllable::NoGroup);
return 0;
- abs = slider_position_to_gain_with_max (position, 2.0);
+ abs = slider_position_to_gain_with_max (position, 2.0); // XXX use interface_to_internal, unhardcode 2.0
if (s->gain_control()) {
s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
return 0;
if (s->gain_control()) {
s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
return 0;
float abs;
if (s) {
if (s->gain_control()) {
float abs;
if (s) {
if (s->gain_control()) {
- abs = slider_position_to_gain_with_max (val, 2.0);
+ abs = slider_position_to_gain_with_max (val, 2.0); // XXX use interface_to_internal, unhardcode 2.0
s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
return 0;
}
s->gain_control()->set_value (abs, PBD::Controllable::NoGroup);
return 0;
}
#include "boost/lambda/lambda.hpp"
#include "boost/lambda/lambda.hpp"
+#include "pbd/control_math.h"
+
#include "ardour/track.h"
#include "ardour/dB.h"
#include "ardour/meter.h"
#include "ardour/track.h"
#include "ardour/dB.h"
#include "ardour/meter.h"
path = string_compose ("%1/%2", path, id);
}
lo_message msg = lo_message_new ();
path = string_compose ("%1/%2", path, id);
}
lo_message msg = lo_message_new ();
- lo_message_add_float (msg, gain_to_slider_position (controllable->get_value()));
+ lo_message_add_float (msg, gain_to_position (controllable->get_value())); // XXX use internal_to_interface
gain_timeout[id] = 8;
lo_send_message (addr, path.c_str(), msg);
gain_timeout[id] = 8;
lo_send_message (addr, path.c_str(), msg);
#include "boost/lambda/lambda.hpp"
#include "boost/lambda/lambda.hpp"
+#include "pbd/control_math.h"
+
#include "ardour/session.h"
#include "ardour/dB.h"
#include "ardour/meter.h"
#include "ardour/session.h"
#include "ardour/dB.h"
#include "ardour/meter.h"
OSCGlobalObserver::send_gain_message (string path, boost::shared_ptr<Controllable> controllable)
{
if (gainmode) {
OSCGlobalObserver::send_gain_message (string path, boost::shared_ptr<Controllable> controllable)
{
if (gainmode) {
- float_message (string_compose ("%1fader", path), gain_to_slider_position (controllable->get_value()));
+ float_message (string_compose ("%1fader", path), gain_to_position (controllable->get_value())); // XXX use internal_to_interface
text_message (string_compose ("%1name", path), string_compose ("%1%2%3", std::fixed, std::setprecision(2), accurate_coefficient_to_dB (controllable->get_value())));
if (path.find("master") != std::string::npos) {
master_timeout = 8;
text_message (string_compose ("%1name", path), string_compose ("%1%2%3", std::fixed, std::setprecision(2), accurate_coefficient_to_dB (controllable->get_value())));
if (path.find("master") != std::string::npos) {
master_timeout = 8;
#include "boost/lambda/lambda.hpp"
#include "boost/lambda/lambda.hpp"
+#include "pbd/control_math.h"
+
#include "ardour/session.h"
#include "ardour/track.h"
#include "ardour/monitor_control.h"
#include "ardour/session.h"
#include "ardour/track.h"
#include "ardour/monitor_control.h"
- lo_message_add_float (msg, gain_to_slider_position (controllable->get_value()));
+ lo_message_add_float (msg, gain_to_position (controllable->get_value())); // XXX use internal_to_interface
text_with_id ("/strip/name", ssid, string_compose ("%1%2%3", std::fixed, std::setprecision(2), accurate_coefficient_to_dB (controllable->get_value())));
gain_timeout = 8;
} else {
text_with_id ("/strip/name", ssid, string_compose ("%1%2%3", std::fixed, std::setprecision(2), accurate_coefficient_to_dB (controllable->get_value())));
gain_timeout = 8;
} else {
#include <vector>
#include "boost/lambda/lambda.hpp"
#include <vector>
#include "boost/lambda/lambda.hpp"
+#include "pbd/control_math.h"
+
#include "ardour/session.h"
#include "ardour/track.h"
#include "ardour/monitor_control.h"
#include "ardour/session.h"
#include "ardour/track.h"
#include "ardour/monitor_control.h"
if (gainmode) {
text_message ("/select/name", string_compose ("%1%2%3", std::fixed, std::setprecision(2), accurate_coefficient_to_dB (value)));
gain_timeout = 8;
if (gainmode) {
text_message ("/select/name", string_compose ("%1%2%3", std::fixed, std::setprecision(2), accurate_coefficient_to_dB (value)));
gain_timeout = 8;
- send_float ("/select/fader", gain_to_slider_position (value));
+ send_float ("/select/fader", gain_to_position (value)); // XXX use internal_to_interface
} else {
if (value < 1e-15) {
send_float ("/select/gain", -200);
} else {
if (value < 1e-15) {
send_float ("/select/gain", -200);
#ifdef MIXBUS
value = controllable->internal_to_interface (controllable->get_value());
#else
#ifdef MIXBUS
value = controllable->internal_to_interface (controllable->get_value());
#else
- value = gain_to_slider_position (controllable->get_value());
+ value = gain_to_position (controllable->get_value()); // XXX use internal_to_interface
#endif
text_with_id ("/select/send_name" , id, string_compose ("%1%2%3", std::fixed, std::setprecision(2), db));
if (send_timeout.size() > id) {
#endif
text_with_id ("/select/send_name" , id, string_compose ("%1%2%3", std::fixed, std::setprecision(2), db));
if (send_timeout.size() > id) {