summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2013-07-15 15:00:22 +0200
committerRobin Gareus <robin@gareus.org>2013-07-15 15:04:36 +0200
commit80aa2574819e947668092c660d767e25a661c6f1 (patch)
tree04267e2361d995787f0ccdd0e544264788517fff
parent9b1d7fd2f7c9167d9d7b7aa3115497ab65747877 (diff)
add VU and IEC meter DSP (from jmeters)
-rw-r--r--gtk2_ardour/meter_patterns.cc9
-rw-r--r--gtk2_ardour/meter_strip.cc3
-rw-r--r--gtk2_ardour/mixer_strip.cc3
-rw-r--r--libs/ardour/ardour/iec1ppmdsp.h51
-rw-r--r--libs/ardour/ardour/iec2ppmdsp.h51
-rw-r--r--libs/ardour/ardour/kmeterdsp.h (renamed from libs/ardour/kmeterdsp.h)5
-rw-r--r--libs/ardour/ardour/meter.h10
-rw-r--r--libs/ardour/ardour/types.h5
-rw-r--r--libs/ardour/ardour/vumeterdsp.h49
-rw-r--r--libs/ardour/iec1ppmdsp.cc100
-rw-r--r--libs/ardour/iec2ppmdsp.cc100
-rw-r--r--libs/ardour/kmeterdsp.cc23
-rw-r--r--libs/ardour/meter.cc93
-rw-r--r--libs/ardour/vumeterdsp.cc89
-rw-r--r--libs/ardour/wscript3
15 files changed, 567 insertions, 27 deletions
diff --git a/gtk2_ardour/meter_patterns.cc b/gtk2_ardour/meter_patterns.cc
index 80655af7b9..ccf24fcefc 100644
--- a/gtk2_ardour/meter_patterns.cc
+++ b/gtk2_ardour/meter_patterns.cc
@@ -64,6 +64,15 @@ ArdourMeter::meter_type_string (ARDOUR::MeterType mt)
case MeterKrms:
return _("RMS + Peak");
break;
+ case MeterIEC1:
+ return _("DIN");
+ break;
+ case MeterIEC2:
+ return _("EBU/BBC");
+ break;
+ case MeterVU:
+ return _("VU");
+ break;
default:
return _("???");
break;
diff --git a/gtk2_ardour/meter_strip.cc b/gtk2_ardour/meter_strip.cc
index 44144114a4..3a8410867a 100644
--- a/gtk2_ardour/meter_strip.cc
+++ b/gtk2_ardour/meter_strip.cc
@@ -573,6 +573,9 @@ MeterStrip::popup_level_meter_menu (GdkEventButton* ev)
_suspend_menu_callbacks = true;
add_level_meter_item (items, group, ArdourMeter::meter_type_string(MeterPeak), MeterPeak);
add_level_meter_item (items, group, ArdourMeter::meter_type_string(MeterKrms), MeterKrms);
+ add_level_meter_item (items, group, ArdourMeter::meter_type_string(MeterIEC1), MeterIEC1);
+ add_level_meter_item (items, group, ArdourMeter::meter_type_string(MeterIEC2), MeterIEC2);
+ add_level_meter_item (items, group, ArdourMeter::meter_type_string(MeterVU), MeterVU);
MeterType cmt = _route->meter_type();
const std::string cmn = ArdourMeter::meter_type_string(cmt);
diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc
index 6128780cf0..dec072b067 100644
--- a/gtk2_ardour/mixer_strip.cc
+++ b/gtk2_ardour/mixer_strip.cc
@@ -2135,6 +2135,9 @@ MixerStrip::popup_level_meter_menu (GdkEventButton* ev)
add_level_meter_item_type (items, tgroup, ArdourMeter::meter_type_string(MeterPeak), MeterPeak);
add_level_meter_item_type (items, tgroup, ArdourMeter::meter_type_string(MeterKrms), MeterKrms);
+ add_level_meter_item_type (items, tgroup, ArdourMeter::meter_type_string(MeterIEC1), MeterIEC1);
+ add_level_meter_item_type (items, tgroup, ArdourMeter::meter_type_string(MeterIEC2), MeterIEC2);
+ add_level_meter_item_type (items, tgroup, ArdourMeter::meter_type_string(MeterVU), MeterVU);
int _strip_type;
if (_route->is_master()) {
diff --git a/libs/ardour/ardour/iec1ppmdsp.h b/libs/ardour/ardour/iec1ppmdsp.h
new file mode 100644
index 0000000000..58dea97555
--- /dev/null
+++ b/libs/ardour/ardour/iec1ppmdsp.h
@@ -0,0 +1,51 @@
+/*
+ Copyright (C) 2012 Fons Adriaensen <fons@linuxaudio.org>
+ Adopted for Ardour 2013 by Robin Gareus <robin@gareus.org>
+
+ 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.
+*/
+
+#ifndef __IEC1PPMDSP_H
+#define __IEC1PPMDSP_H
+
+
+class Iec1ppmdsp
+{
+public:
+
+ Iec1ppmdsp (void);
+ ~Iec1ppmdsp (void);
+
+ void process (float *p, int n);
+ float read (void);
+ void reset ();
+
+ static void init (float fsamp);
+
+private:
+
+ float _z1; // filter state
+ float _z2; // filter state
+ float _m; // max value since last read()
+ bool _res; // flag to reset m
+
+ static float _w1; // attack filter coefficient
+ static float _w2; // attack filter coefficient
+ static float _w3; // release filter coefficient
+ static float _g; // gain factor
+};
+
+
+#endif
diff --git a/libs/ardour/ardour/iec2ppmdsp.h b/libs/ardour/ardour/iec2ppmdsp.h
new file mode 100644
index 0000000000..3574a8bd3f
--- /dev/null
+++ b/libs/ardour/ardour/iec2ppmdsp.h
@@ -0,0 +1,51 @@
+/*
+ Copyright (C) 2012 Fons Adriaensen <fons@linuxaudio.org>
+ Adopted for Ardour 2013 by Robin Gareus <robin@gareus.org>
+
+ 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.
+*/
+
+#ifndef __IEC2PPMDSP_H
+#define __IEC2PPMDSP_H
+
+
+class Iec2ppmdsp
+{
+public:
+
+ Iec2ppmdsp (void);
+ ~Iec2ppmdsp (void);
+
+ void process (float *p, int n);
+ float read (void);
+ void reset ();
+
+ static void init (float fsamp);
+
+private:
+
+ float _z1; // filter state
+ float _z2; // filter state
+ float _m; // max value since last read()
+ bool _res; // flag to reset m
+
+ static float _w1; // attack filter coefficient
+ static float _w2; // attack filter coefficient
+ static float _w3; // release filter coefficient
+ static float _g; // gain factor
+};
+
+
+#endif
diff --git a/libs/ardour/kmeterdsp.h b/libs/ardour/ardour/kmeterdsp.h
index 9c2309e09c..eca3c76695 100644
--- a/libs/ardour/kmeterdsp.h
+++ b/libs/ardour/ardour/kmeterdsp.h
@@ -1,6 +1,6 @@
/*
Copyright (C) 2008-2011 Fons Adriaensen <fons@linuxaudio.org>
- Adopted for Ardour 2013 by Robin Gareus <robin@gareus.org>
+ Adopted for Ardour 2013 by Robin Gareus <robin@gareus.org>
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
@@ -29,9 +29,10 @@ public:
void process (float *p, int n);
float read ();
- static void init (int fsamp);
void reset ();
+ static void init (int fsamp);
+
private:
float _z1; // filter state
diff --git a/libs/ardour/ardour/meter.h b/libs/ardour/ardour/meter.h
index 31ebc76179..4ac140fd04 100644
--- a/libs/ardour/ardour/meter.h
+++ b/libs/ardour/ardour/meter.h
@@ -23,7 +23,11 @@
#include "ardour/types.h"
#include "ardour/processor.h"
#include "pbd/fastlog.h"
-#include "kmeterdsp.h"
+
+#include "ardour/kmeterdsp.h"
+#include "ardour/iec1ppmdsp.h"
+#include "ardour/iec2ppmdsp.h"
+#include "ardour/vumeterdsp.h"
namespace ARDOUR {
@@ -104,7 +108,11 @@ private:
std::vector<float> _visible_peak_power;
std::vector<float> _max_peak_signal;
std::vector<float> _max_peak_power;
+
std::vector<Kmeterdsp *> _kmeter;
+ std::vector<Iec1ppmdsp *> _iec1meter;
+ std::vector<Iec2ppmdsp *> _iec2meter;
+ std::vector<Vumeterdsp *> _vumeter;
MeterType _meter_type;
};
diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h
index 05d6d0b27d..df7209b581 100644
--- a/libs/ardour/ardour/types.h
+++ b/libs/ardour/ardour/types.h
@@ -181,7 +181,10 @@ namespace ARDOUR {
MeterMaxSignal = 0x01,
MeterMaxPeak = 0x02,
MeterPeak = 0x04,
- MeterKrms = 0x08
+ MeterKrms = 0x08,
+ MeterIEC1 = 0x10,
+ MeterIEC2 = 0x20,
+ MeterVU = 0x40
};
enum TrackMode {
diff --git a/libs/ardour/ardour/vumeterdsp.h b/libs/ardour/ardour/vumeterdsp.h
new file mode 100644
index 0000000000..86487e8e8e
--- /dev/null
+++ b/libs/ardour/ardour/vumeterdsp.h
@@ -0,0 +1,49 @@
+/*
+ Copyright (C) 2012 Fons Adriaensen <fons@linuxaudio.org>
+ Adopted for Ardour 2013 by Robin Gareus <robin@gareus.org>
+
+ 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.
+*/
+
+#ifndef __VUMETERDSP_H
+#define __VUMETERDSP_H
+
+
+class Vumeterdsp
+{
+public:
+
+ Vumeterdsp (void);
+ ~Vumeterdsp (void);
+
+ void process (float *p, int n);
+ float read (void);
+ void reset ();
+
+ static void init (float fsamp);
+
+private:
+
+ float _z1; // filter state
+ float _z2; // filter state
+ float _m; // max value since last read()
+ bool _res; // flag to reset m
+
+ static float _w; // lowpass filter coefficient
+ static float _g; // gain factor
+};
+
+
+#endif
diff --git a/libs/ardour/iec1ppmdsp.cc b/libs/ardour/iec1ppmdsp.cc
new file mode 100644
index 0000000000..bed825048f
--- /dev/null
+++ b/libs/ardour/iec1ppmdsp.cc
@@ -0,0 +1,100 @@
+/*
+ Copyright (C) 2012 Fons Adriaensen <fons@linuxaudio.org>
+ Adopted for Ardour 2013 by Robin Gareus <robin@gareus.org>
+
+ 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 <math.h>
+#include "ardour/iec1ppmdsp.h"
+
+
+float Iec1ppmdsp::_w1;
+float Iec1ppmdsp::_w2;
+float Iec1ppmdsp::_w3;
+float Iec1ppmdsp::_g;
+
+
+Iec1ppmdsp::Iec1ppmdsp (void) :
+ _z1 (0),
+ _z2 (0),
+ _m (0),
+ _res (true)
+{
+}
+
+
+Iec1ppmdsp::~Iec1ppmdsp (void)
+{
+}
+
+
+void Iec1ppmdsp::process (float *p, int n)
+{
+ float z1, z2, m, t;
+
+ z1 = _z1;
+ z2 = _z2;
+ m = _res ? 0: _m;
+ _res = false;
+
+ n /= 4;
+ while (n--)
+ {
+ z1 *= _w3;
+ z2 *= _w3;
+ t = fabsf (*p++);
+ if (t > z1) z1 += _w1 * (t - z1);
+ if (t > z2) z2 += _w2 * (t - z2);
+ t = fabsf (*p++);
+ if (t > z1) z1 += _w1 * (t - z1);
+ if (t > z2) z2 += _w2 * (t - z2);
+ t = fabsf (*p++);
+ if (t > z1) z1 += _w1 * (t - z1);
+ if (t > z2) z2 += _w2 * (t - z2);
+ t = fabsf (*p++);
+ if (t > z1) z1 += _w1 * (t - z1);
+ if (t > z2) z2 += _w2 * (t - z2);
+ t = z1 + z2;
+ if (t > m) m = t;
+ }
+
+ _z1 = z1 + 1e-10f;
+ _z2 = z2 + 1e-10f;
+ _m = m;
+}
+
+
+float Iec1ppmdsp::read (void)
+{
+ _res = true;
+ return _g * _m;
+}
+
+void Iec1ppmdsp::reset ()
+{
+ _z1 = _z2 = _m = .0f;
+ _res = true;
+}
+
+void Iec1ppmdsp::init (float fsamp)
+{
+ _w1 = 450.0f / fsamp;
+ _w2 = 1300.0f / fsamp;
+ _w3 = 1.0f - 5.4f / fsamp;
+ _g = 0.5108f;
+}
+
+/* vi:set ts=8 sts=8 sw=4: */
diff --git a/libs/ardour/iec2ppmdsp.cc b/libs/ardour/iec2ppmdsp.cc
new file mode 100644
index 0000000000..76862cccd2
--- /dev/null
+++ b/libs/ardour/iec2ppmdsp.cc
@@ -0,0 +1,100 @@
+/*
+ Copyright (C) 2012 Fons Adriaensen <fons@linuxaudio.org>
+ Adopted for Ardour 2013 by Robin Gareus <robin@gareus.org>
+
+ 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 <math.h>
+#include "ardour/iec2ppmdsp.h"
+
+
+float Iec2ppmdsp::_w1;
+float Iec2ppmdsp::_w2;
+float Iec2ppmdsp::_w3;
+float Iec2ppmdsp::_g;
+
+
+Iec2ppmdsp::Iec2ppmdsp (void) :
+ _z1 (0),
+ _z2 (0),
+ _m (0),
+ _res (true)
+{
+}
+
+
+Iec2ppmdsp::~Iec2ppmdsp (void)
+{
+}
+
+
+void Iec2ppmdsp::process (float *p, int n)
+{
+ float z1, z2, m, t;
+
+ z1 = _z1;
+ z2 = _z2;
+ m = _res ? 0: _m;
+ _res = false;
+
+ n /= 4;
+ while (n--)
+ {
+ z1 *= _w3;
+ z2 *= _w3;
+ t = fabsf (*p++);
+ if (t > z1) z1 += _w1 * (t - z1);
+ if (t > z2) z2 += _w2 * (t - z2);
+ t = fabsf (*p++);
+ if (t > z1) z1 += _w1 * (t - z1);
+ if (t > z2) z2 += _w2 * (t - z2);
+ t = fabsf (*p++);
+ if (t > z1) z1 += _w1 * (t - z1);
+ if (t > z2) z2 += _w2 * (t - z2);
+ t = fabsf (*p++);
+ if (t > z1) z1 += _w1 * (t - z1);
+ if (t > z2) z2 += _w2 * (t - z2);
+ t = z1 + z2;
+ if (t > m) m = t;
+ }
+
+ _z1 = z1 + 1e-10f;
+ _z2 = z2 + 1e-10f;
+ _m = m;
+}
+
+
+float Iec2ppmdsp::read (void)
+{
+ _res = true;
+ return _g * _m;
+}
+
+void Iec2ppmdsp::reset ()
+{
+ _z1 = _z2 = _m = .0f;
+ _res = true;
+}
+
+void Iec2ppmdsp::init (float fsamp)
+{
+ _w1 = 200.0f / fsamp;
+ _w2 = 860.0f / fsamp;
+ _w3 = 1.0f - 4.0f / fsamp;
+ _g = 0.5141f;
+}
+
+/* vi:set ts=8 sts=8 sw=4: */
diff --git a/libs/ardour/kmeterdsp.cc b/libs/ardour/kmeterdsp.cc
index 77d1a87a81..2490ae34ec 100644
--- a/libs/ardour/kmeterdsp.cc
+++ b/libs/ardour/kmeterdsp.cc
@@ -1,6 +1,6 @@
/*
Copyright (C) 2008-2011 Fons Adriaensen <fons@linuxaudio.org>
- Adopted for Ardour 2013 by Robin Gareus <robin@gareus.org>
+ Adopted for Ardour 2013 by Robin Gareus <robin@gareus.org>
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
@@ -17,12 +17,13 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
#include <math.h>
-#include "kmeterdsp.h"
+#include "ardour/kmeterdsp.h"
+
float Kmeterdsp::_omega;
+
Kmeterdsp::Kmeterdsp (void) :
_z1 (0),
_z2 (0),
@@ -36,6 +37,10 @@ Kmeterdsp::~Kmeterdsp (void)
{
}
+void Kmeterdsp::init (int fsamp)
+{
+ _omega = 9.72f / fsamp; // ballistic filter coefficient
+}
void Kmeterdsp::process (float *p, int n)
{
@@ -93,7 +98,6 @@ void Kmeterdsp::process (float *p, int n)
if (s > _rms) _rms = s;
}
-
/* Returns highest _rms value since last call */
float Kmeterdsp::read ()
{
@@ -102,15 +106,10 @@ float Kmeterdsp::read ()
return rv;
}
-void Kmeterdsp::init (int fsamp)
-{
- _omega = 9.72f / fsamp; // ballistic filter coefficient
-}
-
void Kmeterdsp::reset ()
{
- _z1 = _z2 = _rms = 0.0;
- _flag=false;
+ _z1 = _z2 = _rms = .0f;
+ _flag = false;
}
-/* vi:set ts=8 sts=8 sw=8: */
+/* vi:set ts=8 sts=8 sw=4: */
diff --git a/libs/ardour/meter.cc b/libs/ardour/meter.cc
index f239a1c4b7..383a5bdfad 100644
--- a/libs/ardour/meter.cc
+++ b/libs/ardour/meter.cc
@@ -40,13 +40,22 @@ PeakMeter::PeakMeter (Session& s, const std::string& name)
: Processor (s, string_compose ("meter-%1", name))
{
Kmeterdsp::init(s.nominal_frame_rate());
+ Iec1ppmdsp::init(s.nominal_frame_rate());
+ Iec2ppmdsp::init(s.nominal_frame_rate());
+ Vumeterdsp::init(s.nominal_frame_rate());
}
PeakMeter::~PeakMeter ()
{
while (_kmeter.size() > 0) {
delete (_kmeter.back());
+ delete (_iec1meter.back());
+ delete (_iec2meter.back());
+ delete (_vumeter.back());
_kmeter.pop_back();
+ _iec1meter.pop_back();
+ _iec2meter.pop_back();
+ _vumeter.pop_back();
}
}
@@ -100,6 +109,15 @@ PeakMeter::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end_fr
if (_meter_type & MeterKrms) {
_kmeter[i]->process(bufs.get_audio(i).data(), nframes);
}
+ if (_meter_type & MeterIEC1) {
+ _iec1meter[i]->process(bufs.get_audio(i).data(), nframes);
+ }
+ if (_meter_type & MeterIEC2) {
+ _iec2meter[i]->process(bufs.get_audio(i).data(), nframes);
+ }
+ if (_meter_type & MeterVU) {
+ _vumeter[i]->process(bufs.get_audio(i).data(), nframes);
+ }
}
// Zero any excess peaks
@@ -167,6 +185,9 @@ PeakMeter::reflect_inputs (const ChanCount& in)
for (size_t n = 0; n < n_audio; ++n) {
_kmeter[n]->reset();
+ _iec1meter[n]->reset();
+ _iec2meter[n]->reset();
+ _vumeter[n]->reset();
}
reset_max();
@@ -202,12 +223,24 @@ PeakMeter::reset_max_channels (const ChanCount& chn)
/* alloc/free other audio-only meter types. */
while (_kmeter.size() > n_audio) {
delete (_kmeter.back());
+ delete (_iec1meter.back());
+ delete (_iec2meter.back());
+ delete (_vumeter.back());
_kmeter.pop_back();
+ _iec1meter.pop_back();
+ _iec2meter.pop_back();
+ _vumeter.pop_back();
}
while (_kmeter.size() < n_audio) {
_kmeter.push_back(new Kmeterdsp());
+ _iec1meter.push_back(new Iec1ppmdsp());
+ _iec2meter.push_back(new Iec2ppmdsp());
+ _vumeter.push_back(new Vumeterdsp());
}
assert(_kmeter.size() == n_audio);
+ assert(_iec1meter.size() == n_audio);
+ assert(_iec2meter.size() == n_audio);
+ assert(_vumeter.size() == n_audio);
}
/** To be driven by the Meter signal from IO.
@@ -279,32 +312,51 @@ PeakMeter::meter_level(uint32_t n, MeterType type) {
switch (type) {
case MeterKrms:
{
- const uint32_t n_midi = current_meters.n_midi();
+ const uint32_t n_midi = current_meters.n_midi();
if ((n - n_midi) < _kmeter.size() && (n - n_midi) >= 0) {
-#if 0
- return fast_coefficient_to_dB (_kmeter[n-n_midi]->read());
-#else
- return accurate_coefficient_to_dB (_kmeter[n-n_midi]->read());
-#endif
+ return accurate_coefficient_to_dB (_kmeter[n - n_midi]->read());
+ }
+ }
+ break;
+ case MeterIEC1:
+ {
+ const uint32_t n_midi = current_meters.n_midi();
+ if ((n - n_midi) < _iec1meter.size() && (n - n_midi) >= 0) {
+ return accurate_coefficient_to_dB (_iec1meter[n - n_midi]->read());
+ }
+ }
+ break;
+ case MeterIEC2:
+ {
+ const uint32_t n_midi = current_meters.n_midi();
+ if ((n - n_midi) < _iec2meter.size() && (n - n_midi) >= 0) {
+ return accurate_coefficient_to_dB (_iec2meter[n - n_midi]->read());
}
- return minus_infinity();
}
+ break;
+ case MeterVU:
+ {
+ const uint32_t n_midi = current_meters.n_midi();
+ if ((n - n_midi) < _vumeter.size() && (n - n_midi) >= 0) {
+ return accurate_coefficient_to_dB (_vumeter[n - n_midi]->read());
+ }
+ }
+ break;
case MeterPeak:
return peak_power(n);
case MeterMaxSignal:
if (n < _max_peak_signal.size()) {
return _max_peak_signal[n];
- } else {
- return minus_infinity();
}
+ break;
default:
case MeterMaxPeak:
if (n < _max_peak_power.size()) {
return _max_peak_power[n];
- } else {
- return minus_infinity();
}
+ break;
}
+ return minus_infinity();
}
void
@@ -322,6 +374,25 @@ PeakMeter::set_type(MeterType t)
_kmeter[n]->reset();
}
}
+ if (t & MeterIEC1) {
+ const size_t n_audio = current_meters.n_audio();
+ for (size_t n = 0; n < n_audio; ++n) {
+ _iec1meter[n]->reset();
+ }
+ }
+ if (t & MeterIEC2) {
+ const size_t n_audio = current_meters.n_audio();
+ for (size_t n = 0; n < n_audio; ++n) {
+ _iec2meter[n]->reset();
+ }
+ }
+ if (t & MeterVU) {
+ const size_t n_audio = current_meters.n_audio();
+ for (size_t n = 0; n < n_audio; ++n) {
+ _vumeter[n]->reset();
+ }
+ }
+
TypeChanged(t);
}
diff --git a/libs/ardour/vumeterdsp.cc b/libs/ardour/vumeterdsp.cc
new file mode 100644
index 0000000000..67d48f6c54
--- /dev/null
+++ b/libs/ardour/vumeterdsp.cc
@@ -0,0 +1,89 @@
+/*
+ Copyright (C) 2012 Fons Adriaensen <fons@linuxaudio.org>
+ Adopted for Ardour 2013 by Robin Gareus <robin@gareus.org>
+
+ 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 <math.h>
+#include "ardour/vumeterdsp.h"
+
+
+float Vumeterdsp::_w;
+float Vumeterdsp::_g;
+
+
+Vumeterdsp::Vumeterdsp (void) :
+ _z1 (0),
+ _z2 (0),
+ _m (0),
+ _res (true)
+{
+}
+
+
+Vumeterdsp::~Vumeterdsp (void)
+{
+}
+
+
+void Vumeterdsp::process (float *p, int n)
+{
+ float z1, z2, m, t1, t2;
+
+ z1 = _z1;
+ z2 = _z2;
+ m = _res ? 0: _m;
+ _res = false;
+
+ n /= 4;
+ while (n--)
+ {
+ t2 = z2 / 2;
+ t1 = fabsf (*p++) - t2;
+ z1 += _w * (t1 - z1);
+ t1 = fabsf (*p++) - t2;
+ z1 += _w * (t1 - z1);
+ t1 = fabsf (*p++) - t2;
+ z1 += _w * (t1 - z1);
+ t1 = fabsf (*p++) - t2;
+ z1 += _w * (t1 - z1);
+ z2 += 4 * _w * (z1 - z2);
+ if (z2 > m) m = z2;
+ }
+
+ _z1 = z1;
+ _z2 = z2 + 1e-10f;
+ _m = m;
+}
+
+
+float Vumeterdsp::read (void)
+{
+ _res = true;
+ return _g * _m;
+}
+
+void Vumeterdsp::reset ()
+{
+ _z1 = _z2 = _m = .0f;
+ _res = true;
+}
+
+void Vumeterdsp::init (float fsamp)
+{
+ _w = 11.1f / fsamp;
+ _g = 1.5f * 1.571f;
+}
diff --git a/libs/ardour/wscript b/libs/ardour/wscript
index 4e7e23aa1a..ea08636ea8 100644
--- a/libs/ardour/wscript
+++ b/libs/ardour/wscript
@@ -91,6 +91,8 @@ libardour_sources = [
'globals.cc',
'graph.cc',
'graphnode.cc',
+ 'iec1ppmdsp.cc',
+ 'iec2ppmdsp.cc',
'import.cc',
'instrument_info.cc',
'internal_return.cc',
@@ -206,6 +208,7 @@ libardour_sources = [
'user_bundle.cc',
'utils.cc',
'version.cc',
+ 'vumeterdsp.cc',
'worker.cc'
]