13
0

Synchronize meter-reset #7465

Queue reset to be handled when the meter is updated.
Also only call set_name(), set_active_state() when the
state changes.
This commit is contained in:
Robin Gareus 2020-04-10 23:36:17 +02:00
parent 58672bcaa2
commit e1a9034a0e
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
7 changed files with 66 additions and 30 deletions

View File

@ -316,6 +316,8 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir)
, error_alert_button ( ArdourButton::just_led_default_elements )
, editor_meter_peak_display()
, editor_meter(0)
, _clear_editor_meter( true)
, _editor_meter_peaked (false)
, _numpad_locate_happening (false)
, _session_is_new (false)
, last_key_press_time (0)
@ -1136,11 +1138,20 @@ ARDOUR_UI::every_point_zero_something_seconds ()
// august 2007: actual update frequency: 25Hz (40ms), not 100Hz
if (editor_meter && UIConfiguration::instance().get_show_editor_meter() && editor_meter_peak_display.is_mapped ()) {
float mpeak = editor_meter->update_meters();
if (mpeak > editor_meter_max_peak) {
if (mpeak >= UIConfiguration::instance().get_meter_peak()) {
editor_meter_peak_display.set_active_state ( Gtkmm2ext::ExplicitActive );
if (_clear_editor_meter) {
editor_meter->clear_meters();
editor_meter_peak_display.set_active_state (Gtkmm2ext::Off);
_clear_editor_meter = false;
_editor_meter_peaked = false;
}
const float mpeak = editor_meter->update_meters();
const bool peaking = mpeak > UIConfiguration::instance().get_meter_peak();
if (!_editor_meter_peaked && peaking) {
editor_meter_peak_display.set_active_state ( Gtkmm2ext::ExplicitActive );
_editor_meter_peaked = true;
}
}
}
@ -2935,9 +2946,7 @@ void
ARDOUR_UI::reset_peak_display ()
{
if (!_session || !_session->master_out() || !editor_meter) return;
editor_meter->clear_meters();
editor_meter_max_peak = -INFINITY;
editor_meter_peak_display.set_active_state ( Gtkmm2ext::Off );
_clear_editor_meter = true;
}
void

View File

@ -545,10 +545,13 @@ private:
ArdourWidgets::ArdourButton action_script_call_btn[MAX_LUA_ACTION_BUTTONS];
Gtk::VBox alert_box;
Gtk::Table editor_meter_table;
ArdourWidgets::ArdourButton editor_meter_peak_display;
LevelMeterHBox * editor_meter;
float editor_meter_max_peak;
bool _clear_editor_meter;
bool _editor_meter_peaked;
bool editor_meter_peak_button_release (GdkEventButton*);
void blink_handler (bool);

View File

@ -275,7 +275,7 @@ ARDOUR_UI::set_session (Session *s)
editor_meter_peak_display.set_size_request (-1, std::max (5.f, std::min (12.f, rintf (8.f * UIConfiguration::instance().get_ui_scale()))) );
editor_meter_peak_display.set_corner_radius (1.0);
editor_meter_max_peak = -INFINITY;
_clear_editor_meter = true;
editor_meter_peak_display.signal_button_release_event().connect (sigc::mem_fun(*this, &ARDOUR_UI::editor_meter_peak_button_release), false);
repack_transport_hbox ();

View File

@ -106,6 +106,8 @@ GainMeterBase::GainMeterBase (Session* s, bool horizontal, int fader_length, int
, meter_point_button (_("pre"))
, gain_astate_propagate (false)
, _data_type (DataType::AUDIO)
, _clear_meters (true)
, _meter_peaked (false)
{
using namespace Menu_Helpers;
@ -456,10 +458,7 @@ GainMeterBase::reset_peak_display ()
return;
}
_meter->reset_max();
level_meter->clear_meters();
max_peak = minus_infinity ();
peak_display.set_text (_("-inf"));
peak_display.set_name ("MixerStripPeakDisplay");
_clear_meters = true;
}
void
@ -842,7 +841,15 @@ GainMeterBase::meter_channels() const
void
GainMeterBase::update_meters()
{
char buf[32];
if (_clear_meters) {
max_peak = minus_infinity ();
level_meter->clear_meters ();
peak_display.set_text (_("-inf"));
peak_display.set_name ("MixerStripPeakDisplay");
_meter_peaked = false;
_clear_meters = false;
}
float mpeak = level_meter->update_meters();
if (mpeak > max_peak) {
@ -850,12 +857,17 @@ GainMeterBase::update_meters()
if (mpeak <= -200.0f) {
peak_display.set_text (_("-inf"));
} else {
char buf[32];
snprintf (buf, sizeof(buf), "%.1f", mpeak);
peak_display.set_text (buf);
}
}
if (mpeak >= UIConfiguration::instance().get_meter_peak()) {
bool peaking = mpeak >= UIConfiguration::instance().get_meter_peak();
if (!_meter_peaked && peaking) {
peak_display.set_name ("MixerStripPeakDisplayPeak");
_meter_peaked = true;
}
}

View File

@ -208,6 +208,9 @@ private:
bool level_meter_button_press (GdkEventButton *);
PBD::ScopedConnection _level_meter_connection;
bool _clear_meters;
bool _meter_peaked;
};
class GainMeter : public GainMeterBase, public Gtk::VBox

View File

@ -70,6 +70,8 @@ PBD::Signal0<void> MeterStrip::ConfigurationChanged;
MeterStrip::MeterStrip (int metricmode, MeterType mt)
: RouteUI ((Session*) 0)
, metric_type (MeterPeak)
, _clear_meters (true)
, _meter_peaked (false)
, _has_midi (false)
, _tick_bar (0)
, _strip_type (0)
@ -127,6 +129,8 @@ MeterStrip::MeterStrip (Session* sess, boost::shared_ptr<ARDOUR::Route> rt)
, RouteUI ((Session*) 0)
, _route (rt)
, metric_type (MeterPeak)
, _clear_meters (true)
, _meter_peaked (false)
, _has_midi (false)
, _tick_bar (0)
, _strip_type (0)
@ -165,7 +169,6 @@ MeterStrip::MeterStrip (Session* sess, boost::shared_ptr<ARDOUR::Route> rt)
peak_display.set_name ("meterbridge peakindicator");
peak_display.set_elements((ArdourButton::Element) (ArdourButton::Edge|ArdourButton::Body));
set_tooltip (peak_display, _("Reset Peak"));
max_peak = minus_infinity();
peak_display.unset_flags (Gtk::CAN_FOCUS);
peak_display.set_size_request(PX_SCALE(12, 12), PX_SCALE(8, 8));
peak_display.set_corner_radius(2); // ardour-button scales this
@ -417,12 +420,19 @@ MeterStrip::route_color_changed ()
void
MeterStrip::fast_update ()
{
float mpeak = level_meter->update_meters();
if (mpeak > max_peak) {
max_peak = mpeak;
if (mpeak >= UIConfiguration::instance().get_meter_peak()) {
peak_display.set_active_state ( Gtkmm2ext::ExplicitActive );
if (_clear_meters) {
level_meter->clear_meters();
peak_display.set_active_state (Gtkmm2ext::Off);
_clear_meters = false;
_meter_peaked = false;
}
const float mpeak = level_meter->update_meters();
const bool peaking = mpeak > UIConfiguration::instance().get_meter_peak();
if (!_meter_peaked && peaking) {
peak_display.set_active_state ( Gtkmm2ext::ExplicitActive );
_meter_peaked = true;
}
}
@ -697,9 +707,7 @@ void
MeterStrip::reset_peak_display ()
{
_route->shared_peak_meter()->reset_max();
level_meter->clear_meters();
max_peak = -INFINITY;
peak_display.set_active_state ( Gtkmm2ext::Off );
_clear_meters = true;
}
bool
@ -776,7 +784,7 @@ void
MeterStrip::parameter_changed (std::string const & p)
{
if (p == "meter-peak") {
max_peak = -INFINITY;
_clear_meters = true;
}
else if (p == "show-rec-on-meterbridge") {
update_button_box();

View File

@ -131,7 +131,8 @@ private:
std::vector<ARDOUR::DataType> _types;
ARDOUR::MeterType metric_type;
float max_peak;
bool _clear_meters;
bool _meter_peaked;
bool _has_midi;
int _tick_bar;
int _strip_type;