Ardour  9.0-pre0-582-g084a23a80d
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 #pragma once
23 
24 #include <atomic>
25 #include <vector>
26 
27 #include "pbd/fastlog.h"
28 
30 #include "ardour/processor.h"
31 #include "ardour/types.h"
32 
33 #include "ardour/iec1ppmdsp.h"
34 #include "ardour/iec2ppmdsp.h"
35 #include "ardour/kmeterdsp.h"
36 #include "ardour/vumeterdsp.h"
37 
38 namespace ARDOUR {
39 
40 class BufferSet;
41 class ChanCount;
42 class Session;
43 
47 {
48 public:
49  PeakMeter (Session& s, const std::string& name);
51 
52  void reset ();
53  void reset_max ();
54 
55  std::string display_name () const;
56 
59 
60  /* special method for meter, to ensure that it can always handle the maximum
61  number of streams in the route, no matter where we put it.
62  */
63 
64  void set_max_channels (const ChanCount&);
65 
66  /* tell the meter than no matter how many channels it can handle,
67  `in' is the number it is actually going be handling from
68  now on.
69  */
70 
71  void reflect_inputs (const ChanCount& in);
73 
75  void run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_sample, double speed, pframes_t nframes, bool);
76 
77  void activate () {}
78  void deactivate () {}
79 
80  ChanCount input_streams () const { return current_meters; }
81  ChanCount output_streams () const { return current_meters; }
82 
83  float meter_level (uint32_t n, MeterType type);
84 
86  MeterType meter_type () const { return _meter_type; }
87 
89 
90 protected:
91  XMLNode& state () const;
92 
93 private:
94  friend class IO;
95 
102 
103  std::atomic<int> _reset_dpm;
104  std::atomic<int> _reset_max;
105 
106  uint32_t _bufcnt;
107  std::vector<float> _peak_buffer; // internal, integrate
108  std::vector<float> _peak_power; // includes accurate falloff, hence dB
109  std::vector<float> _max_peak_signal; // dB calculation is done on demand
110 
111  std::vector<Kmeterdsp*> _kmeter;
112  std::vector<Iec1ppmdsp*> _iec1meter;
113  std::vector<Iec2ppmdsp*> _iec2meter;
114  std::vector<Vumeterdsp*> _vumeter;
115 
117 };
118 
119 } // namespace ARDOUR
120 
Definition: io.h:72
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)
PBD::Signal< void(MeterType)> MeterTypeChanged
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