media/libsoundtouch/src/AAFilter.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial