1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libsoundtouch/src/AAFilter.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,100 @@ 1.4 +//////////////////////////////////////////////////////////////////////////////// 1.5 +/// 1.6 +/// Sampled sound tempo changer/time stretch algorithm. Changes the sound tempo 1.7 +/// while maintaining the original pitch by using a time domain WSOLA-like method 1.8 +/// with several performance-increasing tweaks. 1.9 +/// 1.10 +/// Anti-alias filter is used to prevent folding of high frequencies when 1.11 +/// transposing the sample rate with interpolation. 1.12 +/// 1.13 +/// Author : Copyright (c) Olli Parviainen 1.14 +/// Author e-mail : oparviai 'at' iki.fi 1.15 +/// SoundTouch WWW: http://www.surina.net/soundtouch 1.16 +/// 1.17 +//////////////////////////////////////////////////////////////////////////////// 1.18 +// 1.19 +// Last changed : $Date: 2014-01-07 13:41:23 -0600 (Tue, 07 Jan 2014) $ 1.20 +// File revision : $Revision: 4 $ 1.21 +// 1.22 +// $Id: AAFilter.h 187 2014-01-07 19:41:23Z oparviai $ 1.23 +// 1.24 +//////////////////////////////////////////////////////////////////////////////// 1.25 +// 1.26 +// License : 1.27 +// 1.28 +// SoundTouch audio processing library 1.29 +// Copyright (c) Olli Parviainen 1.30 +// 1.31 +// This library is free software; you can redistribute it and/or 1.32 +// modify it under the terms of the GNU Lesser General Public 1.33 +// License as published by the Free Software Foundation; either 1.34 +// version 2.1 of the License, or (at your option) any later version. 1.35 +// 1.36 +// This library is distributed in the hope that it will be useful, 1.37 +// but WITHOUT ANY WARRANTY; without even the implied warranty of 1.38 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1.39 +// Lesser General Public License for more details. 1.40 +// 1.41 +// You should have received a copy of the GNU Lesser General Public 1.42 +// License along with this library; if not, write to the Free Software 1.43 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 1.44 +// 1.45 +//////////////////////////////////////////////////////////////////////////////// 1.46 + 1.47 +#ifndef AAFilter_H 1.48 +#define AAFilter_H 1.49 + 1.50 +#include "STTypes.h" 1.51 +#include "FIFOSampleBuffer.h" 1.52 + 1.53 +namespace soundtouch 1.54 +{ 1.55 + 1.56 +class AAFilter 1.57 +{ 1.58 +protected: 1.59 + class FIRFilter *pFIR; 1.60 + 1.61 + /// Low-pass filter cut-off frequency, negative = invalid 1.62 + double cutoffFreq; 1.63 + 1.64 + /// num of filter taps 1.65 + uint length; 1.66 + 1.67 + /// Calculate the FIR coefficients realizing the given cutoff-frequency 1.68 + void calculateCoeffs(); 1.69 +public: 1.70 + AAFilter(uint length); 1.71 + 1.72 + ~AAFilter(); 1.73 + 1.74 + /// Sets new anti-alias filter cut-off edge frequency, scaled to sampling 1.75 + /// frequency (nyquist frequency = 0.5). The filter will cut off the 1.76 + /// frequencies than that. 1.77 + void setCutoffFreq(double newCutoffFreq); 1.78 + 1.79 + /// Sets number of FIR filter taps, i.e. ~filter complexity 1.80 + void setLength(uint newLength); 1.81 + 1.82 + uint getLength() const; 1.83 + 1.84 + /// Applies the filter to the given sequence of samples. 1.85 + /// Note : The amount of outputted samples is by value of 'filter length' 1.86 + /// smaller than the amount of input samples. 1.87 + uint evaluate(SAMPLETYPE *dest, 1.88 + const SAMPLETYPE *src, 1.89 + uint numSamples, 1.90 + uint numChannels) const; 1.91 + 1.92 + /// Applies the filter to the given src & dest pipes, so that processed amount of 1.93 + /// samples get removed from src, and produced amount added to dest 1.94 + /// Note : The amount of outputted samples is by value of 'filter length' 1.95 + /// smaller than the amount of input samples. 1.96 + uint evaluate(FIFOSampleBuffer &dest, 1.97 + FIFOSampleBuffer &src) const; 1.98 + 1.99 +}; 1.100 + 1.101 +} 1.102 + 1.103 +#endif