nick m's fix for markers etc ; several tweaks for mute/solo ; rename run_in_place...
[ardour.git] / libs / ardour / ardour / meter.h
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>
23 #include <sigc++/slot.h>
24 #include "ardour/types.h"
25 #include "ardour/processor.h"
26 #include "pbd/fastlog.h"
27
28 namespace ARDOUR {
29
30 class BufferSet;
31 class ChanCount;
32 class Session;
33
34 class Metering {
35   public:
36         static void               update_meters ();
37         static sigc::signal<void> Meter;
38
39         static sigc::connection   connect (sigc::slot<void> the_slot);
40         static void               disconnect (sigc::connection& c);
41
42   private:
43         /* this object is not meant to be instantiated */
44         virtual void foo() = 0;
45
46         static Glib::StaticMutex    m_meter_signal_lock;
47 };
48
49 /** Meters peaks on the input and stores them for access.
50  */
51 class PeakMeter : public Processor {
52 public:
53         PeakMeter(Session& s) : Processor(s, "Meter") {}
54
55         void meter();
56
57         void reset ();
58         void reset_max ();
59         
60         bool can_support_io_configuration (const ChanCount& in, ChanCount& out) const;
61         bool configure_io (ChanCount in, ChanCount out);
62         
63         /** Compute peaks */
64         void run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes);
65         
66         float peak_power (uint32_t n) { 
67                 if (n < _visible_peak_power.size()) {
68                         return _visible_peak_power[n];
69                 } else {
70                         return minus_infinity();
71                 }
72         }
73         
74         float max_peak_power (uint32_t n) {
75                 if (n < _max_peak_power.size()) {
76                         return _max_peak_power[n];
77                 } else {
78                         return minus_infinity();
79                 }
80         }
81         
82         XMLNode& state (bool full);
83
84 private:
85         friend class IO;
86
87         std::vector<float> _peak_power;
88         std::vector<float> _visible_peak_power;
89         std::vector<float> _max_peak_power;
90 };
91
92
93 } // namespace ARDOUR
94
95 #endif // __ardour_meter_h__