Some fixes for GCC 4.7.0
[ardour.git] / libs / rubberband / src / SilentAudioCurve.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 "SilentAudioCurve.h"
16
17 #include <cmath>
18
19 namespace RubberBand
20 {
21
22 SilentAudioCurve::SilentAudioCurve(size_t sampleRate, size_t windowSize) :
23     AudioCurve(sampleRate, windowSize)
24 {
25 }
26
27 SilentAudioCurve::~SilentAudioCurve()
28 {
29 }
30
31 void
32 SilentAudioCurve::reset()
33 {
34 }
35
36 void
37 SilentAudioCurve::setWindowSize(size_t newSize)
38 {
39     m_windowSize = newSize;
40 }
41
42 float
43 SilentAudioCurve::process(const float *R__ mag, size_t)
44 {
45     const int hs = m_windowSize / 2;
46     static float threshold = powf(10.f, -6);
47
48     for (int i = 0; i <= hs; ++i) {
49         if (mag[i] > threshold) return 0.f;
50     }
51         
52     return 1.f;
53 }
54
55 float
56 SilentAudioCurve::processDouble(const double *R__ mag, size_t)
57 {
58     const int hs = m_windowSize / 2;
59     static double threshold = pow(10.0, -6);
60
61     for (int i = 0; i <= hs; ++i) {
62         if (mag[i] > threshold) return 0.f;
63     }
64         
65     return 1.f;
66 }
67
68 }
69