~ubuntu-branches/ubuntu/utopic/ardour3/utopic

« back to all changes in this revision

Viewing changes to libs/audiographer/audiographer/general/peak_reader.h

  • Committer: Package Import Robot
  • Author(s): Felipe Sateler
  • Date: 2013-09-21 19:05:02 UTC
  • Revision ID: package-import@ubuntu.com-20130921190502-8gsftrku6jnzhd7v
Tags: upstream-3.4~dfsg
ImportĀ upstreamĀ versionĀ 3.4~dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef AUDIOGRAPHER_PEAK_READER_H
 
2
#define AUDIOGRAPHER_PEAK_READER_H
 
3
 
 
4
#include "audiographer/sink.h"
 
5
#include "audiographer/routines.h"
 
6
#include "audiographer/utils/listed_source.h"
 
7
 
 
8
namespace AudioGrapher
 
9
{
 
10
 
 
11
/// A class that reads the maximum value from a stream
 
12
class PeakReader : public ListedSource<float>, public Sink<float>
 
13
{
 
14
  public:
 
15
        /// Constructor \n RT safe
 
16
        PeakReader() : peak (0.0) {}
 
17
        
 
18
        /// Returns the highest absolute of the values found so far. \n RT safe
 
19
        float get_peak() { return peak; }
 
20
        
 
21
        /// Resets the peak to 0 \n RT safe
 
22
        void  reset() { peak = 0.0; }
 
23
 
 
24
        /// Finds peaks from the data \n RT safe
 
25
        void process (ProcessContext<float> const & c)
 
26
        {
 
27
                peak = Routines::compute_peak (c.data(), c.frames(), peak);
 
28
                ListedSource<float>::output(c);
 
29
        }
 
30
        
 
31
        using Sink<float>::process;
 
32
        
 
33
  private:
 
34
        float peak;
 
35
};
 
36
 
 
37
 
 
38
} // namespace
 
39
 
 
40
#endif // AUDIOGRAPHER_PEAK_READER_H