merge 3578:4901 of thirdparty/rubberband/current
[ardour.git] / libs / rubberband / src / HighFrequencyAudioCurve.cpp
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
2
3 /*
4     Rubber Band
5     An audio time-stretching and pitch-shifting library.
6     Copyright 2007-2008 Chris Cannam.
7     
8     This program is free software; you can redistribute it and/or
9     modify it under the terms of the GNU General Public License as
10     published by the Free Software Foundation; either version 2 of the
11     License, or (at your option) any later version.  See the file
12     COPYING included with this distribution for more information.
13 */
14
15 #include "HighFrequencyAudioCurve.h"
16
17 namespace RubberBand
18 {
19
20 HighFrequencyAudioCurve::HighFrequencyAudioCurve(size_t sampleRate, size_t windowSize) :
21     AudioCurve(sampleRate, windowSize)
22 {
23 }
24
25 HighFrequencyAudioCurve::~HighFrequencyAudioCurve()
26 {
27 }
28
29 void
30 HighFrequencyAudioCurve::reset()
31 {
32 }
33
34 void
35 HighFrequencyAudioCurve::setWindowSize(size_t newSize)
36 {
37     m_windowSize = newSize;
38 }
39
40 float
41 HighFrequencyAudioCurve::process(const float *R__ mag, size_t increment)
42 {
43     float result = 0.0;
44
45     const int sz = m_windowSize / 2;
46
47     for (int n = 0; n <= sz; ++n) {
48         result = result + mag[n] * n;
49     }
50
51     return result;
52 }
53
54 float
55 HighFrequencyAudioCurve::processDouble(const double *R__ mag, size_t increment)
56 {
57     float result = 0.0;
58
59     const int sz = m_windowSize / 2;
60
61     for (int n = 0; n <= sz; ++n) {
62         result = result + (float)mag[n] * n;
63     }
64
65     return result;
66 }
67
68 }
69