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