summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2011-06-19 23:02:55 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2011-06-19 23:02:55 +0000
commitd5e09076ca69fda1402a12e383de7a7d9bc5f0ec (patch)
tree0d4df7147098ea57e58d96efb82f57dd5545023c
parent182b23e744d79b3387a779ea25010924daffe6af (diff)
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
-rw-r--r--gtk2_ardour/ardour3_styles.rc.in6
-rw-r--r--gtk2_ardour/ardour3_widget_list.rc3
-rw-r--r--gtk2_ardour/automation_line.cc8
-rw-r--r--gtk2_ardour/editor_drag.cc7
-rw-r--r--gtk2_ardour/editor_drag.h2
-rw-r--r--gtk2_ardour/gain_meter.cc23
-rw-r--r--gtk2_ardour/monitor_section.cc14
-rw-r--r--gtk2_ardour/option_editor.cc10
-rw-r--r--gtk2_ardour/processor_box.cc9
-rw-r--r--gtk2_ardour/volume_controller.cc61
-rw-r--r--gtk2_ardour/volume_controller.h8
-rw-r--r--libs/ardour/amp.cc4
-rw-r--r--libs/ardour/ardour/dB.h2
-rw-r--r--libs/ardour/ardour/rc_configuration_vars.h1
-rw-r--r--libs/ardour/ardour/utils.h59
-rw-r--r--libs/ardour/globals.cc1
-rw-r--r--libs/ardour/monitor_processor.cc24
-rw-r--r--libs/ardour/region.cc1
-rw-r--r--libs/ardour/session.cc2
-rw-r--r--libs/ardour/utils.cc12
-rw-r--r--libs/gtkmm2ext/gtkmm2ext/motionfeedback.h8
-rw-r--r--libs/gtkmm2ext/motionfeedback.cc62
-rw-r--r--libs/gtkmm2ext/pixfader.cc6
23 files changed, 211 insertions, 122 deletions
diff --git a/gtk2_ardour/ardour3_styles.rc.in b/gtk2_ardour/ardour3_styles.rc.in
index f8afec52b1..6deddf7c11 100644
--- a/gtk2_ardour/ardour3_styles.rc.in
+++ b/gtk2_ardour/ardour3_styles.rc.in
@@ -571,7 +571,7 @@ style "medium_entry" = "medium_text"
fg[ACTIVE] = @@COLPREFIX@_text
fg[SELECTED] = @@COLPREFIX@_fg_selected
- bg[NORMAL] = @@COLPREFIX@_bg
+ bg[NORMAL] = @@COLPREFIX@_base
base[NORMAL] = @@COLPREFIX@_base
base[ACTIVE] = @@COLPREFIX@_base
@@ -593,7 +593,7 @@ style "medium_bold_entry" = "medium_bold_text"
fg[NORMAL] = @@COLPREFIX@_text
fg[ACTIVE] = @@COLPREFIX@_text
- bg[NORMAL] = @@COLPREFIX@_bg
+ bg[NORMAL] = @@COLPREFIX@_base
base[NORMAL] = @@COLPREFIX@_base
base[ACTIVE] = @@COLPREFIX@_base
@@ -627,7 +627,7 @@ style "small_bold_entry" = "small_bold_text"
fg[NORMAL] = @@COLPREFIX@_text
fg[ACTIVE] = @@COLPREFIX@_text
- bg[NORMAL] = @@COLPREFIX@_bg
+ bg[NORMAL] = @@COLPREFIX@_base
base[NORMAL] = @@COLPREFIX@_base
base[ACTIVE] = @@COLPREFIX@_base
diff --git a/gtk2_ardour/ardour3_widget_list.rc b/gtk2_ardour/ardour3_widget_list.rc
index 8c49427f6a..e85532515d 100644
--- a/gtk2_ardour/ardour3_widget_list.rc
+++ b/gtk2_ardour/ardour3_widget_list.rc
@@ -237,7 +237,8 @@ widget "*PluginParameterLabel" style:highest "medium_text"
widget "*PluginNameInfo" style:highest "plugin_name_text"
widget "*PluginMakerInfo" style:highest "plugin_maker_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 "*PluginUIClickBox" style:highest "medium_bold_entry"
widget "*PluginUIClickBox*" style:highest "medium_bold_entry"
diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc
index 9a5a9098c7..979b969621 100644
--- a/gtk2_ardour/automation_line.cc
+++ b/gtk2_ardour/automation_line.cc
@@ -521,7 +521,7 @@ AutomationLine::fraction_to_string (double fraction) const
if (fraction == 0.0) {
snprintf (buf, sizeof (buf), "-inf");
} 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 {
view_to_model_coord_y (fraction);
@@ -551,7 +551,7 @@ AutomationLine::string_to_fraction (string const & s) const
sscanf (s.c_str(), "%lf", &v);
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 {
double dummy = 0.0;
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 ... */
if (alist->parameter().type() == GainAutomation ||
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 = min (2.0, y);
} 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 ... */
if (alist->parameter().type() == GainAutomation ||
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 ||
alist->parameter().type() == PanElevationAutomation ||
alist->parameter().type() == PanWidthAutomation) {
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc
index 3be4e78db3..42765e1d87 100644
--- a/gtk2_ardour/editor_drag.cc
+++ b/gtk2_ardour/editor_drag.cc
@@ -66,14 +66,13 @@ using namespace ArdourCanvas;
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)
: _editor (e)
, _ending (false)
, _current_pointer_frame (0)
{
-
}
DragManager::~DragManager ()
@@ -2752,6 +2751,10 @@ ControlPointDrag::ControlPointDrag (Editor* e, ArdourCanvas::Item* i)
_cumulative_x_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");
_point = reinterpret_cast<ControlPoint*> (_item->get_data ("control_point"));
diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h
index 113e54c88e..d4cd5a6a9d 100644
--- a/gtk2_ardour/editor_drag.h
+++ b/gtk2_ardour/editor_drag.h
@@ -690,7 +690,7 @@ private:
double _fixed_grab_y;
double _cumulative_x_drag;
double _cumulative_y_drag;
- static double const _zero_gain_fraction;
+ static double _zero_gain_fraction;
};
/** Gain or automation line drag */
diff --git a/gtk2_ardour/gain_meter.cc b/gtk2_ardour/gain_meter.cc
index f0a8ceb548..b671d5674a 100644
--- a/gtk2_ardour/gain_meter.cc
+++ b/gtk2_ardour/gain_meter.cc
@@ -79,7 +79,7 @@ GainMeterBase::GainMeterBase (Session* s,
const Glib::RefPtr<Gdk::Pixbuf>& pix,
bool horizontal,
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_state_button ("")
, style_changed (false)
@@ -382,7 +382,7 @@ GainMeterBase::show_gain ()
if (v == 0.0) {
strcpy (buf, _("-inf"));
} 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 {
snprintf (buf, sizeof (buf), "%.1f", v);
@@ -395,14 +395,13 @@ void
GainMeterBase::gain_adjusted ()
{
if (!ignore_toggle) {
- if (_route && _route->amp() == _amp) {
- if (_is_midi) {
- _route->set_gain (gain_adjustment.get_value(), this);
- } else {
- _route->set_gain (slider_position_to_gain (gain_adjustment.get_value()), this);
- }
+ if (_is_midi) {
+ _amp->set_gain (gain_adjustment.get_value(), this);
} else {
- _amp->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())
+ << endl;
+ _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;
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 {
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) {
ignore_toggle = true;
gain_adjustment.set_value (value);
diff --git a/gtk2_ardour/monitor_section.cc b/gtk2_ardour/monitor_section.cc
index 9d1811b1d4..ecd1e5c259 100644
--- a/gtk2_ardour/monitor_section.cc
+++ b/gtk2_ardour/monitor_section.cc
@@ -70,12 +70,12 @@ MonitorSection::MonitorSection (Session* s)
/* 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);
dim_packer->show ();
- spin_label = manage (new Label (_("Dim Cut")));
+ spin_label = manage (new Label (_("Dim")));
spin_packer = manage (new VBox);
spin_packer->show ();
spin_packer->set_spacing (6);
@@ -134,7 +134,7 @@ MonitorSection::MonitorSection (Session* s)
/* 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);
solo_packer->set_spacing (12);
@@ -151,7 +151,7 @@ MonitorSection::MonitorSection (Session* s)
/* 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_packer = manage (new VBox);
@@ -234,10 +234,10 @@ MonitorSection::MonitorSection (Session* s)
/* 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_packer = manage (new VBox);
+ spin_label = manage (new Label (_("Monitor")));
+ spin_packer = manage (new VBox);
spin_packer->show ();
spin_packer->set_spacing (6);
spin_packer->pack_start (*gain_control, false, false);
diff --git a/gtk2_ardour/option_editor.cc b/gtk2_ardour/option_editor.cc
index ffdbdc4e95..33f8a8dc43 100644
--- a/gtk2_ardour/option_editor.cc
+++ b/gtk2_ardour/option_editor.cc
@@ -20,9 +20,12 @@
#include <gtkmm/box.h>
#include <gtkmm/alignment.h>
#include "gtkmm2ext/utils.h"
+
#include "ardour/configuration.h"
+#include "ardour/rc_configuration.h"
#include "ardour/utils.h"
#include "ardour/dB.h"
+
#include "option_editor.h"
#include "gui_thread.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)
: Option (i, n)
- // 0.781787 is the value needed for gain to be set to 0.
- , _db_adjustment (0.781787, 0, 1, 0.01, 0.1)
+ , _db_adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0, 1, 0.01, 0.1)
, _get (g)
, _set (s)
{
@@ -166,7 +168,7 @@ void
FaderOption::set_state_from_config ()
{
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];
@@ -182,7 +184,7 @@ FaderOption::set_state_from_config ()
void
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
diff --git a/gtk2_ardour/processor_box.cc b/gtk2_ardour/processor_box.cc
index 3ccb97e5ca..0aeef0ff17 100644
--- a/gtk2_ardour/processor_box.cc
+++ b/gtk2_ardour/processor_box.cc
@@ -300,8 +300,7 @@ ProcessorEntry::name () const
SendProcessorEntry::SendProcessorEntry (boost::shared_ptr<Send> s, Width w)
: ProcessorEntry (s, w),
_send (s),
- /* set the adjustment to a gain of 0dB so that the fader's default value is right */
- _adjustment (0.781787, 0, 1, 0.01, 0.1),
+ _adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0, 1, 0.01, 0.1),
_fader (_slider, &_adjustment, 0, false),
_ignore_gain_change (false)
{
@@ -326,9 +325,7 @@ SendProcessorEntry::setup_slider_pix ()
void
SendProcessorEntry::show_gain ()
{
- ENSURE_GUI_THREAD (*this, &SendProcessorEntry::show_gain)
-
- float const value = gain_to_slider_position (_send->amp()->gain ());
+ float const value = gain_to_slider_position_with_max (_send->amp()->gain (), Config->get_max_gain());
if (_adjustment.get_value() != value) {
_ignore_gain_change = true;
@@ -350,7 +347,7 @@ SendProcessorEntry::gain_adjusted ()
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
diff --git a/gtk2_ardour/volume_controller.cc b/gtk2_ardour/volume_controller.cc
index 8a382f6cb1..365379933d 100644
--- a/gtk2_ardour/volume_controller.cc
+++ b/gtk2_ardour/volume_controller.cc
@@ -28,6 +28,7 @@
#include "gtkmm2ext/gui_thread.h"
#include "ardour/dB.h"
+#include "ardour/rc_configuration.h"
#include "ardour/utils.h"
#include "volume_controller.h"
@@ -42,12 +43,10 @@ VolumeController::VolumeController (Glib::RefPtr<Gdk::Pixbuf> p,
bool with_numeric,
int subw,
int subh,
- bool linear,
- bool dB)
+ bool linear)
: MotionFeedback (p, MotionFeedback::Rotary, c, def, step, page, "", with_numeric, subw, subh)
, _linear (linear)
- , _controllable_uses_dB (dB)
{
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 (_linear) {
- /* controllable units are in dB so just show the value */
+
+ double val = accurate_coefficient_to_dB (c->get_value());
+
if (step_inc < 1.0) {
- snprintf (buf, 32, "%.2f dB", c->get_value());
+ if (val >= 0.0) {
+ snprintf (buf, 32, "+%5.2f dB", val);
+ } else {
+ snprintf (buf, 32, "%5.2f dB", val);
+ }
} else {
- snprintf (buf, 32, "%ld dB", lrint (c->get_value()));
+ if (val >= 0.0) {
+ snprintf (buf, 32, "+%2ld dB", lrint (val));
+ } else {
+ snprintf (buf, 32, "%2ld dB", lrint (val));
+ }
}
+
} else {
- double gain_coefficient;
-
- 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);
- }
+ double dB = accurate_coefficient_to_dB (c->get_value());
if (step_inc < 1.0) {
- snprintf (buf, 32, "%.2f dB", accurate_coefficient_to_dB (gain_coefficient));
+ if (dB >= 0.0) {
+ snprintf (buf, 32, "+%5.2f dB", dB);
+ } else {
+ snprintf (buf, 32, "%5.2f dB", dB);
+ }
} else {
- snprintf (buf, 32, "%ld dB", lrint (accurate_coefficient_to_dB (gain_coefficient)));
+ if (dB >= 0.0) {
+ snprintf (buf, 32, "+%2ld dB", lrint (dB));
+ } else {
+ snprintf (buf, 32, "%2ld dB", lrint (dB));
+ }
}
}
} else {
@@ -111,8 +122,7 @@ VolumeController::to_control_value (double display_value)
if (_linear) {
v = _controllable->lower() + ((_controllable->upper() - _controllable->lower()) * display_value);
} else {
-
- v = slider_position_to_gain (display_value);
+ v = slider_position_to_gain_with_max (display_value, ARDOUR::Config->get_max_gain());
}
return v;
@@ -123,11 +133,18 @@ VolumeController::to_display_value (double control_value)
{
double v;
- if (_linear) {
+// if (_linear) {
v = (control_value - _controllable->lower ()) / (_controllable->upper() - _controllable->lower());
- } else {
- v = gain_to_slider_position (control_value);
- }
+// } else {
+// v = gain_to_slider_position_with_max (control_value, ARDOUR::Config->get_max_gain());
+// }
return v;
}
+
+double
+VolumeController::adjust (double control_delta)
+{
+ return std::max (_controllable->lower(), std::min (_controllable->upper(), _controllable->get_value() + control_delta));
+}
+
diff --git a/gtk2_ardour/volume_controller.h b/gtk2_ardour/volume_controller.h
index 8693f5f0da..28877b7987 100644
--- a/gtk2_ardour/volume_controller.h
+++ b/gtk2_ardour/volume_controller.h
@@ -35,8 +35,7 @@ class VolumeController : public Gtkmm2ext::MotionFeedback
bool with_numeric = true,
int image_width = 40,
int image_height = 40,
- bool linear = true,
- bool dB = false);
+ bool linear = true);
virtual ~VolumeController () {}
@@ -45,10 +44,13 @@ class VolumeController : public Gtkmm2ext::MotionFeedback
protected:
double to_control_value (double);
double to_display_value (double);
+ double adjust (double nominal_delta);
+
+ double display_value () const;
+ double control_value () const;
private:
bool _linear;
- bool _controllable_uses_dB;
void dB_printer (char buf[32], const boost::shared_ptr<PBD::Controllable>& adj);
};
diff --git a/libs/ardour/amp.cc b/libs/ardour/amp.cc
index 200a29861e..bbbaa9b331 100644
--- a/libs/ardour/amp.cc
+++ b/libs/ardour/amp.cc
@@ -412,8 +412,8 @@ void
Amp::GainControl::set_value (double val)
{
// max gain at about +6dB (10.0 ^ ( 6 dB * 0.05))
- if (val > 1.99526231f) {
- val = 1.99526231f;
+ if (val > 1.99526231) {
+ val = 1.99526231;
}
_amp->set_gain (val, this);
diff --git a/libs/ardour/ardour/dB.h b/libs/ardour/ardour/dB.h
index e5865aabd8..d2675fb3c9 100644
--- a/libs/ardour/ardour/dB.h
+++ b/libs/ardour/ardour/dB.h
@@ -34,6 +34,6 @@ static inline float accurate_coefficient_to_dB (float 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__ */
diff --git a/libs/ardour/ardour/rc_configuration_vars.h b/libs/ardour/ardour/rc_configuration_vars.h
index ffe85e8fcb..6fb67595e2 100644
--- a/libs/ardour/ardour/rc_configuration_vars.h
+++ b/libs/ardour/ardour/rc_configuration_vars.h
@@ -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 (int32_t, processor_usage, "processor-usage", -1)
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 */
diff --git a/libs/ardour/ardour/utils.h b/libs/ardour/ardour/utils.h
index dac4086cba..17fa9070ff 100644
--- a/libs/ardour/ardour/utils.h
+++ b/libs/ardour/ardour/utils.h
@@ -36,6 +36,7 @@ bool string_is_affirmative (const std::string&);
#include "ardour/ardour.h"
#include "ardour/data_type.h"
+#include "ardour/dB.h"
class XMLNode;
@@ -70,22 +71,78 @@ ARDOUR::SyncSource string_to_sync_source (std::string str);
const char* edit_mode_to_string (ARDOUR::EditMode);
ARDOUR::EditMode string_to_edit_mode (std::string);
+#undef OLD_GAIN_MATH
+#define OLD_GAIN_MATH
static inline double
gain_to_slider_position (ARDOUR::gain_t g)
{
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
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 ... */
if (pos == 0.0) return 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
* Probably should use a map of some kind that could be configured
diff --git a/libs/ardour/globals.cc b/libs/ardour/globals.cc
index 7238a1f0e6..6e6dd70856 100644
--- a/libs/ardour/globals.cc
+++ b/libs/ardour/globals.cc
@@ -65,6 +65,7 @@
#include "ardour/audiosource.h"
#include "ardour/buffer_manager.h"
#include "ardour/control_protocol_manager.h"
+#include "ardour/dB.h"
#include "ardour/debug.h"
#include "ardour/filesystem_paths.h"
#include "ardour/midi_region.h"
diff --git a/libs/ardour/monitor_processor.cc b/libs/ardour/monitor_processor.cc
index 1125dedc64..835bfde70f 100644
--- a/libs/ardour/monitor_processor.cc
+++ b/libs/ardour/monitor_processor.cc
@@ -1,9 +1,9 @@
#include "pbd/convert.h"
#include "pbd/error.h"
+#include "pbd/locale_guard.h"
#include "pbd/xml++.h"
#include "ardour/amp.h"
-#include "ardour/dB.h"
#include "ardour/debug.h"
#include "ardour/audio_buffer.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))
, _cut_all_ptr (new MPControl<bool> (false, _("monitor cut"), Controllable::Toggle))
, _mono_ptr (new MPControl<bool> (false, _("monitor mono"), Controllable::Toggle))
- , _dim_level_ptr (new MPControl<volatile gain_t> /* units in dB */
- (-12.0, _("monitor dim level"), Controllable::Flag (0), -20.0f, 0.0f))
- , _solo_boost_level_ptr (new MPControl<volatile gain_t> /* units in dB */
- (0.0, _("monitor solo boost level"), Controllable::Flag (0), 0.0, 20.0))
+ , _dim_level_ptr (new MPControl<volatile gain_t>
+ /* default is -12dB, range is -20dB to 0dB */
+ (0.251188635826, _("monitor dim level"), Controllable::Flag (0), 0.100000001490, 1.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)
, _cut_all_control (_cut_all_ptr)
@@ -202,6 +204,7 @@ MonitorProcessor::set_state (const XMLNode& node, int version)
XMLNode&
MonitorProcessor::state (bool full)
{
+ LocaleGuard lg (X_("POSIX"));
XMLNode& node (Processor::state (full));
char buf[64];
@@ -251,12 +254,11 @@ MonitorProcessor::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /
gain_t target_gain;
gain_t dim_level_this_time = _dim_level;
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;
if (_session.listening() || _session.soloing()) {
- /* solo boost controller is in dB */
- solo_boost = dB_to_coefficient (_solo_boost_level);
+ solo_boost = _solo_boost_level;
} else {
solo_boost = 1.0;
}
@@ -266,11 +268,7 @@ MonitorProcessor::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /
/* don't double-scale by both track dim and global dim coefficients */
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) {
target_gain = _channels[chn]->polarity * _channels[chn]->cut * dim_level * global_cut * global_dim * solo_boost;
} else {
diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc
index 30a0b6f24a..8a95f22f8d 100644
--- a/libs/ardour/region.cc
+++ b/libs/ardour/region.cc
@@ -1249,7 +1249,6 @@ int
Region::_set_state (const XMLNode& node, int /*version*/, PropertyChange& what_changed, bool send)
{
const XMLProperty* prop;
- const XMLNodeList& nlist = node.children();
Stateful::save_extra_xml (node);
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index 923fd6164f..3e3d391a7a 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -1188,7 +1188,7 @@ Session::set_block_size (pframes_t nframes)
::process(). It is therefore fine to do things that block
here.
*/
-
+
{
current_block_size = nframes;
diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc
index 0e1b06b1a7..4175322bb6 100644
--- a/libs/ardour/utils.cc
+++ b/libs/ardour/utils.cc
@@ -672,6 +672,18 @@ how_many_dsp_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" {
void c_stacktrace() { stacktrace (cerr); }
}
diff --git a/libs/gtkmm2ext/gtkmm2ext/motionfeedback.h b/libs/gtkmm2ext/gtkmm2ext/motionfeedback.h
index 0eaf78ed55..70ab50d6ba 100644
--- a/libs/gtkmm2ext/gtkmm2ext/motionfeedback.h
+++ b/libs/gtkmm2ext/gtkmm2ext/motionfeedback.h
@@ -24,6 +24,7 @@
#include <gdkmm/pixbuf.h>
#include <gtkmm/box.h>
+#include <gtkmm/label.h>
#include <gtkmm/eventbox.h>
#include "gtkmm2ext/binding_proxy.h"
@@ -58,7 +59,6 @@ class MotionFeedback : public Gtk::VBox
virtual ~MotionFeedback ();
Gtk::Widget& eventwin () { return pixwin; }
- Gtk::Entry& value_display() const { return *value; }
boost::shared_ptr<PBD::Controllable> controllable() const;
virtual void set_controllable (boost::shared_ptr<PBD::Controllable> c);
@@ -75,7 +75,7 @@ class MotionFeedback : public Gtk::VBox
protected:
boost::shared_ptr<PBD::Controllable> _controllable;
- Gtk::Entry* value;
+ Gtk::Label* value;
double default_value;
double step_inc;
double page_inc;
@@ -103,12 +103,12 @@ class MotionFeedback : public Gtk::VBox
*/
virtual double to_display_value (double) = 0;
- double adjust (double control_value, double display_delta);
+ virtual double adjust (double nominal_delta) = 0;
private:
Type type;
Gtk::EventBox pixwin;
- Gtk::HBox* value_packer;
+ Gtk::EventBox* value_packer;
Glib::RefPtr<Gdk::Pixbuf> pixbuf;
BindingProxy binding_proxy;
diff --git a/libs/gtkmm2ext/motionfeedback.cc b/libs/gtkmm2ext/motionfeedback.cc
index da16da57ce..c3152d7616 100644
--- a/libs/gtkmm2ext/motionfeedback.cc
+++ b/libs/gtkmm2ext/motionfeedback.cc
@@ -74,11 +74,17 @@ MotionFeedback::MotionFeedback (Glib::RefPtr<Gdk::Pixbuf> pix,
if (with_numeric_display) {
- value_packer = new HBox;
- value = new Entry;
- value->set_editable (false);
- value_packer->pack_start (*value, false, false);
+ value_packer = new EventBox;
+ value_packer->set_name ("MotionControllerValue");
+ value_packer->show ();
+ 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->pack_start (*value_packer, true, false);
hpacker->show ();
@@ -95,8 +101,6 @@ MotionFeedback::MotionFeedback (Glib::RefPtr<Gdk::Pixbuf> pix,
print_func (buf, _controllable, print_arg);
value->set_text (buf);
}
-
- value->show ();
}
pixwin.set_events (Gdk::BUTTON_PRESS_MASK|
@@ -137,24 +141,22 @@ MotionFeedback::pixwin_button_press_event (GdkEventButton *ev)
}
switch (ev->button) {
- case 2:
- return FALSE; /* XXX why ? */
-
case 1:
grab_is_fine = false;
break;
- case 3:
+ case 2:
grab_is_fine = true;
break;
+ case 3:
+ return false;
}
gtk_grab_add(GTK_WIDGET(pixwin.gobj()));
+
grabbed_y = ev->y_root;
grabbed_x = ev->x_root;
- /* XXX should we return TRUE ? */
-
- return FALSE;
+ return false;
}
bool
@@ -213,6 +215,8 @@ MotionFeedback::pixwin_motion_notify_event (GdkEventMotion *ev)
if (ev->state & Gdk::BUTTON1_MASK) {
+ /* vertical control */
+
y_delta = 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 /= 10;
- _controllable->set_value (adjust (_controllable->get_value(),
- ((grab_is_fine ? step_inc : page_inc) * y_delta)));
+ _controllable->set_value (adjust ((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 y = - ev->y + subwidth/2;
@@ -261,12 +266,6 @@ MotionFeedback::pixwin_leave_notify_event (GdkEventCrossing *ev)
return false;
}
-double
-MotionFeedback::adjust (double control_value, double display_delta)
-{
- return to_control_value (to_display_value (control_value) + display_delta);
-}
-
bool
MotionFeedback::pixwin_key_press_event (GdkEventKey *ev)
{
@@ -275,32 +274,31 @@ MotionFeedback::pixwin_key_press_event (GdkEventKey *ev)
}
bool retval = false;
- double curval = _controllable->get_value ();
double multiplier;
- multiplier = ((ev->state & Keyboard::TertiaryModifier) ? 100 : 1) *
- ((ev->state & Keyboard::SecondaryModifier) ? 10 : 1) *
- ((ev->state & Keyboard::PrimaryModifier) ? 2 : 1);
+ multiplier = ((ev->state & Keyboard::TertiaryModifier) ? 100.0 : 1.0) *
+ ((ev->state & Keyboard::SecondaryModifier) ? 10.0 : 1.0) *
+ ((ev->state & Keyboard::PrimaryModifier) ? 2.0 : 1.0);
switch (ev->keyval) {
case GDK_Page_Up:
retval = true;
- _controllable->set_value (adjust (curval, multiplier * page_inc));
+ _controllable->set_value (adjust (multiplier * page_inc));
break;
case GDK_Page_Down:
retval = true;
- _controllable->set_value (adjust (curval, multiplier * page_inc));
+ _controllable->set_value (adjust (multiplier * page_inc));
break;
case GDK_Up:
retval = true;
- _controllable->set_value (adjust (curval, multiplier * step_inc));
+ _controllable->set_value (adjust (multiplier * step_inc));
break;
case GDK_Down:
retval = true;
- _controllable->set_value (adjust (curval, multiplier * step_inc));
+ _controllable->set_value (adjust (multiplier * step_inc));
break;
case GDK_Home:
@@ -388,12 +386,12 @@ MotionFeedback::pixwin_scroll_event (GdkEventScroll* ev)
switch (ev->direction) {
case GDK_SCROLL_UP:
case GDK_SCROLL_RIGHT:
- _controllable->set_value (adjust (_controllable->get_value(), (scale * step_inc)));
+ _controllable->set_value (adjust (scale * step_inc));
break;
case GDK_SCROLL_DOWN:
case GDK_SCROLL_LEFT:
- _controllable->set_value (adjust (_controllable->get_value(), -(scale * step_inc)));
+ _controllable->set_value (adjust (-scale * step_inc));
break;
}
diff --git a/libs/gtkmm2ext/pixfader.cc b/libs/gtkmm2ext/pixfader.cc
index 6f8eb32e78..7a6357fa53 100644
--- a/libs/gtkmm2ext/pixfader.cc
+++ b/libs/gtkmm2ext/pixfader.cc
@@ -342,6 +342,12 @@ PixFader::on_motion_notify_event (GdkEventMotion* ev)
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()));
}