2007-12-20 18:25:19 -05:00
|
|
|
/*
|
|
|
|
Copyright (C) 2002 Paul Davis
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <limits.h>
|
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/meter.h"
|
2016-09-25 16:02:16 -04:00
|
|
|
#include "ardour/logmeter.h"
|
2007-12-20 18:25:19 -05:00
|
|
|
|
|
|
|
#include <gtkmm2ext/utils.h>
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "pbd/fastlog.h"
|
2007-12-20 18:25:19 -05:00
|
|
|
|
|
|
|
#include "level_meter.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include "gui_thread.h"
|
|
|
|
#include "keyboard.h"
|
|
|
|
#include "public_editor.h"
|
2015-01-02 09:44:54 -05:00
|
|
|
#include "ui_config.h"
|
2007-12-20 18:25:19 -05:00
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2007-12-20 18:25:19 -05:00
|
|
|
|
|
|
|
using namespace ARDOUR;
|
2014-06-25 15:27:37 -04:00
|
|
|
using namespace ARDOUR_UI_UTILS;
|
2007-12-20 18:25:19 -05:00
|
|
|
using namespace PBD;
|
2017-07-16 16:13:46 -04:00
|
|
|
using namespace ArdourWidgets;
|
2007-12-20 18:25:19 -05:00
|
|
|
using namespace Gtk;
|
|
|
|
using namespace std;
|
|
|
|
|
2013-07-28 14:43:21 -04:00
|
|
|
LevelMeterBase::LevelMeterBase (Session* s, PBD::EventLoop::InvalidationRecord* ir, FastMeter::Orientation o)
|
2013-07-29 13:43:19 -04:00
|
|
|
: parent_invalidator(ir)
|
|
|
|
, _meter (0)
|
2013-07-25 08:18:39 -04:00
|
|
|
, _meter_orientation(o)
|
2013-07-31 13:24:26 -04:00
|
|
|
, regular_meter_width (6)
|
2009-05-04 13:05:55 -04:00
|
|
|
, meter_length (0)
|
2013-06-28 14:22:09 -04:00
|
|
|
, thin_meter_width(2)
|
2014-12-29 20:21:32 -05:00
|
|
|
, max_peak (minus_infinity())
|
2017-02-24 17:35:26 -05:00
|
|
|
, _meter_type (MeterPeak)
|
2015-04-30 13:06:26 -04:00
|
|
|
, visible_meter_type (MeterType(0))
|
2016-07-22 06:57:14 -04:00
|
|
|
, midi_count (0)
|
2016-05-04 11:36:40 -04:00
|
|
|
, meter_count (0)
|
|
|
|
, max_visible_meters (0)
|
2014-12-29 20:21:32 -05:00
|
|
|
, color_changed (false)
|
2007-12-20 18:25:19 -05:00
|
|
|
{
|
2009-12-17 13:24:23 -05:00
|
|
|
set_session (s);
|
2014-12-29 19:55:51 -05:00
|
|
|
|
2013-07-28 14:43:21 -04:00
|
|
|
Config->ParameterChanged.connect (_parameter_connection, parent_invalidator, boost::bind (&LevelMeterBase::parameter_changed, this, _1), gui_context());
|
2015-01-02 09:44:54 -05:00
|
|
|
UIConfiguration::instance().ParameterChanged.connect (sigc::mem_fun(*this, &LevelMeterBase::parameter_changed));
|
|
|
|
UIConfiguration::instance().ColorsChanged.connect (sigc::mem_fun (*this, &LevelMeterBase::color_handler));
|
2007-12-20 18:25:19 -05:00
|
|
|
}
|
|
|
|
|
2013-07-25 08:18:39 -04:00
|
|
|
LevelMeterBase::~LevelMeterBase ()
|
2007-12-20 18:25:19 -05:00
|
|
|
{
|
2014-09-10 20:34:09 -04:00
|
|
|
_configuration_connection.disconnect();
|
|
|
|
_meter_type_connection.disconnect();
|
|
|
|
_parameter_connection.disconnect();
|
2007-12-20 18:25:19 -05:00
|
|
|
for (vector<MeterInfo>::iterator i = meters.begin(); i != meters.end(); i++) {
|
2008-12-18 14:31:00 -05:00
|
|
|
delete (*i).meter;
|
2007-12-20 18:25:19 -05:00
|
|
|
}
|
2014-09-27 13:17:13 -04:00
|
|
|
meters.clear();
|
2007-12-20 18:25:19 -05:00
|
|
|
}
|
|
|
|
|
2008-12-08 11:07:28 -05:00
|
|
|
void
|
2013-07-25 08:18:39 -04:00
|
|
|
LevelMeterBase::set_meter (PeakMeter* meter)
|
2008-12-08 11:07:28 -05:00
|
|
|
{
|
2009-05-04 13:05:55 -04:00
|
|
|
_configuration_connection.disconnect();
|
2013-07-07 07:34:36 -04:00
|
|
|
_meter_type_connection.disconnect();
|
|
|
|
|
2009-05-16 22:08:13 -04:00
|
|
|
_meter = meter;
|
2015-04-30 13:11:55 -04:00
|
|
|
color_changed = true; // force update
|
2009-12-17 13:24:23 -05:00
|
|
|
|
2009-05-16 22:08:13 -04:00
|
|
|
if (_meter) {
|
2013-07-28 14:43:21 -04:00
|
|
|
_meter->ConfigurationChanged.connect (_configuration_connection, parent_invalidator, boost::bind (&LevelMeterBase::configuration_changed, this, _1, _2), gui_context());
|
|
|
|
_meter->TypeChanged.connect (_meter_type_connection, parent_invalidator, boost::bind (&LevelMeterBase::meter_type_changed, this, _1), gui_context());
|
2009-05-16 22:08:13 -04:00
|
|
|
}
|
2008-12-08 11:07:28 -05:00
|
|
|
}
|
|
|
|
|
2013-07-27 21:29:16 -04:00
|
|
|
static float meter_lineup_cfg(MeterLineUp lul, float offset) {
|
|
|
|
switch (lul) {
|
2013-07-23 15:20:51 -04:00
|
|
|
case MeteringLineUp24:
|
|
|
|
return offset + 6.0;
|
|
|
|
case MeteringLineUp20:
|
|
|
|
return offset + 2.0;
|
|
|
|
case MeteringLineUp18:
|
|
|
|
return offset;
|
|
|
|
case MeteringLineUp15:
|
|
|
|
return offset - 3.0;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
2013-07-27 21:29:16 -04:00
|
|
|
static float meter_lineup(float offset) {
|
2015-01-02 09:44:54 -05:00
|
|
|
return meter_lineup_cfg (UIConfiguration::instance().get_meter_line_up_level(), offset);
|
2013-07-27 21:29:16 -04:00
|
|
|
}
|
|
|
|
|
2013-07-23 15:20:51 -04:00
|
|
|
static float vu_standard() {
|
|
|
|
// note - default meter config is +2dB (france)
|
2015-01-02 09:44:54 -05:00
|
|
|
switch (UIConfiguration::instance().get_meter_vu_standard()) {
|
2013-07-23 19:43:24 -04:00
|
|
|
default:
|
2013-07-23 17:53:22 -04:00
|
|
|
case MeteringVUfrench: // 0VU = -2dBu
|
2013-07-23 15:20:51 -04:00
|
|
|
return 0;
|
2013-07-23 17:53:22 -04:00
|
|
|
case MeteringVUamerican: // 0VU = 0dBu
|
2013-07-23 15:20:51 -04:00
|
|
|
return -2;
|
2013-07-23 17:53:22 -04:00
|
|
|
case MeteringVUstandard: // 0VU = +4dBu
|
2013-07-23 15:20:51 -04:00
|
|
|
return -6;
|
2013-07-23 17:53:22 -04:00
|
|
|
case MeteringVUeight: // 0VU = +8dBu
|
|
|
|
return -10;
|
2013-07-23 15:20:51 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
float
|
2013-07-25 08:18:39 -04:00
|
|
|
LevelMeterBase::update_meters ()
|
2007-12-20 18:25:19 -05:00
|
|
|
{
|
|
|
|
vector<MeterInfo>::iterator i;
|
|
|
|
uint32_t n;
|
2009-05-16 22:08:13 -04:00
|
|
|
|
|
|
|
if (!_meter) {
|
|
|
|
return 0.0f;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2013-07-05 08:55:07 -04:00
|
|
|
uint32_t nmidi = _meter->input_streams().n_midi();
|
2013-07-04 18:43:31 -04:00
|
|
|
|
2007-12-20 18:25:19 -05:00
|
|
|
for (n = 0, i = meters.begin(); i != meters.end(); ++i, ++n) {
|
|
|
|
if ((*i).packed) {
|
2013-07-07 20:26:17 -04:00
|
|
|
const float mpeak = _meter->meter_level(n, MeterMaxPeak);
|
2013-07-06 10:32:36 -04:00
|
|
|
if (mpeak > (*i).max_peak) {
|
|
|
|
(*i).max_peak = mpeak;
|
2015-01-02 09:44:54 -05:00
|
|
|
(*i).meter->set_highlight(mpeak >= UIConfiguration::instance().get_meter_peak());
|
2008-04-11 10:06:50 -04:00
|
|
|
}
|
2008-09-10 11:03:30 -04:00
|
|
|
if (mpeak > max_peak) {
|
|
|
|
max_peak = mpeak;
|
|
|
|
}
|
2013-07-06 10:32:36 -04:00
|
|
|
|
2013-07-04 18:43:31 -04:00
|
|
|
if (n < nmidi) {
|
2013-07-07 20:26:17 -04:00
|
|
|
(*i).meter->set (_meter->meter_level (n, MeterPeak));
|
2013-07-04 18:43:31 -04:00
|
|
|
} else {
|
2017-02-24 17:35:26 -05:00
|
|
|
const float peak = _meter->meter_level (n, _meter_type);
|
|
|
|
if (_meter_type == MeterPeak) {
|
2013-07-07 19:06:02 -04:00
|
|
|
(*i).meter->set (log_meter (peak));
|
2017-02-24 17:35:26 -05:00
|
|
|
} else if (_meter_type == MeterPeak0dB) {
|
2015-04-25 00:46:56 -04:00
|
|
|
(*i).meter->set (log_meter0dB (peak));
|
2017-02-24 17:35:26 -05:00
|
|
|
} else if (_meter_type == MeterIEC1NOR) {
|
2013-07-23 15:20:51 -04:00
|
|
|
(*i).meter->set (meter_deflect_nordic (peak + meter_lineup(0)));
|
2017-02-24 17:35:26 -05:00
|
|
|
} else if (_meter_type == MeterIEC1DIN) {
|
2015-01-02 09:44:54 -05:00
|
|
|
(*i).meter->set (meter_deflect_din (peak + meter_lineup_cfg(UIConfiguration::instance().get_meter_line_up_din(), 3.0)));
|
2017-02-24 17:35:26 -05:00
|
|
|
} else if (_meter_type == MeterIEC2BBC || _meter_type == MeterIEC2EBU) {
|
2013-07-23 15:20:51 -04:00
|
|
|
(*i).meter->set (meter_deflect_ppm (peak + meter_lineup(0)));
|
2017-02-24 17:35:26 -05:00
|
|
|
} else if (_meter_type == MeterVU) {
|
2013-07-23 15:20:51 -04:00
|
|
|
(*i).meter->set (meter_deflect_vu (peak + vu_standard() + meter_lineup(0)));
|
2017-02-24 17:35:26 -05:00
|
|
|
} else if (_meter_type == MeterK12) {
|
2013-12-22 03:25:33 -05:00
|
|
|
(*i).meter->set (meter_deflect_k (peak, 12), meter_deflect_k(_meter->meter_level(n, MeterPeak), 12));
|
2017-02-24 17:35:26 -05:00
|
|
|
} else if (_meter_type == MeterK14) {
|
2013-07-22 12:45:08 -04:00
|
|
|
(*i).meter->set (meter_deflect_k (peak, 14), meter_deflect_k(_meter->meter_level(n, MeterPeak), 14));
|
2017-02-24 17:35:26 -05:00
|
|
|
} else if (_meter_type == MeterK20) {
|
2013-07-22 12:45:08 -04:00
|
|
|
(*i).meter->set (meter_deflect_k (peak, 20), meter_deflect_k(_meter->meter_level(n, MeterPeak), 20));
|
2013-07-23 15:20:51 -04:00
|
|
|
} else { // RMS
|
2013-07-07 19:06:02 -04:00
|
|
|
(*i).meter->set (log_meter (peak), log_meter(_meter->meter_level(n, MeterPeak)));
|
|
|
|
}
|
2013-07-04 18:43:31 -04:00
|
|
|
}
|
2007-12-20 18:25:19 -05:00
|
|
|
}
|
|
|
|
}
|
2008-04-11 10:06:50 -04:00
|
|
|
return max_peak;
|
2007-12-20 18:25:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-07-25 08:18:39 -04:00
|
|
|
LevelMeterBase::parameter_changed (string p)
|
2007-12-20 18:25:19 -05:00
|
|
|
{
|
2013-07-25 08:18:39 -04:00
|
|
|
ENSURE_GUI_THREAD (*this, &LevelMeterBase::parameter_changed, p)
|
2007-12-20 18:25:19 -05:00
|
|
|
|
2009-05-15 21:22:43 -04:00
|
|
|
if (p == "meter-hold") {
|
2007-12-20 18:25:19 -05:00
|
|
|
vector<MeterInfo>::iterator i;
|
|
|
|
uint32_t n;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-12-20 18:25:19 -05:00
|
|
|
for (n = 0, i = meters.begin(); i != meters.end(); ++i, ++n) {
|
2015-01-02 09:44:54 -05:00
|
|
|
(*i).meter->set_hold_count ((uint32_t) floor(UIConfiguration::instance().get_meter_hold()));
|
2007-12-20 18:25:19 -05:00
|
|
|
}
|
|
|
|
}
|
2013-07-05 16:18:04 -04:00
|
|
|
else if (p == "meter-line-up-level") {
|
|
|
|
color_changed = true;
|
|
|
|
setup_meters (meter_length, regular_meter_width, thin_meter_width);
|
|
|
|
}
|
2013-07-27 21:01:37 -04:00
|
|
|
else if (p == "meter-style-led") {
|
|
|
|
color_changed = true;
|
|
|
|
setup_meters (meter_length, regular_meter_width, thin_meter_width);
|
|
|
|
}
|
2013-07-06 11:10:13 -04:00
|
|
|
else if (p == "meter-peak") {
|
|
|
|
vector<MeterInfo>::iterator i;
|
|
|
|
uint32_t n;
|
|
|
|
|
|
|
|
for (n = 0, i = meters.begin(); i != meters.end(); ++i, ++n) {
|
|
|
|
(*i).max_peak = minus_infinity();
|
|
|
|
}
|
|
|
|
}
|
2007-12-20 18:25:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-07-25 08:18:39 -04:00
|
|
|
LevelMeterBase::configuration_changed (ChanCount /*in*/, ChanCount /*out*/)
|
2007-12-20 18:25:19 -05:00
|
|
|
{
|
2013-06-28 14:22:09 -04:00
|
|
|
setup_meters (meter_length, regular_meter_width, thin_meter_width);
|
2009-05-04 13:05:55 -04:00
|
|
|
}
|
2007-12-20 18:25:19 -05:00
|
|
|
|
2013-07-07 07:34:36 -04:00
|
|
|
void
|
2013-07-25 08:18:39 -04:00
|
|
|
LevelMeterBase::meter_type_changed (MeterType t)
|
2013-07-07 07:34:36 -04:00
|
|
|
{
|
2017-02-24 17:35:26 -05:00
|
|
|
_meter_type = t;
|
2013-07-22 12:45:08 -04:00
|
|
|
setup_meters (meter_length, regular_meter_width, thin_meter_width);
|
2013-07-07 07:34:36 -04:00
|
|
|
MeterTypeChanged(t);
|
2009-05-04 13:05:55 -04:00
|
|
|
}
|
2007-12-20 18:25:19 -05:00
|
|
|
|
2009-05-04 13:05:55 -04:00
|
|
|
void
|
2013-07-25 08:18:39 -04:00
|
|
|
LevelMeterBase::hide_all_meters ()
|
2009-05-04 13:05:55 -04:00
|
|
|
{
|
2007-12-20 18:25:19 -05:00
|
|
|
for (vector<MeterInfo>::iterator i = meters.begin(); i != meters.end(); ++i) {
|
|
|
|
if ((*i).packed) {
|
2013-07-25 08:18:39 -04:00
|
|
|
mtr_remove (*((*i).meter));
|
2007-12-20 18:25:19 -05:00
|
|
|
(*i).packed = false;
|
|
|
|
}
|
|
|
|
}
|
2016-05-04 11:36:40 -04:00
|
|
|
meter_count = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
LevelMeterBase::set_max_audio_meter_count (uint32_t cnt)
|
|
|
|
{
|
|
|
|
if (cnt == max_visible_meters) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
color_changed = true; // force re-setup
|
|
|
|
max_visible_meters = cnt;
|
|
|
|
setup_meters (meter_length, regular_meter_width, thin_meter_width);
|
2007-12-20 18:25:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-07-25 08:18:39 -04:00
|
|
|
LevelMeterBase::setup_meters (int len, int initial_width, int thin_width)
|
2007-12-20 18:25:19 -05:00
|
|
|
{
|
2015-01-08 21:18:43 -05:00
|
|
|
|
2009-05-04 13:05:55 -04:00
|
|
|
if (!_meter) {
|
2015-04-30 13:06:26 -04:00
|
|
|
hide_all_meters ();
|
2009-05-16 22:08:13 -04:00
|
|
|
return; /* do it later or never */
|
2008-12-08 11:07:28 -05:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2016-07-22 06:57:14 -04:00
|
|
|
uint32_t nmidi = _meter->input_streams().n_midi();
|
2009-05-04 13:05:55 -04:00
|
|
|
uint32_t nmeters = _meter->input_streams().n_total();
|
2008-04-11 10:06:50 -04:00
|
|
|
regular_meter_width = initial_width;
|
2013-06-28 14:22:09 -04:00
|
|
|
thin_meter_width = thin_width;
|
2009-05-04 13:05:55 -04:00
|
|
|
meter_length = len;
|
2008-09-10 11:03:30 -04:00
|
|
|
|
2007-12-20 18:25:19 -05:00
|
|
|
guint16 width;
|
|
|
|
|
|
|
|
if (nmeters == 0) {
|
2015-04-30 13:06:26 -04:00
|
|
|
hide_all_meters ();
|
2007-12-20 18:25:19 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nmeters <= 2) {
|
|
|
|
width = regular_meter_width;
|
|
|
|
} else {
|
|
|
|
width = thin_meter_width;
|
|
|
|
}
|
|
|
|
|
2015-01-02 09:44:54 -05:00
|
|
|
width = rint (width * UIConfiguration::instance().get_ui_scale());
|
2015-04-19 23:35:23 -04:00
|
|
|
|
2015-04-30 13:06:26 -04:00
|
|
|
if ( meters.size() > 0
|
2016-07-22 06:57:14 -04:00
|
|
|
&& nmidi == midi_count
|
2016-05-04 11:36:40 -04:00
|
|
|
&& nmeters == meter_count
|
2015-04-30 13:06:26 -04:00
|
|
|
&& meters[0].width == width
|
|
|
|
&& meters[0].length == len
|
|
|
|
&& !color_changed
|
2017-02-24 17:35:26 -05:00
|
|
|
&& _meter_type == visible_meter_type) {
|
2015-04-30 13:06:26 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
printf("Meter redraw: %s %s %s %s %s %s\n",
|
|
|
|
(meters.size() > 0) ? "yes" : "no",
|
|
|
|
(meters.size() > 0 && meters[0].width == width) ? "yes" : "no",
|
|
|
|
(meters.size() > 0 && meters[0].length == len) ? "yes" : "no",
|
2016-05-04 11:36:40 -04:00
|
|
|
(nmeters == meter_count) ? "yes" : "no",
|
2017-02-24 17:35:26 -05:00
|
|
|
(_meter_type == visible_meter_type) ? "yes" : "no",
|
2015-04-30 13:06:26 -04:00
|
|
|
!color_changed ? "yes" : "no"
|
|
|
|
);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
hide_all_meters ();
|
2007-12-20 18:25:19 -05:00
|
|
|
while (meters.size() < nmeters) {
|
|
|
|
meters.push_back (MeterInfo());
|
|
|
|
}
|
|
|
|
|
2013-07-25 08:18:39 -04:00
|
|
|
//cerr << "LevelMeterBase::setup_meters() called color_changed = " << color_changed << " colors: " << endl;//DEBUG
|
2007-12-20 18:25:19 -05:00
|
|
|
|
|
|
|
for (int32_t n = nmeters-1; nmeters && n >= 0 ; --n) {
|
2013-07-03 19:29:59 -04:00
|
|
|
uint32_t c[10];
|
2013-07-23 20:46:53 -04:00
|
|
|
uint32_t b[4];
|
2013-07-05 16:18:04 -04:00
|
|
|
float stp[4];
|
2015-01-02 09:44:54 -05:00
|
|
|
int styleflags = UIConfiguration::instance().get_meter_style_led() ? 3 : 1;
|
|
|
|
b[0] = UIConfiguration::instance().color ("meter background bottom");
|
|
|
|
b[1] = UIConfiguration::instance().color ("meter background top");
|
2013-07-23 20:46:53 -04:00
|
|
|
b[2] = 0x991122ff; // red highlight gradient Bot
|
|
|
|
b[3] = 0x551111ff; // red highlight gradient Top
|
2016-08-22 09:41:28 -04:00
|
|
|
if ((uint32_t) n < nmidi) {
|
2015-01-02 09:44:54 -05:00
|
|
|
c[0] = UIConfiguration::instance().color ("midi meter color0");
|
|
|
|
c[1] = UIConfiguration::instance().color ("midi meter color1");
|
|
|
|
c[2] = UIConfiguration::instance().color ("midi meter color2");
|
|
|
|
c[3] = UIConfiguration::instance().color ("midi meter color3");
|
|
|
|
c[4] = UIConfiguration::instance().color ("midi meter color4");
|
|
|
|
c[5] = UIConfiguration::instance().color ("midi meter color5");
|
|
|
|
c[6] = UIConfiguration::instance().color ("midi meter color6");
|
|
|
|
c[7] = UIConfiguration::instance().color ("midi meter color7");
|
|
|
|
c[8] = UIConfiguration::instance().color ("midi meter color8");
|
|
|
|
c[9] = UIConfiguration::instance().color ("midi meter color9");
|
2013-07-03 19:29:59 -04:00
|
|
|
stp[0] = 115.0 * 32.0 / 128.0;
|
|
|
|
stp[1] = 115.0 * 64.0 / 128.0;
|
|
|
|
stp[2] = 115.0 * 100.0 / 128.0;
|
|
|
|
stp[3] = 115.0 * 112.0 / 128.0;
|
2009-05-04 13:05:55 -04:00
|
|
|
} else {
|
2015-01-02 09:44:54 -05:00
|
|
|
c[0] = UIConfiguration::instance().color ("meter color0");
|
|
|
|
c[1] = UIConfiguration::instance().color ("meter color1");
|
|
|
|
c[2] = UIConfiguration::instance().color ("meter color2");
|
|
|
|
c[3] = UIConfiguration::instance().color ("meter color3");
|
|
|
|
c[4] = UIConfiguration::instance().color ("meter color4");
|
|
|
|
c[5] = UIConfiguration::instance().color ("meter color5");
|
|
|
|
c[6] = UIConfiguration::instance().color ("meter color6");
|
|
|
|
c[7] = UIConfiguration::instance().color ("meter color7");
|
|
|
|
c[8] = UIConfiguration::instance().color ("meter color8");
|
|
|
|
c[9] = UIConfiguration::instance().color ("meter color9");
|
2013-07-22 12:45:08 -04:00
|
|
|
|
2017-02-24 17:35:26 -05:00
|
|
|
switch (_meter_type) {
|
2013-07-22 12:45:08 -04:00
|
|
|
case MeterK20:
|
|
|
|
stp[0] = 115.0 * meter_deflect_k(-40, 20); //-20
|
|
|
|
stp[1] = 115.0 * meter_deflect_k(-20, 20); // 0
|
|
|
|
stp[2] = 115.0 * meter_deflect_k(-18, 20); // +2
|
|
|
|
stp[3] = 115.0 * meter_deflect_k(-16, 20); // +4
|
|
|
|
c[0] = c[1] = 0x008800ff;
|
|
|
|
c[2] = c[3] = 0x00ff00ff;
|
|
|
|
c[4] = c[5] = 0xffff00ff;
|
|
|
|
c[6] = c[7] = 0xffff00ff;
|
|
|
|
c[8] = c[9] = 0xff0000ff;
|
|
|
|
break;
|
|
|
|
case MeterK14:
|
|
|
|
stp[0] = 115.0 * meter_deflect_k(-34, 14); //-20
|
|
|
|
stp[1] = 115.0 * meter_deflect_k(-14, 14); // 0
|
|
|
|
stp[2] = 115.0 * meter_deflect_k(-12, 14); // +2
|
|
|
|
stp[3] = 115.0 * meter_deflect_k(-10, 14); // +4
|
|
|
|
c[0] = c[1] = 0x008800ff;
|
|
|
|
c[2] = c[3] = 0x00ff00ff;
|
|
|
|
c[4] = c[5] = 0xffff00ff;
|
|
|
|
c[6] = c[7] = 0xffff00ff;
|
|
|
|
c[8] = c[9] = 0xff0000ff;
|
|
|
|
break;
|
2013-12-22 03:25:33 -05:00
|
|
|
case MeterK12:
|
|
|
|
stp[0] = 115.0 * meter_deflect_k(-32, 12); //-20
|
|
|
|
stp[1] = 115.0 * meter_deflect_k(-12, 12); // 0
|
|
|
|
stp[2] = 115.0 * meter_deflect_k(-10, 12); // +2
|
|
|
|
stp[3] = 115.0 * meter_deflect_k( -8, 12); // +4
|
|
|
|
c[0] = c[1] = 0x008800ff;
|
|
|
|
c[2] = c[3] = 0x00ff00ff;
|
|
|
|
c[4] = c[5] = 0xffff00ff;
|
|
|
|
c[6] = c[7] = 0xffff00ff;
|
|
|
|
c[8] = c[9] = 0xff0000ff;
|
|
|
|
break;
|
2013-07-22 12:45:08 -04:00
|
|
|
case MeterIEC2BBC:
|
2013-07-28 21:54:43 -04:00
|
|
|
c[0] = c[1] = c[2] = c[3] = c[4] = c[5] = c[6] = c[7] = c[8] = c[9] =
|
2015-01-02 09:44:54 -05:00
|
|
|
UIConfiguration::instance().color ("meter color BBC");
|
2013-07-28 14:43:21 -04:00
|
|
|
stp[0] = stp[1] = stp[2] = stp[3] = 115.0;
|
2013-07-24 17:24:11 -04:00
|
|
|
break;
|
|
|
|
case MeterIEC2EBU:
|
2013-07-27 15:26:22 -04:00
|
|
|
stp[0] = 115.0 * meter_deflect_ppm(-24); // ignored
|
|
|
|
stp[1] = 115.0 * meter_deflect_ppm(-18);
|
|
|
|
stp[2] = 115.0 * meter_deflect_ppm( -9);
|
|
|
|
stp[3] = 115.0 * meter_deflect_ppm( 0); // ignored
|
|
|
|
c[3] = c[2] = c[1];
|
|
|
|
c[6] = c[7] = c[8] = c[9];
|
2013-07-22 12:45:08 -04:00
|
|
|
break;
|
|
|
|
case MeterIEC1NOR:
|
2013-07-27 15:26:22 -04:00
|
|
|
stp[0] = 115.0 * meter_deflect_nordic(-30); // ignored
|
|
|
|
stp[1] = 115.0 * meter_deflect_nordic(-18);
|
2013-07-22 12:45:08 -04:00
|
|
|
stp[2] = 115.0 * meter_deflect_nordic(-12);
|
2013-07-27 15:26:22 -04:00
|
|
|
stp[3] = 115.0 * meter_deflect_nordic( -9); // ignored
|
2013-07-27 16:44:38 -04:00
|
|
|
c[0] = c[1] = c[2]; // bright-green
|
2013-07-27 15:26:22 -04:00
|
|
|
c[6] = c[7] = c[8] = c[9];
|
2013-07-22 12:45:08 -04:00
|
|
|
break;
|
|
|
|
case MeterIEC1DIN:
|
2013-07-27 15:26:22 -04:00
|
|
|
stp[0] = 115.0 * meter_deflect_din(-29); // ignored
|
2013-07-22 12:45:08 -04:00
|
|
|
stp[1] = 115.0 * meter_deflect_din(-18);
|
2013-07-27 15:26:22 -04:00
|
|
|
stp[2] = 115.0 * meter_deflect_din(-15); // ignored
|
2013-07-22 12:45:08 -04:00
|
|
|
stp[3] = 115.0 * meter_deflect_din( -9);
|
2014-09-26 10:10:06 -04:00
|
|
|
c[0] = c[2] = c[3] = c[1];
|
2013-07-27 15:26:22 -04:00
|
|
|
c[4] = c[6];
|
|
|
|
c[5] = c[7];
|
2013-07-22 12:45:08 -04:00
|
|
|
break;
|
|
|
|
case MeterVU:
|
|
|
|
stp[0] = 115.0 * meter_deflect_vu(-26); // -6
|
|
|
|
stp[1] = 115.0 * meter_deflect_vu(-23); // -3
|
|
|
|
stp[2] = 115.0 * meter_deflect_vu(-20); // 0
|
|
|
|
stp[3] = 115.0 * meter_deflect_vu(-18); // +2
|
2014-09-26 10:10:06 -04:00
|
|
|
c[0] = c[2] = c[3] = c[4] = c[5] = c[1];
|
|
|
|
c[7] = c[8] = c[9] = c[6];
|
2013-07-22 12:45:08 -04:00
|
|
|
break;
|
2015-04-25 00:46:56 -04:00
|
|
|
case MeterPeak0dB:
|
2015-04-25 10:09:05 -04:00
|
|
|
stp[1] = 89.125; // 115.0 * log_meter0dB(-9);
|
|
|
|
stp[2] = 106.375; // 115.0 * log_meter0dB(-3);
|
|
|
|
stp[3] = 115.0; // 115.0 * log_meter0dB(0);
|
2015-01-02 09:44:54 -05:00
|
|
|
switch (UIConfiguration::instance().get_meter_line_up_level()) {
|
2015-04-25 00:46:56 -04:00
|
|
|
case MeteringLineUp24:
|
|
|
|
stp[0] = 115.0 * log_meter0dB(-24);
|
|
|
|
break;
|
|
|
|
case MeteringLineUp20:
|
|
|
|
stp[0] = 115.0 * log_meter0dB(-20);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
case MeteringLineUp18:
|
|
|
|
stp[0] = 115.0 * log_meter0dB(-18);
|
|
|
|
break;
|
|
|
|
case MeteringLineUp15:
|
|
|
|
stp[0] = 115.0 * log_meter0dB(-15);
|
|
|
|
}
|
|
|
|
break;
|
2013-07-22 12:45:08 -04:00
|
|
|
default: // PEAK, RMS
|
2015-04-25 10:09:05 -04:00
|
|
|
stp[1] = 77.5; // 115 * log_meter(-9)
|
2013-07-22 12:45:08 -04:00
|
|
|
stp[2] = 92.5; // 115 * log_meter(-3)
|
|
|
|
stp[3] = 100.0; // 115 * log_meter(0)
|
2015-01-02 09:44:54 -05:00
|
|
|
switch (UIConfiguration::instance().get_meter_line_up_level()) {
|
2013-07-22 12:45:08 -04:00
|
|
|
case MeteringLineUp24:
|
|
|
|
stp[0] = 42.0;
|
|
|
|
break;
|
|
|
|
case MeteringLineUp20:
|
|
|
|
stp[0] = 50.0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
case MeteringLineUp18:
|
|
|
|
stp[0] = 55.0;
|
|
|
|
break;
|
|
|
|
case MeteringLineUp15:
|
|
|
|
stp[0] = 62.5;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-05-04 13:05:55 -04:00
|
|
|
}
|
2017-02-24 17:35:26 -05:00
|
|
|
if (meters[n].width != width || meters[n].length != len || color_changed || _meter_type != visible_meter_type || nmidi != midi_count) {
|
2013-07-25 13:55:26 -04:00
|
|
|
bool hl = meters[n].meter ? meters[n].meter->get_highlight() : false;
|
2015-01-08 21:18:43 -05:00
|
|
|
meters[n].packed = false;
|
|
|
|
delete meters[n].meter;
|
2015-01-02 09:44:54 -05:00
|
|
|
meters[n].meter = new FastMeter ((uint32_t) floor (UIConfiguration::instance().get_meter_hold()), width, _meter_orientation, len,
|
2013-07-23 20:46:53 -04:00
|
|
|
c[0], c[1], c[2], c[3], c[4],
|
|
|
|
c[5], c[6], c[7], c[8], c[9],
|
|
|
|
b[0], b[1], b[2], b[3],
|
2013-07-23 20:47:37 -04:00
|
|
|
stp[0], stp[1], stp[2], stp[3],
|
|
|
|
styleflags
|
2013-07-23 20:46:53 -04:00
|
|
|
);
|
2013-07-25 13:55:26 -04:00
|
|
|
meters[n].meter->set_highlight(hl);
|
2007-12-20 18:25:19 -05:00
|
|
|
meters[n].width = width;
|
|
|
|
meters[n].length = len;
|
2011-11-13 10:12:34 -05:00
|
|
|
meters[n].meter->add_events (Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
|
2014-08-28 11:31:57 -04:00
|
|
|
meters[n].meter->signal_button_press_event().connect (sigc::mem_fun (*this, &LevelMeterBase::meter_button_press), false);
|
|
|
|
meters[n].meter->signal_button_release_event().connect (sigc::mem_fun (*this, &LevelMeterBase::meter_button_release), false);
|
2014-12-29 18:00:24 -05:00
|
|
|
}
|
|
|
|
|
2015-01-08 21:18:43 -05:00
|
|
|
//pack_end (*meters[n].meter, false, false);
|
|
|
|
mtr_pack (*meters[n].meter);
|
|
|
|
meters[n].packed = true;
|
2016-05-04 11:36:40 -04:00
|
|
|
if (max_visible_meters == 0 || (uint32_t) n < max_visible_meters + nmidi) {
|
|
|
|
meters[n].meter->show_all ();
|
|
|
|
} else {
|
|
|
|
meters[n].meter->hide ();
|
|
|
|
}
|
2015-01-08 21:18:43 -05:00
|
|
|
}
|
|
|
|
//show();
|
2007-12-20 18:25:19 -05:00
|
|
|
color_changed = false;
|
2017-02-24 17:35:26 -05:00
|
|
|
visible_meter_type = _meter_type;
|
2016-07-22 06:57:14 -04:00
|
|
|
midi_count = nmidi;
|
2016-05-04 11:36:40 -04:00
|
|
|
meter_count = nmeters;
|
2008-04-11 10:06:50 -04:00
|
|
|
}
|
|
|
|
|
2013-07-06 20:00:43 -04:00
|
|
|
void
|
2017-02-24 17:35:26 -05:00
|
|
|
LevelMeterBase::set_meter_type(MeterType t)
|
2013-07-06 20:00:43 -04:00
|
|
|
{
|
2017-02-24 17:35:26 -05:00
|
|
|
_meter_type = t;
|
2013-07-06 20:00:43 -04:00
|
|
|
_meter->set_type(t);
|
|
|
|
}
|
|
|
|
|
2011-11-13 10:12:34 -05:00
|
|
|
bool
|
2013-07-25 08:18:39 -04:00
|
|
|
LevelMeterBase::meter_button_press (GdkEventButton* ev)
|
2011-11-13 10:12:34 -05:00
|
|
|
{
|
2015-04-28 08:32:59 -04:00
|
|
|
return static_cast<bool>(ButtonPress (ev)); /* EMIT SIGNAL */
|
2011-11-13 10:12:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-25 08:18:39 -04:00
|
|
|
LevelMeterBase::meter_button_release (GdkEventButton* ev)
|
2008-04-11 10:06:50 -04:00
|
|
|
{
|
|
|
|
if (ev->button == 1) {
|
2013-07-06 20:52:37 -04:00
|
|
|
clear_meters (false);
|
2008-04-11 10:06:50 -04:00
|
|
|
}
|
2013-07-29 13:42:41 -04:00
|
|
|
ButtonRelease(ev);
|
2011-11-13 10:12:34 -05:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
return true;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-12-20 18:25:19 -05:00
|
|
|
|
2013-07-25 08:18:39 -04:00
|
|
|
void LevelMeterBase::clear_meters (bool reset_highlight)
|
2007-12-20 18:25:19 -05:00
|
|
|
{
|
|
|
|
for (vector<MeterInfo>::iterator i = meters.begin(); i < meters.end(); i++) {
|
|
|
|
(*i).meter->clear();
|
2013-07-06 10:32:36 -04:00
|
|
|
(*i).max_peak = minus_infinity();
|
2013-07-06 20:52:37 -04:00
|
|
|
if (reset_highlight)
|
|
|
|
(*i).meter->set_highlight(false);
|
2007-12-20 18:25:19 -05:00
|
|
|
}
|
2008-04-11 10:06:50 -04:00
|
|
|
max_peak = minus_infinity();
|
2007-12-20 18:25:19 -05:00
|
|
|
}
|
|
|
|
|
2013-07-25 08:18:39 -04:00
|
|
|
void LevelMeterBase::hide_meters ()
|
2007-12-20 18:25:19 -05:00
|
|
|
{
|
|
|
|
hide_all_meters();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-07-25 08:18:39 -04:00
|
|
|
LevelMeterBase::color_handler ()
|
2007-12-20 18:25:19 -05:00
|
|
|
{
|
|
|
|
color_changed = true;
|
2013-07-29 10:31:33 -04:00
|
|
|
setup_meters (meter_length, regular_meter_width, thin_meter_width);
|
2007-12-20 18:25:19 -05:00
|
|
|
}
|
|
|
|
|
2013-07-25 08:18:39 -04:00
|
|
|
LevelMeterHBox::LevelMeterHBox(Session* s)
|
2013-07-28 14:43:21 -04:00
|
|
|
: LevelMeterBase(s, invalidator(*this))
|
2013-07-25 08:18:39 -04:00
|
|
|
{
|
|
|
|
set_spacing(1);
|
|
|
|
show();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LevelMeterHBox::~LevelMeterHBox() {}
|
|
|
|
|
|
|
|
void
|
|
|
|
LevelMeterHBox::mtr_pack(Gtk::Widget &w) {
|
|
|
|
pack_end (w, false, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
LevelMeterHBox::mtr_remove(Gtk::Widget &w) {
|
|
|
|
remove (w);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LevelMeterVBox::LevelMeterVBox(Session* s)
|
2013-07-28 14:43:21 -04:00
|
|
|
: LevelMeterBase(s, invalidator(*this), FastMeter::Horizontal)
|
2013-07-25 08:18:39 -04:00
|
|
|
{
|
|
|
|
set_spacing(1);
|
|
|
|
show();
|
|
|
|
}
|
|
|
|
LevelMeterVBox::~LevelMeterVBox() {}
|
|
|
|
|
|
|
|
void
|
|
|
|
LevelMeterVBox::mtr_pack(Gtk::Widget &w) {
|
|
|
|
pack_end (w, false, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
LevelMeterVBox::mtr_remove(Gtk::Widget &w) {
|
|
|
|
remove (w);
|
|
|
|
}
|