/external/pysoundtouch14/libsoundtouch/AAFilter.h

http://echo-nest-remix.googlecode.com/ · C++ Header · 91 lines · 25 code · 14 blank · 52 comment · 0 complexity · e3e2cfce7c6eb2a7e4efd6cf40f66b16 MD5 · raw file

  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: 2008-02-10 18:26:55 +0200 (Sun, 10 Feb 2008) $
  17. // File revision : $Revision: 4 $
  18. //
  19. // $Id: AAFilter.h 11 2008-02-10 16:26:55Z 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. ////////////////////////////////////////////////////////////////////////////////
  43. #ifndef AAFilter_H
  44. #define AAFilter_H
  45. #include "STTypes.h"
  46. namespace soundtouch
  47. {
  48. class AAFilter
  49. {
  50. protected:
  51. class FIRFilter *pFIR;
  52. /// Low-pass filter cut-off frequency, negative = invalid
  53. double cutoffFreq;
  54. /// num of filter taps
  55. uint length;
  56. /// Calculate the FIR coefficients realizing the given cutoff-frequency
  57. void calculateCoeffs();
  58. public:
  59. AAFilter(uint length);
  60. ~AAFilter();
  61. /// Sets new anti-alias filter cut-off edge frequency, scaled to sampling
  62. /// frequency (nyquist frequency = 0.5). The filter will cut off the
  63. /// frequencies than that.
  64. void setCutoffFreq(double newCutoffFreq);
  65. /// Sets number of FIR filter taps, i.e. ~filter complexity
  66. void setLength(uint newLength);
  67. uint getLength() const;
  68. /// Applies the filter to the given sequence of samples.
  69. /// Note : The amount of outputted samples is by value of 'filter length'
  70. /// smaller than the amount of input samples.
  71. uint evaluate(SAMPLETYPE *dest,
  72. const SAMPLETYPE *src,
  73. uint numSamples,
  74. uint numChannels) const;
  75. };
  76. }
  77. #endif