Re-integrate export-optimization branch.
[ardour.git] / libs / audiographer / audiographer / peak_reader.h
1 #ifndef AUDIOGRAPHER_PEAK_READER_H
2 #define AUDIOGRAPHER_PEAK_READER_H
3
4 #include "listed_source.h"
5 #include "sink.h"
6 #include "routines.h"
7
8 namespace AudioGrapher
9 {
10
11 class PeakReader : public ListedSource<float>, public Sink<float>
12 {
13   public:
14         PeakReader() : peak (0.0) {}
15         
16         float get_peak() { return peak; }
17         void  reset() { peak = 0.0; }
18
19         void process (ProcessContext<float> const & c)
20         {
21                 peak = Routines::compute_peak (c.data(), c.frames(), peak);
22                 ListedSource<float>::output(c);
23         }
24         
25         void process (ProcessContext<float> & c)
26         {
27                 peak = Routines::compute_peak (c.data(), c.frames(), peak);
28                 ListedSource<float>::output(c);
29         }
30         
31   private:
32         float peak;
33 };
34
35
36 } // namespace
37
38 #endif // AUDIOGRAPHER_PEAK_READER_H