ardour
meter.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2006 Paul Davis
3 
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)
7  any later version.
8 
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
12  for more details.
13 
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.
17 */
18 
19 #ifndef __ardour_meter_h__
20 #define __ardour_meter_h__
21 
22 #include <vector>
24 #include "ardour/types.h"
25 #include "ardour/processor.h"
26 #include "pbd/fastlog.h"
27 
28 #include "ardour/kmeterdsp.h"
29 #include "ardour/iec1ppmdsp.h"
30 #include "ardour/iec2ppmdsp.h"
31 #include "ardour/vumeterdsp.h"
32 
33 namespace ARDOUR {
34 
35 class BufferSet;
36 class ChanCount;
37 class Session;
38 
42 public:
43  PeakMeter(Session& s, const std::string& name);
44  ~PeakMeter();
45 
46  void reset ();
47  void reset_max ();
48 
49  bool can_support_io_configuration (const ChanCount& in, ChanCount& out);
50  bool configure_io (ChanCount in, ChanCount out);
51 
52  /* special method for meter, to ensure that it can always handle the maximum
53  number of streams in the route, no matter where we put it.
54  */
55 
56  void set_max_channels (const ChanCount&);
57 
58  /* tell the meter than no matter how many channels it can handle,
59  `in' is the number it is actually going be handling from
60  now on.
61  */
62 
63  void reflect_inputs (const ChanCount& in);
64  void emit_configuration_changed ();
65 
67  void run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, bool);
68 
69  void activate () { }
70  void deactivate () { }
71 
72  ChanCount input_streams () const { return current_meters; }
73  ChanCount output_streams () const { return current_meters; }
74 
75  float meter_level (uint32_t n, MeterType type);
76 
77  void set_type(MeterType t);
78  MeterType get_type() { return _meter_type; }
79 
80  XMLNode& state (bool full);
81 
82  PBD::Signal1<void, MeterType> TypeChanged;
83 
84 private:
85  friend class IO;
86 
92 
93  bool _reset_dpm;
94  bool _reset_max;
95 
96  uint32_t _bufcnt;
97  std::vector<float> _peak_buffer; // internal, integrate
98  std::vector<float> _peak_power; // includes accurate falloff, hence dB
99  std::vector<float> _max_peak_signal; // dB calculation is done on demand
100 
101  std::vector<Kmeterdsp *> _kmeter;
102  std::vector<Iec1ppmdsp *> _iec1meter;
103  std::vector<Iec2ppmdsp *> _iec2meter;
104  std::vector<Vumeterdsp *> _vumeter;
105 
107 };
108 
109 } // namespace ARDOUR
110 
111 #endif // __ardour_meter_h__
std::vector< float > _peak_buffer
Definition: meter.h:97
std::vector< Kmeterdsp * > _kmeter
Definition: meter.h:101
bool _reset_dpm
Definition: meter.h:93
uint32_t pframes_t
Definition: types.h:61
void deactivate()
Definition: meter.h:70
std::vector< Vumeterdsp * > _vumeter
Definition: meter.h:104
void activate()
Definition: meter.h:69
uint32_t _bufcnt
Definition: meter.h:96
MeterType
Definition: types.h:182
Definition: amp.h:29
MeterType _meter_type
Definition: meter.h:106
bool _reset_max
Definition: meter.h:94
int64_t framepos_t
Definition: types.h:66
#define LIBARDOUR_API
std::vector< float > _peak_power
Definition: meter.h:98
ChanCount input_streams() const
Definition: meter.h:72
const char * name
std::vector< Iec2ppmdsp * > _iec2meter
Definition: meter.h:103
Definition: xml++.h:95
std::vector< float > _max_peak_signal
Definition: meter.h:99
PBD::Signal1< void, MeterType > TypeChanged
Definition: meter.h:82
MeterType get_type()
Definition: meter.h:78
ChanCount output_streams() const
Definition: meter.h:73
ChanCount current_meters
Definition: meter.h:91
std::vector< Iec1ppmdsp * > _iec1meter
Definition: meter.h:102
Definition: io.h:67