2 Copyright (C) 2006 Paul Davis
4 This program is free software; you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2 of the License, or (at your option)
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 675 Mass Ave, Cambridge, MA 02139, USA.
19 #ifndef __ardour_meter_h__
20 #define __ardour_meter_h__
23 #include "ardour/types.h"
24 #include "ardour/processor.h"
25 #include "pbd/fastlog.h"
27 #include "ardour/kmeterdsp.h"
28 #include "ardour/iec1ppmdsp.h"
29 #include "ardour/iec2ppmdsp.h"
30 #include "ardour/vumeterdsp.h"
40 static void update_meters ();
41 static PBD::Signal0<void> Meter;
44 /* this object is not meant to be instantiated */
48 /** Meters peaks on the input and stores them for access.
50 class PeakMeter : public Processor {
52 PeakMeter(Session& s, const std::string& name);
59 bool can_support_io_configuration (const ChanCount& in, ChanCount& out);
60 bool configure_io (ChanCount in, ChanCount out);
62 /* special method for meter, to ensure that it can always handle the maximum
63 number of streams in the route, no matter where we put it.
66 void reset_max_channels (const ChanCount&);
68 /* tell the meter than no matter how many channels it can handle,
69 `in' is the number it is actually going be handling from
73 void reflect_inputs (const ChanCount& in);
76 void run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, bool);
79 void deactivate () { }
81 ChanCount input_streams () const { return current_meters; }
82 ChanCount output_streams () const { return current_meters; }
84 float peak_power (uint32_t n) {
85 if (n < _visible_peak_power.size()) {
86 return _visible_peak_power[n];
88 return minus_infinity();
92 float meter_level (uint32_t n, MeterType type);
94 void set_type(MeterType t);
95 MeterType get_type() { return _meter_type; }
97 XMLNode& state (bool full);
99 PBD::Signal1<void, MeterType> TypeChanged;
104 /** The number of meters that we are currently handling;
105 * may be different to _configured_input and _configured_output
106 * as it can be altered outside a ::configure_io by ::reflect_inputs.
108 ChanCount current_meters;
110 std::vector<float> _peak_signal;
111 std::vector<float> _visible_peak_power;
112 std::vector<float> _max_peak_signal;
113 std::vector<float> _max_peak_power;
115 std::vector<Kmeterdsp *> _kmeter;
116 std::vector<Iec1ppmdsp *> _iec1meter;
117 std::vector<Iec2ppmdsp *> _iec2meter;
118 std::vector<Vumeterdsp *> _vumeter;
120 MeterType _meter_type;
123 } // namespace ARDOUR
125 #endif // __ardour_meter_h__