Ardour  8.7-15-gadf511264b
ardour/ardour/meter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2012 David Robillard <d@drobilla.net>
3  * Copyright (C) 2007-2017 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2009-2011 Carl Hetherington <carl@carlh.net>
5  * Copyright (C) 2013-2020 Robin Gareus <robin@gareus.org>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21 
22 #ifndef __ardour_meter_h__
23 #define __ardour_meter_h__
24 
25 #include <atomic>
26 #include <vector>
27 
28 #include "pbd/fastlog.h"
29 
31 #include "ardour/processor.h"
32 #include "ardour/types.h"
33 
34 #include "ardour/iec1ppmdsp.h"
35 #include "ardour/iec2ppmdsp.h"
36 #include "ardour/kmeterdsp.h"
37 #include "ardour/vumeterdsp.h"
38 
39 namespace ARDOUR {
40 
41 class BufferSet;
42 class ChanCount;
43 class Session;
44 
48 {
49 public:
50  PeakMeter (Session& s, const std::string& name);
52 
53  void reset ();
54  void reset_max ();
55 
56  std::string display_name () const;
57 
60 
61  /* special method for meter, to ensure that it can always handle the maximum
62  number of streams in the route, no matter where we put it.
63  */
64 
65  void set_max_channels (const ChanCount&);
66 
67  /* tell the meter than no matter how many channels it can handle,
68  `in' is the number it is actually going be handling from
69  now on.
70  */
71 
72  void reflect_inputs (const ChanCount& in);
74 
76  void run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_sample, double speed, pframes_t nframes, bool);
77 
78  void activate () {}
79  void deactivate () {}
80 
81  ChanCount input_streams () const { return current_meters; }
82  ChanCount output_streams () const { return current_meters; }
83 
84  float meter_level (uint32_t n, MeterType type);
85 
87  MeterType meter_type () const { return _meter_type; }
88 
89  PBD::Signal1<void, MeterType> MeterTypeChanged;
90 
91 protected:
92  XMLNode& state () const;
93 
94 private:
95  friend class IO;
96 
103 
104  std::atomic<int> _reset_dpm;
105  std::atomic<int> _reset_max;
106 
107  uint32_t _bufcnt;
108  std::vector<float> _peak_buffer; // internal, integrate
109  std::vector<float> _peak_power; // includes accurate falloff, hence dB
110  std::vector<float> _max_peak_signal; // dB calculation is done on demand
111 
112  std::vector<Kmeterdsp*> _kmeter;
113  std::vector<Iec1ppmdsp*> _iec1meter;
114  std::vector<Iec2ppmdsp*> _iec2meter;
115  std::vector<Vumeterdsp*> _vumeter;
116 
118 };
119 
120 } // namespace ARDOUR
121 
122 #endif // __ardour_meter_h__
Definition: io.h:73
PBD::Signal1< void, MeterType > MeterTypeChanged
std::string display_name() const
void reflect_inputs(const ChanCount &in)
ChanCount output_streams() const
void run(BufferSet &bufs, samplepos_t start_sample, samplepos_t end_sample, double speed, pframes_t nframes, bool)
MeterType meter_type() const
void set_meter_type(MeterType t)
PeakMeter(Session &s, const std::string &name)
bool can_support_io_configuration(const ChanCount &in, ChanCount &out)
void emit_configuration_changed()
ChanCount input_streams() const
std::vector< Iec1ppmdsp * > _iec1meter
std::vector< Kmeterdsp * > _kmeter
std::atomic< int > _reset_max
float meter_level(uint32_t n, MeterType type)
XMLNode & state() const
std::atomic< int > _reset_dpm
void set_max_channels(const ChanCount &)
std::vector< Iec2ppmdsp * > _iec2meter
std::vector< float > _peak_power
std::vector< float > _max_peak_signal
std::vector< Vumeterdsp * > _vumeter
bool configure_io(ChanCount in, ChanCount out)
std::vector< float > _peak_buffer
Definition: xml++.h:114
GtkImageIconNameData name
Definition: gtkimage.h:6
#define LIBARDOUR_API
uint32_t pframes_t
Temporal::samplepos_t samplepos_t