media/libsoundtouch/src/AAFilter.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 ////////////////////////////////////////////////////////////////////////////////
michael@0 2 ///
michael@0 3 /// Sampled sound tempo changer/time stretch algorithm. Changes the sound tempo
michael@0 4 /// while maintaining the original pitch by using a time domain WSOLA-like method
michael@0 5 /// with several performance-increasing tweaks.
michael@0 6 ///
michael@0 7 /// Anti-alias filter is used to prevent folding of high frequencies when
michael@0 8 /// transposing the sample rate with interpolation.
michael@0 9 ///
michael@0 10 /// Author : Copyright (c) Olli Parviainen
michael@0 11 /// Author e-mail : oparviai 'at' iki.fi
michael@0 12 /// SoundTouch WWW: http://www.surina.net/soundtouch
michael@0 13 ///
michael@0 14 ////////////////////////////////////////////////////////////////////////////////
michael@0 15 //
michael@0 16 // Last changed : $Date: 2014-01-07 13:41:23 -0600 (Tue, 07 Jan 2014) $
michael@0 17 // File revision : $Revision: 4 $
michael@0 18 //
michael@0 19 // $Id: AAFilter.h 187 2014-01-07 19:41:23Z oparviai $
michael@0 20 //
michael@0 21 ////////////////////////////////////////////////////////////////////////////////
michael@0 22 //
michael@0 23 // License :
michael@0 24 //
michael@0 25 // SoundTouch audio processing library
michael@0 26 // Copyright (c) Olli Parviainen
michael@0 27 //
michael@0 28 // This library is free software; you can redistribute it and/or
michael@0 29 // modify it under the terms of the GNU Lesser General Public
michael@0 30 // License as published by the Free Software Foundation; either
michael@0 31 // version 2.1 of the License, or (at your option) any later version.
michael@0 32 //
michael@0 33 // This library is distributed in the hope that it will be useful,
michael@0 34 // but WITHOUT ANY WARRANTY; without even the implied warranty of
michael@0 35 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
michael@0 36 // Lesser General Public License for more details.
michael@0 37 //
michael@0 38 // You should have received a copy of the GNU Lesser General Public
michael@0 39 // License along with this library; if not, write to the Free Software
michael@0 40 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
michael@0 41 //
michael@0 42 ////////////////////////////////////////////////////////////////////////////////
michael@0 43
michael@0 44 #ifndef AAFilter_H
michael@0 45 #define AAFilter_H
michael@0 46
michael@0 47 #include "STTypes.h"
michael@0 48 #include "FIFOSampleBuffer.h"
michael@0 49
michael@0 50 namespace soundtouch
michael@0 51 {
michael@0 52
michael@0 53 class AAFilter
michael@0 54 {
michael@0 55 protected:
michael@0 56 class FIRFilter *pFIR;
michael@0 57
michael@0 58 /// Low-pass filter cut-off frequency, negative = invalid
michael@0 59 double cutoffFreq;
michael@0 60
michael@0 61 /// num of filter taps
michael@0 62 uint length;
michael@0 63
michael@0 64 /// Calculate the FIR coefficients realizing the given cutoff-frequency
michael@0 65 void calculateCoeffs();
michael@0 66 public:
michael@0 67 AAFilter(uint length);
michael@0 68
michael@0 69 ~AAFilter();
michael@0 70
michael@0 71 /// Sets new anti-alias filter cut-off edge frequency, scaled to sampling
michael@0 72 /// frequency (nyquist frequency = 0.5). The filter will cut off the
michael@0 73 /// frequencies than that.
michael@0 74 void setCutoffFreq(double newCutoffFreq);
michael@0 75
michael@0 76 /// Sets number of FIR filter taps, i.e. ~filter complexity
michael@0 77 void setLength(uint newLength);
michael@0 78
michael@0 79 uint getLength() const;
michael@0 80
michael@0 81 /// Applies the filter to the given sequence of samples.
michael@0 82 /// Note : The amount of outputted samples is by value of 'filter length'
michael@0 83 /// smaller than the amount of input samples.
michael@0 84 uint evaluate(SAMPLETYPE *dest,
michael@0 85 const SAMPLETYPE *src,
michael@0 86 uint numSamples,
michael@0 87 uint numChannels) const;
michael@0 88
michael@0 89 /// Applies the filter to the given src & dest pipes, so that processed amount of
michael@0 90 /// samples get removed from src, and produced amount added to dest
michael@0 91 /// Note : The amount of outputted samples is by value of 'filter length'
michael@0 92 /// smaller than the amount of input samples.
michael@0 93 uint evaluate(FIFOSampleBuffer &dest,
michael@0 94 FIFOSampleBuffer &src) const;
michael@0 95
michael@0 96 };
michael@0 97
michael@0 98 }
michael@0 99
michael@0 100 #endif

mercurial