830911f6f9
git-svn-id: svn://localhost/ardour2/branches/3.0@6760 d708f5d6-7413-0410-9779-e7cbd77b26cf
41 lines
889 B
C++
41 lines
889 B
C++
#ifndef AUDIOGRAPHER_PEAK_READER_H
|
|
#define AUDIOGRAPHER_PEAK_READER_H
|
|
|
|
#include "audiographer/sink.h"
|
|
#include "audiographer/routines.h"
|
|
#include "audiographer/utils/listed_source.h"
|
|
|
|
namespace AudioGrapher
|
|
{
|
|
|
|
/// A class that reads the maximum value from a stream
|
|
class PeakReader : public ListedSource<float>, public Sink<float>
|
|
{
|
|
public:
|
|
/// Constructor \n RT safe
|
|
PeakReader() : peak (0.0) {}
|
|
|
|
/// Returns the highest absolute of the values found so far. \n RT safe
|
|
float get_peak() { return peak; }
|
|
|
|
/// Resets the peak to 0 \n RT safe
|
|
void reset() { peak = 0.0; }
|
|
|
|
/// Finds peaks from the data \n RT safe
|
|
void process (ProcessContext<float> const & c)
|
|
{
|
|
peak = Routines::compute_peak (c.data(), c.frames(), peak);
|
|
ListedSource<float>::output(c);
|
|
}
|
|
|
|
using Sink<float>::process;
|
|
|
|
private:
|
|
float peak;
|
|
};
|
|
|
|
|
|
} // namespace
|
|
|
|
#endif // AUDIOGRAPHER_PEAK_READER_H
|