1 #ifndef AUDIOGRAPHER_PEAK_READER_H
2 #define AUDIOGRAPHER_PEAK_READER_H
4 #include "audiographer/visibility.h"
5 #include "audiographer/sink.h"
6 #include "audiographer/routines.h"
7 #include "audiographer/utils/listed_source.h"
12 /// A class that reads the maximum value from a stream
13 class LIBAUDIOGRAPHER_API PeakReader : public ListedSource<float>, public Sink<float>
16 /// Constructor \n RT safe
17 PeakReader() : peak (0.0) {}
19 /// Returns the highest absolute of the values found so far. \n RT safe
20 float get_peak() { return peak; }
22 /// Resets the peak to 0 \n RT safe
23 void reset() { peak = 0.0; }
25 /// Finds peaks from the data \n RT safe
26 void process (ProcessContext<float> const & c)
28 peak = Routines::compute_peak (c.data(), c.frames(), peak);
29 ListedSource<float>::output(c);
32 using Sink<float>::process;
41 #endif // AUDIOGRAPHER_PEAK_READER_H