Reinstate user Controllable values, as they are needed

for gain (which I forgot about).


git-svn-id: svn://localhost/ardour2/branches/3.0@11293 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2012-01-21 16:38:56 +00:00
parent a8bb49e5d8
commit 4381b590bb
9 changed files with 56 additions and 46 deletions

View file

@ -95,11 +95,11 @@ AutomationController::get_label (double& xpos)
void void
AutomationController::display_effective_value() AutomationController::display_effective_value()
{ {
double const ui_value = _controllable->user_to_ui (_controllable->get_value()); double const interface_value = _controllable->internal_to_interface (_controllable->get_value());
if (_adjustment->get_value() != ui_value) { if (_adjustment->get_value () != interface_value) {
_ignore_change = true; _ignore_change = true;
_adjustment->set_value (ui_value); _adjustment->set_value (interface_value);
_ignore_change = false; _ignore_change = false;
} }
} }
@ -108,7 +108,7 @@ void
AutomationController::value_adjusted () AutomationController::value_adjusted ()
{ {
if (!_ignore_change) { if (!_ignore_change) {
_controllable->set_value (_controllable->ui_to_user (_adjustment->get_value())); _controllable->set_value (_controllable->interface_to_internal (_adjustment->get_value()));
} }
} }

View file

@ -570,8 +570,8 @@ GenericPluginUI::build_control_ui (guint32 port_index, boost::shared_ptr<Automat
Adjustment* adj = control_ui->controller->adjustment(); Adjustment* adj = control_ui->controller->adjustment();
boost::shared_ptr<PluginInsert::PluginControl> pc = boost::dynamic_pointer_cast<PluginInsert::PluginControl> (control_ui->control); boost::shared_ptr<PluginInsert::PluginControl> pc = boost::dynamic_pointer_cast<PluginInsert::PluginControl> (control_ui->control);
adj->set_lower (pc->user_to_ui (desc.lower)); adj->set_lower (pc->internal_to_interface (desc.lower));
adj->set_upper (pc->user_to_ui (desc.upper)); adj->set_upper (pc->internal_to_interface (desc.upper));
adj->set_step_increment (desc.step); adj->set_step_increment (desc.step);
adj->set_page_increment (desc.largestep); adj->set_page_increment (desc.largestep);
@ -594,7 +594,7 @@ GenericPluginUI::build_control_ui (guint32 port_index, boost::shared_ptr<Automat
} }
adj->set_value (pc->user_to_ui (plugin->get_parameter (port_index))); adj->set_value (pc->internal_to_interface (plugin->get_parameter (port_index)));
/* XXX memory leak: SliderController not destroyed by ControlUI /* XXX memory leak: SliderController not destroyed by ControlUI
destructor, and manage() reports object hierarchy destructor, and manage() reports object hierarchy

View file

@ -385,14 +385,14 @@ ProcessorEntry::Control::Control (Glib::RefPtr<Gdk::Pixbuf> s, boost::shared_ptr
_slider.show (); _slider.show ();
box.pack_start (_slider); box.pack_start (_slider);
double const lo = c->user_to_ui (c->lower ()); double const lo = c->internal_to_interface (c->lower ());
double const up = c->user_to_ui (c->upper ()); double const up = c->internal_to_interface (c->upper ());
_adjustment.set_lower (lo); _adjustment.set_lower (lo);
_adjustment.set_upper (up); _adjustment.set_upper (up);
_adjustment.set_step_increment ((up - lo) / 100); _adjustment.set_step_increment ((up - lo) / 100);
_adjustment.set_page_increment ((up - lo) / 10); _adjustment.set_page_increment ((up - lo) / 10);
_slider.set_default_value (c->user_to_ui (c->normal ())); _slider.set_default_value (c->internal_to_interface (c->normal ()));
_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &Control::slider_adjusted)); _adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &Control::slider_adjusted));
c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ()); c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
@ -419,7 +419,7 @@ ProcessorEntry::Control::slider_adjusted ()
return; return;
} }
c->set_value (c->ui_to_user (_adjustment.get_value ())); c->set_value (c->interface_to_internal (_adjustment.get_value ()));
} }
void void
@ -432,14 +432,12 @@ ProcessorEntry::Control::control_changed ()
_ignore_slider_adjustment = true; _ignore_slider_adjustment = true;
_adjustment.set_value (c->user_to_ui (c->get_value ())); _adjustment.set_value (c->internal_to_interface (c->get_value ()));
/* XXX: general presentation of values to the user */
stringstream s; stringstream s;
s.precision (1); s.precision (1);
s.setf (ios::fixed, ios::floatfield); s.setf (ios::fixed, ios::floatfield);
s << accurate_coefficient_to_dB (c->get_value ()); s << c->internal_to_user (c->get_value ());
s << _("dB");
_slider.set_tooltip_text (s.str ()); _slider.set_tooltip_text (s.str ());

View file

@ -423,23 +423,23 @@ Amp::GainControl::set_value (double val)
} }
double double
Amp::GainControl::get_value (void) const Amp::GainControl::internal_to_interface (double v) const
{
return AutomationControl::get_value();
}
double
Amp::GainControl::user_to_ui (double v) const
{ {
return gain_to_slider_position (v); return gain_to_slider_position (v);
} }
double double
Amp::GainControl::ui_to_user (double v) const Amp::GainControl::interface_to_internal (double v) const
{ {
return slider_position_to_gain (v); return slider_position_to_gain (v);
} }
double
Amp::GainControl::internal_to_user (double v) const
{
return accurate_coefficient_to_dB (v);
}
void void
Amp::setup_gain_automation (framepos_t start_frame, framepos_t end_frame, framecnt_t nframes) Amp::setup_gain_automation (framepos_t start_frame, framepos_t end_frame, framecnt_t nframes)
{ {

View file

@ -82,10 +82,10 @@ public:
} }
void set_value (double val); void set_value (double val);
double get_value (void) const;
double user_to_ui (double) const; double internal_to_interface (double) const;
double ui_to_user (double) const; double interface_to_internal (double) const;
double internal_to_user (double) const;
Amp* _amp; Amp* _amp;
}; };

View file

@ -77,6 +77,18 @@ public:
void set_value (double); void set_value (double);
double get_value () const; double get_value () const;
virtual double internal_to_interface (double v) const {
return v;
}
virtual double interface_to_internal (double v) const {
return v;
}
virtual double internal_to_user (double v) const {
return v;
}
double lower() const { return parameter().min(); } double lower() const { return parameter().min(); }
double upper() const { return parameter().max(); } double upper() const { return parameter().max(); }
double normal() const { return parameter().normal(); } double normal() const { return parameter().normal(); }

View file

@ -89,8 +89,8 @@ class PluginInsert : public Processor
double get_value (void) const; double get_value (void) const;
XMLNode& get_state(); XMLNode& get_state();
double user_to_ui (double) const; double internal_to_interface (double) const;
double ui_to_user (double) const; double interface_to_internal (double) const;
private: private:
PluginInsert* _plugin; PluginInsert* _plugin;

View file

@ -1174,7 +1174,7 @@ PluginInsert::PluginControl::set_value (double user_val)
} }
double double
PluginInsert::PluginControl::user_to_ui (double val) const PluginInsert::PluginControl::internal_to_interface (double val) const
{ {
if (_logarithmic) { if (_logarithmic) {
if (val > 0) { if (val > 0) {
@ -1188,7 +1188,7 @@ PluginInsert::PluginControl::user_to_ui (double val) const
} }
double double
PluginInsert::PluginControl::ui_to_user (double val) const PluginInsert::PluginControl::interface_to_internal (double val) const
{ {
if (_logarithmic) { if (_logarithmic) {
val = exp (val); val = exp (val);

View file

@ -43,27 +43,27 @@ class Controllable : public PBD::StatefulDestructible {
Controllable (const std::string& name, Flag f = Flag (0)); Controllable (const std::string& name, Flag f = Flag (0));
virtual ~Controllable() { Destroyed (this); } virtual ~Controllable() { Destroyed (this); }
/* We express Controllable values in one of two ways: /* We express Controllable values in one of three ways:
* 1. `UI' --- as used in some cases for the internal representation * 1. `user' --- as presented to the user (e.g. dB, Hz, etc.)
* of the UI. This may be the same as `user', or may be something * 2. `interface' --- as used in some cases for the UI representation
* like the natural log of frequency in order that sliders operate * (in order to make controls behave logarithmically).
* in a logarithmic fashion. * 3. `internal' --- as passed to a processor, track, plugin, or whatever.
* 2. `user' --- as passed to a plugin, and presented to the user. *
* Note that in some cases user and processor may be the same
* (and interface different) e.g. frequency, which is presented
* to the user and passed to the processor in linear terms, but
* which needs log scaling in the interface.
*
* In other cases, user and interface may be the same (and processor different)
* e.g. gain, which is presented to the user in log terms (dB)
* but passed to the processor as a linear quantity.
*/ */
/** Set `user' value */ /** Set `internal' value */
virtual void set_value (double) = 0; virtual void set_value (double) = 0;
/** @return `user' value */ /** @return `internal' value */
virtual double get_value (void) const = 0; virtual double get_value (void) const = 0;
virtual double user_to_ui (double v) const {
return v;
}
virtual double ui_to_user (double v) const {
return v;
}
PBD::Signal0<void> LearningFinished; PBD::Signal0<void> LearningFinished;
static PBD::Signal3<void,PBD::Controllable*,int,int> CreateBinding; static PBD::Signal3<void,PBD::Controllable*,int,int> CreateBinding;
static PBD::Signal1<void,PBD::Controllable*> DeleteBinding; static PBD::Signal1<void,PBD::Controllable*> DeleteBinding;