InterpolateLinear.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. ////////////////////////////////////////////////////////////////////////////////
  2. ///
  3. /// Linear interpolation routine.
  4. ///
  5. /// Author : Copyright (c) Olli Parviainen
  6. /// Author e-mail : oparviai 'at' iki.fi
  7. /// SoundTouch WWW: http://www.surina.net/soundtouch
  8. ///
  9. ////////////////////////////////////////////////////////////////////////////////
  10. //
  11. // License :
  12. //
  13. // SoundTouch audio processing library
  14. // Copyright (c) Olli Parviainen
  15. //
  16. // This library is free software; you can redistribute it and/or
  17. // modify it under the terms of the GNU Lesser General Public
  18. // License as published by the Free Software Foundation; either
  19. // version 2.1 of the License, or (at your option) any later version.
  20. //
  21. // This library is distributed in the hope that it will be useful,
  22. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  24. // Lesser General Public License for more details.
  25. //
  26. // You should have received a copy of the GNU Lesser General Public
  27. // License along with this library; if not, write to the Free Software
  28. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  29. //
  30. ////////////////////////////////////////////////////////////////////////////////
  31. #ifndef _InterpolateLinear_H_
  32. #define _InterpolateLinear_H_
  33. #include "RateTransposer.h"
  34. #include "STTypes.h"
  35. namespace soundtouch
  36. {
  37. /// Linear transposer class that uses integer arithmetic
  38. class InterpolateLinearInteger : public TransposerBase
  39. {
  40. protected:
  41. int iFract;
  42. int iRate;
  43. virtual int transposeMono(SAMPLETYPE *dest,
  44. const SAMPLETYPE *src,
  45. int &srcSamples);
  46. virtual int transposeStereo(SAMPLETYPE *dest,
  47. const SAMPLETYPE *src,
  48. int &srcSamples);
  49. virtual int transposeMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, int &srcSamples);
  50. public:
  51. InterpolateLinearInteger();
  52. /// Sets new target rate. Normal rate = 1.0, smaller values represent slower
  53. /// rate, larger faster rates.
  54. virtual void setRate(double newRate);
  55. virtual void resetRegisters();
  56. int getLatency() const
  57. {
  58. return 0;
  59. }
  60. };
  61. /// Linear transposer class that uses floating point arithmetic
  62. class InterpolateLinearFloat : public TransposerBase
  63. {
  64. protected:
  65. double fract;
  66. virtual int transposeMono(SAMPLETYPE *dest,
  67. const SAMPLETYPE *src,
  68. int &srcSamples);
  69. virtual int transposeStereo(SAMPLETYPE *dest,
  70. const SAMPLETYPE *src,
  71. int &srcSamples);
  72. virtual int transposeMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, int &srcSamples);
  73. public:
  74. InterpolateLinearFloat();
  75. virtual void resetRegisters();
  76. int getLatency() const
  77. {
  78. return 0;
  79. }
  80. };
  81. }
  82. #endif