michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: /// michael@0: /// Sampled sound tempo changer/time stretch algorithm. Changes the sound tempo michael@0: /// while maintaining the original pitch by using a time domain WSOLA-like method michael@0: /// with several performance-increasing tweaks. michael@0: /// michael@0: /// Anti-alias filter is used to prevent folding of high frequencies when michael@0: /// transposing the sample rate with interpolation. michael@0: /// michael@0: /// Author : Copyright (c) Olli Parviainen michael@0: /// Author e-mail : oparviai 'at' iki.fi michael@0: /// SoundTouch WWW: http://www.surina.net/soundtouch michael@0: /// michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: // michael@0: // Last changed : $Date: 2014-01-07 13:41:23 -0600 (Tue, 07 Jan 2014) $ michael@0: // File revision : $Revision: 4 $ michael@0: // michael@0: // $Id: AAFilter.h 187 2014-01-07 19:41:23Z oparviai $ michael@0: // michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: // michael@0: // License : michael@0: // michael@0: // SoundTouch audio processing library michael@0: // Copyright (c) Olli Parviainen michael@0: // michael@0: // This library is free software; you can redistribute it and/or michael@0: // modify it under the terms of the GNU Lesser General Public michael@0: // License as published by the Free Software Foundation; either michael@0: // version 2.1 of the License, or (at your option) any later version. michael@0: // michael@0: // This library is distributed in the hope that it will be useful, michael@0: // but WITHOUT ANY WARRANTY; without even the implied warranty of michael@0: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU michael@0: // Lesser General Public License for more details. michael@0: // michael@0: // You should have received a copy of the GNU Lesser General Public michael@0: // License along with this library; if not, write to the Free Software michael@0: // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA michael@0: // michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: #ifndef AAFilter_H michael@0: #define AAFilter_H michael@0: michael@0: #include "STTypes.h" michael@0: #include "FIFOSampleBuffer.h" michael@0: michael@0: namespace soundtouch michael@0: { michael@0: michael@0: class AAFilter michael@0: { michael@0: protected: michael@0: class FIRFilter *pFIR; michael@0: michael@0: /// Low-pass filter cut-off frequency, negative = invalid michael@0: double cutoffFreq; michael@0: michael@0: /// num of filter taps michael@0: uint length; michael@0: michael@0: /// Calculate the FIR coefficients realizing the given cutoff-frequency michael@0: void calculateCoeffs(); michael@0: public: michael@0: AAFilter(uint length); michael@0: michael@0: ~AAFilter(); michael@0: michael@0: /// Sets new anti-alias filter cut-off edge frequency, scaled to sampling michael@0: /// frequency (nyquist frequency = 0.5). The filter will cut off the michael@0: /// frequencies than that. michael@0: void setCutoffFreq(double newCutoffFreq); michael@0: michael@0: /// Sets number of FIR filter taps, i.e. ~filter complexity michael@0: void setLength(uint newLength); michael@0: michael@0: uint getLength() const; michael@0: michael@0: /// Applies the filter to the given sequence of samples. michael@0: /// Note : The amount of outputted samples is by value of 'filter length' michael@0: /// smaller than the amount of input samples. michael@0: uint evaluate(SAMPLETYPE *dest, michael@0: const SAMPLETYPE *src, michael@0: uint numSamples, michael@0: uint numChannels) const; michael@0: michael@0: /// Applies the filter to the given src & dest pipes, so that processed amount of michael@0: /// samples get removed from src, and produced amount added to dest michael@0: /// Note : The amount of outputted samples is by value of 'filter length' michael@0: /// smaller than the amount of input samples. michael@0: uint evaluate(FIFOSampleBuffer &dest, michael@0: FIFOSampleBuffer &src) const; michael@0: michael@0: }; michael@0: michael@0: } michael@0: michael@0: #endif