Revert "Revert new meter types (postponed until after 3.3 release)"
authorRobin Gareus <robin@gareus.org>
Mon, 22 Jul 2013 16:42:01 +0000 (18:42 +0200)
committerRobin Gareus <robin@gareus.org>
Mon, 22 Jul 2013 16:42:01 +0000 (18:42 +0200)
This reverts commit d80f672e8487f459d76ab291958bffcded08f0fd.

17 files changed:
gtk2_ardour/meter_patterns.cc
gtk2_ardour/meter_strip.cc
gtk2_ardour/mixer_strip.cc
libs/ardour/ardour/iec1ppmdsp.h [new file with mode: 0644]
libs/ardour/ardour/iec2ppmdsp.h [new file with mode: 0644]
libs/ardour/ardour/kmeterdsp.h [new file with mode: 0644]
libs/ardour/ardour/meter.h
libs/ardour/ardour/types.h
libs/ardour/ardour/vumeterdsp.h [new file with mode: 0644]
libs/ardour/enums.cc
libs/ardour/iec1ppmdsp.cc [new file with mode: 0644]
libs/ardour/iec2ppmdsp.cc [new file with mode: 0644]
libs/ardour/kmeterdsp.cc
libs/ardour/kmeterdsp.h [deleted file]
libs/ardour/meter.cc
libs/ardour/vumeterdsp.cc [new file with mode: 0644]
libs/ardour/wscript

index 35ba8491bef8db837a16357ac0e1f907858adb44..d658a0b3ef8c6e248cafc43c81ecc9e6d6bc8c26 100644 (file)
@@ -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;
index 44144114a4dad2cbc167d2d238fb26c180678854..3a8410867af565cfe8f1e277d86163ff9e1b1823 100644 (file)
@@ -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);
index 6128780cf03dda5837d9d8f175467f5549ff19c5..dec072b067fa68f430a95677e82c0d2f896760bb 100644 (file)
@@ -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 (file)
index 0000000..58dea97
--- /dev/null
@@ -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 (file)
index 0000000..3574a8b
--- /dev/null
@@ -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/ardour/kmeterdsp.h b/libs/ardour/ardour/kmeterdsp.h
new file mode 100644 (file)
index 0000000..eca3c76
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+    Copyright (C) 2008-2011 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 __KMETERDSP_H
+#define        __KMETERDSP_H
+
+class Kmeterdsp
+{
+public:
+
+    Kmeterdsp (void);
+    ~Kmeterdsp (void);
+
+    void process (float *p, int n);
+    float read ();
+    void reset ();
+
+    static void init (int fsamp);
+
+private:
+
+    float          _z1;          // filter state
+    float          _z2;          // filter state
+    float          _rms;         // max rms value since last read()
+    bool           _flag;        // flag set by read(), resets _rms
+
+    static float   _omega;       // ballistics filter constant.
+};
+
+#endif
index 31ebc76179800e925656f6548ee0b0b0dfc48038..4ac140fd04d75661b66032811888283b5f8d4d78 100644 (file)
 #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;
 };
index 05d6d0b27d47563ca2950c5785f3afec74eda217..df7209b5810e96a5019888ad809d1fcc1c0ce6e1 100644 (file)
@@ -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 (file)
index 0000000..86487e8
--- /dev/null
@@ -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
index 495ff0b4c350d5e1e953bc17b04f53513edce7e2..12eb59ce65c2b0ae9bbf4dbf4d52d408eab500fb 100644 (file)
@@ -177,6 +177,9 @@ setup_enum_writer ()
        REGISTER_ENUM (MeterMaxPeak);
        REGISTER_ENUM (MeterPeak);
        REGISTER_ENUM (MeterKrms);
+       REGISTER_ENUM (MeterIEC1);
+       REGISTER_ENUM (MeterIEC2);
+       REGISTER_ENUM (MeterVU);
        REGISTER (_MeterType);
 
        REGISTER_ENUM (Normal);
diff --git a/libs/ardour/iec1ppmdsp.cc b/libs/ardour/iec1ppmdsp.cc
new file mode 100644 (file)
index 0000000..bed8250
--- /dev/null
@@ -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 (file)
index 0000000..76862cc
--- /dev/null
@@ -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: */
index afd0f71719c0397046e5cf793e5ef86243cb6b2a..d4460f94cb8fe843fb886d7c8c1e07e3def3c272 100644 (file)
@@ -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
     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)
 {
@@ -96,7 +101,6 @@ void Kmeterdsp::process (float *p, int n)
     }
 }
 
-
 /* Returns highest _rms value since last call */
 float Kmeterdsp::read ()
 {
@@ -105,15 +109,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/kmeterdsp.h b/libs/ardour/kmeterdsp.h
deleted file mode 100644 (file)
index 9c2309e..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-    Copyright (C) 2008-2011 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 __KMETERDSP_H
-#define        __KMETERDSP_H
-
-class Kmeterdsp
-{
-public:
-
-    Kmeterdsp (void);
-    ~Kmeterdsp (void);
-
-    void process (float *p, int n);
-    float read ();
-    static void init (int fsamp);
-    void reset ();
-
-private:
-
-    float          _z1;          // filter state
-    float          _z2;          // filter state
-    float          _rms;         // max rms value since last read()
-    bool           _flag;        // flag set by read(), resets _rms
-
-    static float   _omega;       // ballistics filter constant.
-};
-
-#endif
index 961a489a631b7669af26d2cad28d505edb0ca48c..3ca19afe7637bd0ca57a228ac57b63139337d32f 100644 (file)
@@ -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
@@ -119,6 +137,9 @@ PeakMeter::reset ()
 
        for (size_t n = 0; n < _kmeter.size(); ++n) {
                _kmeter[n]->reset();
+               _iec1meter[n]->reset();
+               _iec2meter[n]->reset();
+               _vumeter[n]->reset();
        }
 }
 
@@ -212,12 +233,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);
 
        reset();
        reset_max();
@@ -292,32 +325,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
@@ -335,6 +387,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 (file)
index 0000000..67d48f6
--- /dev/null
@@ -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;
+}
index 4e7e23aa1a2e412273b41ac5b681cc1e98784653..ea08636ea8290259eb8e3f1719cf7d765cb727ab 100644 (file)
@@ -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'
 ]