diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2012-11-13 17:47:39 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2012-11-13 17:47:39 +0000 |
commit | c0bb288ff148274bd258562b0c718aa5e009cca0 (patch) | |
tree | bbc0c9f9c2757e73d01e5fe2e10e7812a96ebd5b /gtk2_ardour | |
parent | 55c7a3bf01ddbc22620eccbf682f5094e6be97e3 (diff) |
change handling of MIDI gain so that we present a linear fader spanning 0..127. this is based on the realization that we actually have no idea what the MIDI receiver will do with velocity and/or CC #7 values, and so trying to pretend that we can provide some kind of dB value in the display or the behaviour of the fader is completely wrong; ALSO: fix keyboard entry of fader levels for non EN locales (#5027)
git-svn-id: svn://localhost/ardour2/branches/3.0@13480 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/gain_meter.cc | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/gtk2_ardour/gain_meter.cc b/gtk2_ardour/gain_meter.cc index 166d29ef2c..5751d071cf 100644 --- a/gtk2_ardour/gain_meter.cc +++ b/gtk2_ardour/gain_meter.cc @@ -263,10 +263,10 @@ GainMeterBase::setup_gain_adjustment () } else { _data_type = DataType::MIDI; gain_adjustment.set_lower (0.0); - gain_adjustment.set_upper (2.0); - gain_adjustment.set_step_increment (0.05); - gain_adjustment.set_page_increment (0.1); - gain_slider->set_default_value (1); + gain_adjustment.set_upper (1.0); + gain_adjustment.set_step_increment (1.0/128.0); + gain_adjustment.set_page_increment (10.0/128.0); + gain_slider->set_default_value (1.0); } ignore_toggle = false; @@ -396,17 +396,29 @@ GainMeterBase::gain_activated () { float f; - if (sscanf (gain_display.get_text().c_str(), "%f", &f) == 1) { + { + // Switch to user's preferred locale so that + // if they use different LC_NUMERIC conventions, + // we will honor them. - /* clamp to displayable values */ + PBD::LocaleGuard lg (""); + if (sscanf (gain_display.get_text().c_str(), "%f", &f) != 1) { + return; + } + } + /* clamp to displayable values */ + if (_data_type == DataType::AUDIO) { f = min (f, 6.0f); - _amp->set_gain (dB_to_coefficient(f), this); + } else { + f = min (fabs (f), 127.0f); + f = Amp::midi_velocity_factor_to_gain_coefficient (f/127.0f); + _amp->set_gain (f, this); + } - if (gain_display.has_focus()) { - PublicEditor::instance().reset_focus(); - } + if (gain_display.has_focus()) { + PublicEditor::instance().reset_focus(); } } @@ -426,7 +438,7 @@ GainMeterBase::show_gain () } break; case DataType::MIDI: - snprintf (buf, sizeof (buf), "%.1f", v); + snprintf (buf, sizeof (buf), "%.0f", v * 127.0f); break; } @@ -436,15 +448,14 @@ GainMeterBase::show_gain () void GainMeterBase::gain_adjusted () { - gain_t value = 0; + gain_t value; - switch (_data_type) { - case DataType::AUDIO: + /* convert from adjustment range (0..1) to gain coefficient */ + + if (_data_type == DataType::AUDIO) { value = slider_position_to_gain_with_max (gain_adjustment.get_value(), Config->get_max_gain()); - break; - case DataType::MIDI: - value = gain_adjustment.get_value (); - break; + } else { + value = Amp::midi_velocity_factor_to_gain_coefficient (gain_adjustment.get_value()); } if (!ignore_toggle) { @@ -468,7 +479,7 @@ GainMeterBase::effective_gain_display () value = gain_to_slider_position_with_max (_amp->gain(), Config->get_max_gain()); break; case DataType::MIDI: - value = _amp->gain (); + value = Amp::gain_coefficient_to_midi_velocity_factor (_amp->gain ()); break; } |