much ado about nothing when it comes to gain control

git-svn-id: svn://localhost/ardour2/branches/3.0@9748 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2011-06-19 23:02:55 +00:00
parent 182b23e744
commit d5e09076ca
23 changed files with 211 additions and 122 deletions

View file

@ -571,7 +571,7 @@ style "medium_entry" = "medium_text"
fg[ACTIVE] = @@COLPREFIX@_text fg[ACTIVE] = @@COLPREFIX@_text
fg[SELECTED] = @@COLPREFIX@_fg_selected fg[SELECTED] = @@COLPREFIX@_fg_selected
bg[NORMAL] = @@COLPREFIX@_bg bg[NORMAL] = @@COLPREFIX@_base
base[NORMAL] = @@COLPREFIX@_base base[NORMAL] = @@COLPREFIX@_base
base[ACTIVE] = @@COLPREFIX@_base base[ACTIVE] = @@COLPREFIX@_base
@ -593,7 +593,7 @@ style "medium_bold_entry" = "medium_bold_text"
fg[NORMAL] = @@COLPREFIX@_text fg[NORMAL] = @@COLPREFIX@_text
fg[ACTIVE] = @@COLPREFIX@_text fg[ACTIVE] = @@COLPREFIX@_text
bg[NORMAL] = @@COLPREFIX@_bg bg[NORMAL] = @@COLPREFIX@_base
base[NORMAL] = @@COLPREFIX@_base base[NORMAL] = @@COLPREFIX@_base
base[ACTIVE] = @@COLPREFIX@_base base[ACTIVE] = @@COLPREFIX@_base
@ -627,7 +627,7 @@ style "small_bold_entry" = "small_bold_text"
fg[NORMAL] = @@COLPREFIX@_text fg[NORMAL] = @@COLPREFIX@_text
fg[ACTIVE] = @@COLPREFIX@_text fg[ACTIVE] = @@COLPREFIX@_text
bg[NORMAL] = @@COLPREFIX@_bg bg[NORMAL] = @@COLPREFIX@_base
base[NORMAL] = @@COLPREFIX@_base base[NORMAL] = @@COLPREFIX@_base
base[ACTIVE] = @@COLPREFIX@_base base[ACTIVE] = @@COLPREFIX@_base

View file

@ -237,7 +237,8 @@ widget "*PluginParameterLabel" style:highest "medium_text"
widget "*PluginNameInfo" style:highest "plugin_name_text" widget "*PluginNameInfo" style:highest "plugin_name_text"
widget "*PluginMakerInfo" style:highest "plugin_maker_text" widget "*PluginMakerInfo" style:highest "plugin_maker_text"
widget "*PluginParameterInfo" style:highest "medium_text" widget "*PluginParameterInfo" style:highest "medium_text"
widget "*MotionControllerValue" style:highest "medium_entry" widget "*MotionControllerValue" style:highest "small_entry"
widget "*MotionControllerValue*" style:highest "small_entry"
widget "*ParameterValueDisplay" style:highest "medium_bold_entry" widget "*ParameterValueDisplay" style:highest "medium_bold_entry"
widget "*PluginUIClickBox" style:highest "medium_bold_entry" widget "*PluginUIClickBox" style:highest "medium_bold_entry"
widget "*PluginUIClickBox*" style:highest "medium_bold_entry" widget "*PluginUIClickBox*" style:highest "medium_bold_entry"

View file

@ -521,7 +521,7 @@ AutomationLine::fraction_to_string (double fraction) const
if (fraction == 0.0) { if (fraction == 0.0) {
snprintf (buf, sizeof (buf), "-inf"); snprintf (buf, sizeof (buf), "-inf");
} else { } else {
snprintf (buf, sizeof (buf), "%.1f", accurate_coefficient_to_dB (slider_position_to_gain (fraction))); snprintf (buf, sizeof (buf), "%.1f", accurate_coefficient_to_dB (slider_position_to_gain_with_max (fraction, Config->get_max_gain())));
} }
} else { } else {
view_to_model_coord_y (fraction); view_to_model_coord_y (fraction);
@ -551,7 +551,7 @@ AutomationLine::string_to_fraction (string const & s) const
sscanf (s.c_str(), "%lf", &v); sscanf (s.c_str(), "%lf", &v);
if (_uses_gain_mapping) { if (_uses_gain_mapping) {
v = gain_to_slider_position (dB_to_coefficient (v)); v = gain_to_slider_position_with_max (dB_to_coefficient (v), Config->get_max_gain());
} else { } else {
double dummy = 0.0; double dummy = 0.0;
model_to_view_coord (dummy, v); model_to_view_coord (dummy, v);
@ -1198,7 +1198,7 @@ AutomationLine::view_to_model_coord_y (double& y) const
/* TODO: This should be more generic ... */ /* TODO: This should be more generic ... */
if (alist->parameter().type() == GainAutomation || if (alist->parameter().type() == GainAutomation ||
alist->parameter().type() == EnvelopeAutomation) { alist->parameter().type() == EnvelopeAutomation) {
y = slider_position_to_gain (y); y = slider_position_to_gain_with_max (y, Config->get_max_gain());
y = max (0.0, y); y = max (0.0, y);
y = min (2.0, y); y = min (2.0, y);
} else if (alist->parameter().type() == PanAzimuthAutomation || } else if (alist->parameter().type() == PanAzimuthAutomation ||
@ -1218,7 +1218,7 @@ AutomationLine::model_to_view_coord (double& x, double& y) const
/* TODO: This should be more generic ... */ /* TODO: This should be more generic ... */
if (alist->parameter().type() == GainAutomation || if (alist->parameter().type() == GainAutomation ||
alist->parameter().type() == EnvelopeAutomation) { alist->parameter().type() == EnvelopeAutomation) {
y = gain_to_slider_position (y); y = gain_to_slider_position_with_max (y, Config->get_max_gain());
} else if (alist->parameter().type() == PanAzimuthAutomation || } else if (alist->parameter().type() == PanAzimuthAutomation ||
alist->parameter().type() == PanElevationAutomation || alist->parameter().type() == PanElevationAutomation ||
alist->parameter().type() == PanWidthAutomation) { alist->parameter().type() == PanWidthAutomation) {

View file

@ -66,14 +66,13 @@ using namespace ArdourCanvas;
using Gtkmm2ext::Keyboard; using Gtkmm2ext::Keyboard;
double const ControlPointDrag::_zero_gain_fraction = gain_to_slider_position (dB_to_coefficient (0.0)); double ControlPointDrag::_zero_gain_fraction = -1.0;
DragManager::DragManager (Editor* e) DragManager::DragManager (Editor* e)
: _editor (e) : _editor (e)
, _ending (false) , _ending (false)
, _current_pointer_frame (0) , _current_pointer_frame (0)
{ {
} }
DragManager::~DragManager () DragManager::~DragManager ()
@ -2752,6 +2751,10 @@ ControlPointDrag::ControlPointDrag (Editor* e, ArdourCanvas::Item* i)
_cumulative_x_drag (0), _cumulative_x_drag (0),
_cumulative_y_drag (0) _cumulative_y_drag (0)
{ {
if (_zero_gain_fraction < 0.0) {
_zero_gain_fraction = gain_to_slider_position_with_max (dB_to_coefficient (0.0), Config->get_max_gain());
}
DEBUG_TRACE (DEBUG::Drags, "New ControlPointDrag\n"); DEBUG_TRACE (DEBUG::Drags, "New ControlPointDrag\n");
_point = reinterpret_cast<ControlPoint*> (_item->get_data ("control_point")); _point = reinterpret_cast<ControlPoint*> (_item->get_data ("control_point"));

View file

@ -690,7 +690,7 @@ private:
double _fixed_grab_y; double _fixed_grab_y;
double _cumulative_x_drag; double _cumulative_x_drag;
double _cumulative_y_drag; double _cumulative_y_drag;
static double const _zero_gain_fraction; static double _zero_gain_fraction;
}; };
/** Gain or automation line drag */ /** Gain or automation line drag */

View file

@ -79,7 +79,7 @@ GainMeterBase::GainMeterBase (Session* s,
const Glib::RefPtr<Gdk::Pixbuf>& pix, const Glib::RefPtr<Gdk::Pixbuf>& pix,
bool horizontal, bool horizontal,
int fader_length) int fader_length)
: gain_adjustment (0.781787, 0.0, 1.0, 0.01, 0.1) // 0.781787 is the value needed for gain to be set to 0. : gain_adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0.0, 1.0, 0.01, 0.1)
, gain_automation_style_button ("") , gain_automation_style_button ("")
, gain_automation_state_button ("") , gain_automation_state_button ("")
, style_changed (false) , style_changed (false)
@ -382,7 +382,7 @@ GainMeterBase::show_gain ()
if (v == 0.0) { if (v == 0.0) {
strcpy (buf, _("-inf")); strcpy (buf, _("-inf"));
} else { } else {
snprintf (buf, sizeof (buf), "%.1f", accurate_coefficient_to_dB (slider_position_to_gain (v))); snprintf (buf, sizeof (buf), "%.1f", accurate_coefficient_to_dB (slider_position_to_gain_with_max (v, Config->get_max_gain())));
} }
} else { } else {
snprintf (buf, sizeof (buf), "%.1f", v); snprintf (buf, sizeof (buf), "%.1f", v);
@ -395,14 +395,13 @@ void
GainMeterBase::gain_adjusted () GainMeterBase::gain_adjusted ()
{ {
if (!ignore_toggle) { if (!ignore_toggle) {
if (_route && _route->amp() == _amp) {
if (_is_midi) { if (_is_midi) {
_route->set_gain (gain_adjustment.get_value(), this); _amp->set_gain (gain_adjustment.get_value(), this);
} else { } else {
_route->set_gain (slider_position_to_gain (gain_adjustment.get_value()), this); cerr << "reset gain using slider pos " << gain_adjustment.get_value() << " to "
} << slider_position_to_gain_with_max (gain_adjustment.get_value(), Config->get_max_gain())
} else { << endl;
_amp->set_gain (slider_position_to_gain (gain_adjustment.get_value()), this); _amp->set_gain (slider_position_to_gain_with_max (gain_adjustment.get_value(), Config->get_max_gain()), this);
} }
} }
@ -415,15 +414,11 @@ GainMeterBase::effective_gain_display ()
gfloat value; gfloat value;
if (!_route || _route->output()->n_ports().n_midi() == 0) { if (!_route || _route->output()->n_ports().n_midi() == 0) {
value = gain_to_slider_position (_amp->gain()); value = gain_to_slider_position_with_max (_amp->gain(), Config->get_max_gain());
} else { } else {
value = _amp->gain (); value = _amp->gain ();
} }
//cerr << this << " for " << _io->name() << " EGAIN = " << value
// << " AGAIN = " << gain_adjustment.get_value () << endl;
// stacktrace (cerr, 20);
if (gain_adjustment.get_value() != value) { if (gain_adjustment.get_value() != value) {
ignore_toggle = true; ignore_toggle = true;
gain_adjustment.set_value (value); gain_adjustment.set_value (value);

View file

@ -70,12 +70,12 @@ MonitorSection::MonitorSection (Session* s)
/* Dim */ /* Dim */
dim_control = new VolumeController (little_knob_pixbuf, boost::shared_ptr<Controllable>(), 0.0, 0.01, 0.1, true, 30, 30, true, true); dim_control = new VolumeController (little_knob_pixbuf, boost::shared_ptr<Controllable>(), 0.0, 0.1, 1.0, true, 30, 30, true);
HBox* dim_packer = manage (new HBox); HBox* dim_packer = manage (new HBox);
dim_packer->show (); dim_packer->show ();
spin_label = manage (new Label (_("Dim Cut"))); spin_label = manage (new Label (_("Dim")));
spin_packer = manage (new VBox); spin_packer = manage (new VBox);
spin_packer->show (); spin_packer->show ();
spin_packer->set_spacing (6); spin_packer->set_spacing (6);
@ -134,7 +134,7 @@ MonitorSection::MonitorSection (Session* s)
/* Solo Boost */ /* Solo Boost */
solo_boost_control = new VolumeController (little_knob_pixbuf, boost::shared_ptr<Controllable>(), 0.0, 0.01, 0.1, true, 30, 30, true, true); solo_boost_control = new VolumeController (little_knob_pixbuf, boost::shared_ptr<Controllable>(), 0.0, 0.1, 1.0, true, 30, 30, true);
HBox* solo_packer = manage (new HBox); HBox* solo_packer = manage (new HBox);
solo_packer->set_spacing (12); solo_packer->set_spacing (12);
@ -151,7 +151,7 @@ MonitorSection::MonitorSection (Session* s)
/* Solo (SiP) cut */ /* Solo (SiP) cut */
solo_cut_control = new VolumeController (little_knob_pixbuf, boost::shared_ptr<Controllable>(), 0.0, 0.01, 0.1, true, 30, 30, false, false); solo_cut_control = new VolumeController (little_knob_pixbuf, boost::shared_ptr<Controllable>(), 0.0, 0.1, 1.0, true, 30, 30, true);
spin_label = manage (new Label (_("SiP Cut"))); spin_label = manage (new Label (_("SiP Cut")));
spin_packer = manage (new VBox); spin_packer = manage (new VBox);
@ -234,9 +234,9 @@ MonitorSection::MonitorSection (Session* s)
/* Gain */ /* Gain */
gain_control = new VolumeController (big_knob_pixbuf, boost::shared_ptr<Controllable>(), 0.781787, 0.01, 0.1, true, 80, 80, false, false); gain_control = new VolumeController (big_knob_pixbuf, boost::shared_ptr<Controllable>(), 1.0, 0.1, 1.0, true, 80, 80, false);
spin_label = manage (new Label (_("Gain"))); spin_label = manage (new Label (_("Monitor")));
spin_packer = manage (new VBox); spin_packer = manage (new VBox);
spin_packer->show (); spin_packer->show ();
spin_packer->set_spacing (6); spin_packer->set_spacing (6);

View file

@ -20,9 +20,12 @@
#include <gtkmm/box.h> #include <gtkmm/box.h>
#include <gtkmm/alignment.h> #include <gtkmm/alignment.h>
#include "gtkmm2ext/utils.h" #include "gtkmm2ext/utils.h"
#include "ardour/configuration.h" #include "ardour/configuration.h"
#include "ardour/rc_configuration.h"
#include "ardour/utils.h" #include "ardour/utils.h"
#include "ardour/dB.h" #include "ardour/dB.h"
#include "option_editor.h" #include "option_editor.h"
#include "gui_thread.h" #include "gui_thread.h"
#include "utils.h" #include "utils.h"
@ -134,8 +137,7 @@ EntryOption::activated ()
FaderOption::FaderOption (string const & i, string const & n, sigc::slot<gain_t> g, sigc::slot<bool, gain_t> s) FaderOption::FaderOption (string const & i, string const & n, sigc::slot<gain_t> g, sigc::slot<bool, gain_t> s)
: Option (i, n) : Option (i, n)
// 0.781787 is the value needed for gain to be set to 0. , _db_adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0, 1, 0.01, 0.1)
, _db_adjustment (0.781787, 0, 1, 0.01, 0.1)
, _get (g) , _get (g)
, _set (s) , _set (s)
{ {
@ -166,7 +168,7 @@ void
FaderOption::set_state_from_config () FaderOption::set_state_from_config ()
{ {
gain_t const val = _get (); gain_t const val = _get ();
_db_adjustment.set_value (gain_to_slider_position (val)); _db_adjustment.set_value (gain_to_slider_position_with_max (val, Config->get_max_gain ()));
char buf[16]; char buf[16];
@ -182,7 +184,7 @@ FaderOption::set_state_from_config ()
void void
FaderOption::db_changed () FaderOption::db_changed ()
{ {
_set (slider_position_to_gain (_db_adjustment.get_value ())); _set (slider_position_to_gain_with_max (_db_adjustment.get_value (), Config->get_max_gain()));
} }
void void

View file

@ -300,8 +300,7 @@ ProcessorEntry::name () const
SendProcessorEntry::SendProcessorEntry (boost::shared_ptr<Send> s, Width w) SendProcessorEntry::SendProcessorEntry (boost::shared_ptr<Send> s, Width w)
: ProcessorEntry (s, w), : ProcessorEntry (s, w),
_send (s), _send (s),
/* set the adjustment to a gain of 0dB so that the fader's default value is right */ _adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0, 1, 0.01, 0.1),
_adjustment (0.781787, 0, 1, 0.01, 0.1),
_fader (_slider, &_adjustment, 0, false), _fader (_slider, &_adjustment, 0, false),
_ignore_gain_change (false) _ignore_gain_change (false)
{ {
@ -326,9 +325,7 @@ SendProcessorEntry::setup_slider_pix ()
void void
SendProcessorEntry::show_gain () SendProcessorEntry::show_gain ()
{ {
ENSURE_GUI_THREAD (*this, &SendProcessorEntry::show_gain) float const value = gain_to_slider_position_with_max (_send->amp()->gain (), Config->get_max_gain());
float const value = gain_to_slider_position (_send->amp()->gain ());
if (_adjustment.get_value() != value) { if (_adjustment.get_value() != value) {
_ignore_gain_change = true; _ignore_gain_change = true;
@ -350,7 +347,7 @@ SendProcessorEntry::gain_adjusted ()
return; return;
} }
_send->amp()->set_gain (slider_position_to_gain (_adjustment.get_value()), this); _send->amp()->set_gain (slider_position_to_gain_with_max (_adjustment.get_value(), Config->get_max_gain()), this);
} }
void void

View file

@ -28,6 +28,7 @@
#include "gtkmm2ext/gui_thread.h" #include "gtkmm2ext/gui_thread.h"
#include "ardour/dB.h" #include "ardour/dB.h"
#include "ardour/rc_configuration.h"
#include "ardour/utils.h" #include "ardour/utils.h"
#include "volume_controller.h" #include "volume_controller.h"
@ -42,12 +43,10 @@ VolumeController::VolumeController (Glib::RefPtr<Gdk::Pixbuf> p,
bool with_numeric, bool with_numeric,
int subw, int subw,
int subh, int subh,
bool linear, bool linear)
bool dB)
: MotionFeedback (p, MotionFeedback::Rotary, c, def, step, page, "", with_numeric, subw, subh) : MotionFeedback (p, MotionFeedback::Rotary, c, def, step, page, "", with_numeric, subw, subh)
, _linear (linear) , _linear (linear)
, _controllable_uses_dB (dB)
{ {
set_print_func (VolumeController::_dB_printer, this); set_print_func (VolumeController::_dB_printer, this);
@ -72,27 +71,39 @@ VolumeController::dB_printer (char buf[32], const boost::shared_ptr<PBD::Control
if (c) { if (c) {
if (_linear) { if (_linear) {
/* controllable units are in dB so just show the value */
if (step_inc < 1.0) {
snprintf (buf, 32, "%.2f dB", c->get_value());
} else {
snprintf (buf, 32, "%ld dB", lrint (c->get_value()));
}
} else {
double gain_coefficient; double val = accurate_coefficient_to_dB (c->get_value());
if (!_controllable_uses_dB) {
gain_coefficient = c->get_value();
} else {
double fract = (c->get_value() - c->lower()) / (c->upper() - c->lower());
gain_coefficient = slider_position_to_gain (fract);
}
if (step_inc < 1.0) { if (step_inc < 1.0) {
snprintf (buf, 32, "%.2f dB", accurate_coefficient_to_dB (gain_coefficient)); if (val >= 0.0) {
snprintf (buf, 32, "+%5.2f dB", val);
} else { } else {
snprintf (buf, 32, "%ld dB", lrint (accurate_coefficient_to_dB (gain_coefficient))); snprintf (buf, 32, "%5.2f dB", val);
}
} else {
if (val >= 0.0) {
snprintf (buf, 32, "+%2ld dB", lrint (val));
} else {
snprintf (buf, 32, "%2ld dB", lrint (val));
}
}
} else {
double dB = accurate_coefficient_to_dB (c->get_value());
if (step_inc < 1.0) {
if (dB >= 0.0) {
snprintf (buf, 32, "+%5.2f dB", dB);
} else {
snprintf (buf, 32, "%5.2f dB", dB);
}
} else {
if (dB >= 0.0) {
snprintf (buf, 32, "+%2ld dB", lrint (dB));
} else {
snprintf (buf, 32, "%2ld dB", lrint (dB));
}
} }
} }
} else { } else {
@ -111,8 +122,7 @@ VolumeController::to_control_value (double display_value)
if (_linear) { if (_linear) {
v = _controllable->lower() + ((_controllable->upper() - _controllable->lower()) * display_value); v = _controllable->lower() + ((_controllable->upper() - _controllable->lower()) * display_value);
} else { } else {
v = slider_position_to_gain_with_max (display_value, ARDOUR::Config->get_max_gain());
v = slider_position_to_gain (display_value);
} }
return v; return v;
@ -123,11 +133,18 @@ VolumeController::to_display_value (double control_value)
{ {
double v; double v;
if (_linear) { // if (_linear) {
v = (control_value - _controllable->lower ()) / (_controllable->upper() - _controllable->lower()); v = (control_value - _controllable->lower ()) / (_controllable->upper() - _controllable->lower());
} else { // } else {
v = gain_to_slider_position (control_value); // v = gain_to_slider_position_with_max (control_value, ARDOUR::Config->get_max_gain());
} // }
return v; return v;
} }
double
VolumeController::adjust (double control_delta)
{
return std::max (_controllable->lower(), std::min (_controllable->upper(), _controllable->get_value() + control_delta));
}

View file

@ -35,8 +35,7 @@ class VolumeController : public Gtkmm2ext::MotionFeedback
bool with_numeric = true, bool with_numeric = true,
int image_width = 40, int image_width = 40,
int image_height = 40, int image_height = 40,
bool linear = true, bool linear = true);
bool dB = false);
virtual ~VolumeController () {} virtual ~VolumeController () {}
@ -45,10 +44,13 @@ class VolumeController : public Gtkmm2ext::MotionFeedback
protected: protected:
double to_control_value (double); double to_control_value (double);
double to_display_value (double); double to_display_value (double);
double adjust (double nominal_delta);
double display_value () const;
double control_value () const;
private: private:
bool _linear; bool _linear;
bool _controllable_uses_dB;
void dB_printer (char buf[32], const boost::shared_ptr<PBD::Controllable>& adj); void dB_printer (char buf[32], const boost::shared_ptr<PBD::Controllable>& adj);
}; };

View file

@ -412,8 +412,8 @@ void
Amp::GainControl::set_value (double val) Amp::GainControl::set_value (double val)
{ {
// max gain at about +6dB (10.0 ^ ( 6 dB * 0.05)) // max gain at about +6dB (10.0 ^ ( 6 dB * 0.05))
if (val > 1.99526231f) { if (val > 1.99526231) {
val = 1.99526231f; val = 1.99526231;
} }
_amp->set_gain (val, this); _amp->set_gain (val, this);

View file

@ -34,6 +34,6 @@ static inline float accurate_coefficient_to_dB (float coeff) {
return 20.0f * log10 (coeff); return 20.0f * log10 (coeff);
} }
static const double zero_db_as_fraction = 0.781787; extern double zero_db_as_fraction;
#endif /* __ardour_dB_h__ */ #endif /* __ardour_dB_h__ */

View file

@ -164,6 +164,7 @@ CONFIG_VARIABLE (WaveformShape, waveform_shape, "waveform-shape", Traditional)
CONFIG_VARIABLE (bool, allow_special_bus_removal, "allow-special-bus-removal", false) CONFIG_VARIABLE (bool, allow_special_bus_removal, "allow-special-bus-removal", false)
CONFIG_VARIABLE (int32_t, processor_usage, "processor-usage", -1) CONFIG_VARIABLE (int32_t, processor_usage, "processor-usage", -1)
CONFIG_VARIABLE (bool, color_regions_using_track_color, "color-regions-using-track-color", false) CONFIG_VARIABLE (bool, color_regions_using_track_color, "color-regions-using-track-color", false)
CONFIG_VARIABLE (gain_t, max_gain, "max-gain", 2.0) /* +6.0dB */
/* denormal management */ /* denormal management */

View file

@ -36,6 +36,7 @@ bool string_is_affirmative (const std::string&);
#include "ardour/ardour.h" #include "ardour/ardour.h"
#include "ardour/data_type.h" #include "ardour/data_type.h"
#include "ardour/dB.h"
class XMLNode; class XMLNode;
@ -70,22 +71,78 @@ ARDOUR::SyncSource string_to_sync_source (std::string str);
const char* edit_mode_to_string (ARDOUR::EditMode); const char* edit_mode_to_string (ARDOUR::EditMode);
ARDOUR::EditMode string_to_edit_mode (std::string); ARDOUR::EditMode string_to_edit_mode (std::string);
#undef OLD_GAIN_MATH
#define OLD_GAIN_MATH
static inline double static inline double
gain_to_slider_position (ARDOUR::gain_t g) gain_to_slider_position (ARDOUR::gain_t g)
{ {
if (g == 0) return 0; if (g == 0) return 0;
return pow((6.0*log(g)/log(2.0)+192.0)/198.0, 8.0);
#ifndef OLD_GAIN_MATH
/* Power Law With Exponential Cutoff 2D, fit to data from TC Spectra
console (image of fader gradations
y = C * x(-T) * exp(-x/K)
C = 8.2857630370864188E-01
T = -5.1526743785019269E-01
K = 7.8990885960495589E+00
*/
return 8.2857630370864188E-01 * pow(g,5.1526743785019269E-01) * exp (-g/7.8990885960495589E+00);
#else
return pow((6.0*log(g)/log(2.0)+192.0)/198.0, 8.0);
#endif
} }
static inline ARDOUR::gain_t static inline ARDOUR::gain_t
slider_position_to_gain (double pos) slider_position_to_gain (double pos)
{ {
if (pos == 0.0) {
return 0.0;
}
#ifndef OLD_GAIN_MATH
/* 5th order polynomial function fit to data from a TC Spectra console
fader (image of fader gradations).
y = a + bx1 + cx2 + dx3 + fx4 + gx5
a = -1.1945480381045521E-02
b = 1.5809476525537265E+00
c = -1.5850710838966151E+01
d = 6.1643128605961991E+01
f = -8.5525246160607693E+01
g = 4.1312725896188283E+01
*/
double p = pos;
double g = -1.1945480381045521E-02;
g += 1.5809476525537265E+00 * pos;
pos *= p;
g += -1.5850710838966151E+01 * pos;
pos *= p;
g += 6.1643128605961991E+01 * pos;
pos *= p;
g += -8.5525246160607693E+01 * pos;
pos *= p;
g += 4.1312725896188283E+01 * pos;
return g;
#else
/* XXX Marcus writes: this doesn't seem right to me. but i don't have a better answer ... */ /* XXX Marcus writes: this doesn't seem right to me. but i don't have a better answer ... */
if (pos == 0.0) return 0; if (pos == 0.0) return 0;
return pow (2.0,(sqrt(sqrt(sqrt(pos)))*198.0-192.0)/6.0); return pow (2.0,(sqrt(sqrt(sqrt(pos)))*198.0-192.0)/6.0);
#endif
} }
#undef OLD_GAIN_MATH
double gain_to_slider_position_with_max (double g, double max_gain = 2.0);
double slider_position_to_gain_with_max (double g, double max_gain = 2.0);
/* I don't really like hard-coding these falloff rates here /* I don't really like hard-coding these falloff rates here
* Probably should use a map of some kind that could be configured * Probably should use a map of some kind that could be configured

View file

@ -65,6 +65,7 @@
#include "ardour/audiosource.h" #include "ardour/audiosource.h"
#include "ardour/buffer_manager.h" #include "ardour/buffer_manager.h"
#include "ardour/control_protocol_manager.h" #include "ardour/control_protocol_manager.h"
#include "ardour/dB.h"
#include "ardour/debug.h" #include "ardour/debug.h"
#include "ardour/filesystem_paths.h" #include "ardour/filesystem_paths.h"
#include "ardour/midi_region.h" #include "ardour/midi_region.h"

View file

@ -1,9 +1,9 @@
#include "pbd/convert.h" #include "pbd/convert.h"
#include "pbd/error.h" #include "pbd/error.h"
#include "pbd/locale_guard.h"
#include "pbd/xml++.h" #include "pbd/xml++.h"
#include "ardour/amp.h" #include "ardour/amp.h"
#include "ardour/dB.h"
#include "ardour/debug.h" #include "ardour/debug.h"
#include "ardour/audio_buffer.h" #include "ardour/audio_buffer.h"
#include "ardour/monitor_processor.h" #include "ardour/monitor_processor.h"
@ -34,10 +34,12 @@ MonitorProcessor::MonitorProcessor (Session& s)
, _dim_all_ptr (new MPControl<bool> (false, _("monitor dim"), Controllable::Toggle)) , _dim_all_ptr (new MPControl<bool> (false, _("monitor dim"), Controllable::Toggle))
, _cut_all_ptr (new MPControl<bool> (false, _("monitor cut"), Controllable::Toggle)) , _cut_all_ptr (new MPControl<bool> (false, _("monitor cut"), Controllable::Toggle))
, _mono_ptr (new MPControl<bool> (false, _("monitor mono"), Controllable::Toggle)) , _mono_ptr (new MPControl<bool> (false, _("monitor mono"), Controllable::Toggle))
, _dim_level_ptr (new MPControl<volatile gain_t> /* units in dB */ , _dim_level_ptr (new MPControl<volatile gain_t>
(-12.0, _("monitor dim level"), Controllable::Flag (0), -20.0f, 0.0f)) /* default is -12dB, range is -20dB to 0dB */
, _solo_boost_level_ptr (new MPControl<volatile gain_t> /* units in dB */ (0.251188635826, _("monitor dim level"), Controllable::Flag (0), 0.100000001490, 1.0))
(0.0, _("monitor solo boost level"), Controllable::Flag (0), 0.0, 20.0)) , _solo_boost_level_ptr (new MPControl<volatile gain_t>
/* default is 0dB, range is 0dB to +20dB */
(1.0, _("monitor solo boost level"), Controllable::Flag (0), 1.0, 10.0))
, _dim_all_control (_dim_all_ptr) , _dim_all_control (_dim_all_ptr)
, _cut_all_control (_cut_all_ptr) , _cut_all_control (_cut_all_ptr)
@ -202,6 +204,7 @@ MonitorProcessor::set_state (const XMLNode& node, int version)
XMLNode& XMLNode&
MonitorProcessor::state (bool full) MonitorProcessor::state (bool full)
{ {
LocaleGuard lg (X_("POSIX"));
XMLNode& node (Processor::state (full)); XMLNode& node (Processor::state (full));
char buf[64]; char buf[64];
@ -251,12 +254,11 @@ MonitorProcessor::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /
gain_t target_gain; gain_t target_gain;
gain_t dim_level_this_time = _dim_level; gain_t dim_level_this_time = _dim_level;
gain_t global_cut = (_cut_all ? 0.0f : 1.0f); gain_t global_cut = (_cut_all ? 0.0f : 1.0f);
gain_t global_dim = (_dim_all ? dim_level_this_time : 1.0f); gain_t global_dim = (_dim_all ? dim_level_this_time : 1.0);
gain_t solo_boost; gain_t solo_boost;
if (_session.listening() || _session.soloing()) { if (_session.listening() || _session.soloing()) {
/* solo boost controller is in dB */ solo_boost = _solo_boost_level;
solo_boost = dB_to_coefficient (_solo_boost_level);
} else { } else {
solo_boost = 1.0; solo_boost = 1.0;
} }
@ -267,10 +269,6 @@ MonitorProcessor::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /
gain_t dim_level = (global_dim == 1.0 ? (_channels[chn]->dim ? dim_level_this_time : 1.0) : 1.0); gain_t dim_level = (global_dim == 1.0 ? (_channels[chn]->dim ? dim_level_this_time : 1.0) : 1.0);
/* dim level is in dB */
dim_level = dB_to_coefficient (dim_level);
if (_channels[chn]->soloed) { if (_channels[chn]->soloed) {
target_gain = _channels[chn]->polarity * _channels[chn]->cut * dim_level * global_cut * global_dim * solo_boost; target_gain = _channels[chn]->polarity * _channels[chn]->cut * dim_level * global_cut * global_dim * solo_boost;
} else { } else {

View file

@ -1249,7 +1249,6 @@ int
Region::_set_state (const XMLNode& node, int /*version*/, PropertyChange& what_changed, bool send) Region::_set_state (const XMLNode& node, int /*version*/, PropertyChange& what_changed, bool send)
{ {
const XMLProperty* prop; const XMLProperty* prop;
const XMLNodeList& nlist = node.children();
Stateful::save_extra_xml (node); Stateful::save_extra_xml (node);

View file

@ -672,6 +672,18 @@ how_many_dsp_threads ()
return num_threads; return num_threads;
} }
double gain_to_slider_position_with_max (double g, double max_gain)
{
/* max gain is ignored for now */
return gain_to_slider_position (g);
}
double slider_position_to_gain_with_max (double g, double max_gain)
{
/* max gain is ignored for now */
return slider_position_to_gain (g);
}
extern "C" { extern "C" {
void c_stacktrace() { stacktrace (cerr); } void c_stacktrace() { stacktrace (cerr); }
} }

View file

@ -24,6 +24,7 @@
#include <gdkmm/pixbuf.h> #include <gdkmm/pixbuf.h>
#include <gtkmm/box.h> #include <gtkmm/box.h>
#include <gtkmm/label.h>
#include <gtkmm/eventbox.h> #include <gtkmm/eventbox.h>
#include "gtkmm2ext/binding_proxy.h" #include "gtkmm2ext/binding_proxy.h"
@ -58,7 +59,6 @@ class MotionFeedback : public Gtk::VBox
virtual ~MotionFeedback (); virtual ~MotionFeedback ();
Gtk::Widget& eventwin () { return pixwin; } Gtk::Widget& eventwin () { return pixwin; }
Gtk::Entry& value_display() const { return *value; }
boost::shared_ptr<PBD::Controllable> controllable() const; boost::shared_ptr<PBD::Controllable> controllable() const;
virtual void set_controllable (boost::shared_ptr<PBD::Controllable> c); virtual void set_controllable (boost::shared_ptr<PBD::Controllable> c);
@ -75,7 +75,7 @@ class MotionFeedback : public Gtk::VBox
protected: protected:
boost::shared_ptr<PBD::Controllable> _controllable; boost::shared_ptr<PBD::Controllable> _controllable;
Gtk::Entry* value; Gtk::Label* value;
double default_value; double default_value;
double step_inc; double step_inc;
double page_inc; double page_inc;
@ -103,12 +103,12 @@ class MotionFeedback : public Gtk::VBox
*/ */
virtual double to_display_value (double) = 0; virtual double to_display_value (double) = 0;
double adjust (double control_value, double display_delta); virtual double adjust (double nominal_delta) = 0;
private: private:
Type type; Type type;
Gtk::EventBox pixwin; Gtk::EventBox pixwin;
Gtk::HBox* value_packer; Gtk::EventBox* value_packer;
Glib::RefPtr<Gdk::Pixbuf> pixbuf; Glib::RefPtr<Gdk::Pixbuf> pixbuf;
BindingProxy binding_proxy; BindingProxy binding_proxy;

View file

@ -74,10 +74,16 @@ MotionFeedback::MotionFeedback (Glib::RefPtr<Gdk::Pixbuf> pix,
if (with_numeric_display) { if (with_numeric_display) {
value_packer = new HBox; value_packer = new EventBox;
value = new Entry; value_packer->set_name ("MotionControllerValue");
value->set_editable (false); value_packer->show ();
value_packer->pack_start (*value, false, false); value_packer->set_border_width (6);
value = new Label;
value->set_justify (Gtk::JUSTIFY_RIGHT);
value->show ();
value_packer->add (*value);
hpacker = manage (new HBox); hpacker = manage (new HBox);
hpacker->pack_start (*value_packer, true, false); hpacker->pack_start (*value_packer, true, false);
@ -95,8 +101,6 @@ MotionFeedback::MotionFeedback (Glib::RefPtr<Gdk::Pixbuf> pix,
print_func (buf, _controllable, print_arg); print_func (buf, _controllable, print_arg);
value->set_text (buf); value->set_text (buf);
} }
value->show ();
} }
pixwin.set_events (Gdk::BUTTON_PRESS_MASK| pixwin.set_events (Gdk::BUTTON_PRESS_MASK|
@ -137,24 +141,22 @@ MotionFeedback::pixwin_button_press_event (GdkEventButton *ev)
} }
switch (ev->button) { switch (ev->button) {
case 2:
return FALSE; /* XXX why ? */
case 1: case 1:
grab_is_fine = false; grab_is_fine = false;
break; break;
case 3: case 2:
grab_is_fine = true; grab_is_fine = true;
break; break;
case 3:
return false;
} }
gtk_grab_add(GTK_WIDGET(pixwin.gobj())); gtk_grab_add(GTK_WIDGET(pixwin.gobj()));
grabbed_y = ev->y_root; grabbed_y = ev->y_root;
grabbed_x = ev->x_root; grabbed_x = ev->x_root;
/* XXX should we return TRUE ? */ return false;
return FALSE;
} }
bool bool
@ -213,6 +215,8 @@ MotionFeedback::pixwin_motion_notify_event (GdkEventMotion *ev)
if (ev->state & Gdk::BUTTON1_MASK) { if (ev->state & Gdk::BUTTON1_MASK) {
/* vertical control */
y_delta = grabbed_y - ev->y_root; y_delta = grabbed_y - ev->y_root;
grabbed_y = ev->y_root; grabbed_y = ev->y_root;
@ -224,10 +228,11 @@ MotionFeedback::pixwin_motion_notify_event (GdkEventMotion *ev)
y_delta *= multiplier; y_delta *= multiplier;
y_delta /= 10; y_delta /= 10;
_controllable->set_value (adjust (_controllable->get_value(), _controllable->set_value (adjust ((grab_is_fine ? step_inc : page_inc) * y_delta));
((grab_is_fine ? step_inc : page_inc) * y_delta)));
} else if (ev->state & Gdk::BUTTON3_MASK) { } else if (ev->state & Gdk::BUTTON2_MASK) {
/* rotary control */
double x = ev->x - subwidth/2; double x = ev->x - subwidth/2;
double y = - ev->y + subwidth/2; double y = - ev->y + subwidth/2;
@ -261,12 +266,6 @@ MotionFeedback::pixwin_leave_notify_event (GdkEventCrossing *ev)
return false; return false;
} }
double
MotionFeedback::adjust (double control_value, double display_delta)
{
return to_control_value (to_display_value (control_value) + display_delta);
}
bool bool
MotionFeedback::pixwin_key_press_event (GdkEventKey *ev) MotionFeedback::pixwin_key_press_event (GdkEventKey *ev)
{ {
@ -275,32 +274,31 @@ MotionFeedback::pixwin_key_press_event (GdkEventKey *ev)
} }
bool retval = false; bool retval = false;
double curval = _controllable->get_value ();
double multiplier; double multiplier;
multiplier = ((ev->state & Keyboard::TertiaryModifier) ? 100 : 1) * multiplier = ((ev->state & Keyboard::TertiaryModifier) ? 100.0 : 1.0) *
((ev->state & Keyboard::SecondaryModifier) ? 10 : 1) * ((ev->state & Keyboard::SecondaryModifier) ? 10.0 : 1.0) *
((ev->state & Keyboard::PrimaryModifier) ? 2 : 1); ((ev->state & Keyboard::PrimaryModifier) ? 2.0 : 1.0);
switch (ev->keyval) { switch (ev->keyval) {
case GDK_Page_Up: case GDK_Page_Up:
retval = true; retval = true;
_controllable->set_value (adjust (curval, multiplier * page_inc)); _controllable->set_value (adjust (multiplier * page_inc));
break; break;
case GDK_Page_Down: case GDK_Page_Down:
retval = true; retval = true;
_controllable->set_value (adjust (curval, multiplier * page_inc)); _controllable->set_value (adjust (multiplier * page_inc));
break; break;
case GDK_Up: case GDK_Up:
retval = true; retval = true;
_controllable->set_value (adjust (curval, multiplier * step_inc)); _controllable->set_value (adjust (multiplier * step_inc));
break; break;
case GDK_Down: case GDK_Down:
retval = true; retval = true;
_controllable->set_value (adjust (curval, multiplier * step_inc)); _controllable->set_value (adjust (multiplier * step_inc));
break; break;
case GDK_Home: case GDK_Home:
@ -388,12 +386,12 @@ MotionFeedback::pixwin_scroll_event (GdkEventScroll* ev)
switch (ev->direction) { switch (ev->direction) {
case GDK_SCROLL_UP: case GDK_SCROLL_UP:
case GDK_SCROLL_RIGHT: case GDK_SCROLL_RIGHT:
_controllable->set_value (adjust (_controllable->get_value(), (scale * step_inc))); _controllable->set_value (adjust (scale * step_inc));
break; break;
case GDK_SCROLL_DOWN: case GDK_SCROLL_DOWN:
case GDK_SCROLL_LEFT: case GDK_SCROLL_LEFT:
_controllable->set_value (adjust (_controllable->get_value(), -(scale * step_inc))); _controllable->set_value (adjust (-scale * step_inc));
break; break;
} }

View file

@ -342,6 +342,12 @@ PixFader::on_motion_notify_event (GdkEventMotion* ev)
fract = -fract; fract = -fract;
} }
std::cerr << "Motion tries to set adjustment to "
<< adjustment.get_value() + scale * fract * (adjustment.get_upper() - adjustment.get_lower())
<< " val = " << adjustment.get_value() << " upper = " << adjustment.get_upper() << " lower = " << adjustment.get_lower()
<< " fract = " << fract
<< std::endl;
adjustment.set_value (adjustment.get_value() + scale * fract * (adjustment.get_upper() - adjustment.get_lower())); adjustment.set_value (adjustment.get_value() + scale * fract * (adjustment.get_upper() - adjustment.get_lower()));
} }