Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
2.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. struct CatmullRomAlgorithm
  18. {
  19. static forcedinline float valueAtOffset (const float* const inputs, const float offset) noexcept
  20. {
  21. const float y0 = inputs[3];
  22. const float y1 = inputs[2];
  23. const float y2 = inputs[1];
  24. const float y3 = inputs[0];
  25. const float halfY0 = 0.5f * y0;
  26. const float halfY3 = 0.5f * y3;
  27. return y1 + offset * ((0.5f * y2 - halfY0)
  28. + (offset * (((y0 + 2.0f * y2) - (halfY3 + 2.5f * y1))
  29. + (offset * ((halfY3 + 1.5f * y1) - (halfY0 + 1.5f * y2))))));
  30. }
  31. };
  32. CatmullRomInterpolator::CatmullRomInterpolator() noexcept { reset(); }
  33. CatmullRomInterpolator::~CatmullRomInterpolator() noexcept {}
  34. void CatmullRomInterpolator::reset() noexcept
  35. {
  36. subSamplePos = 1.0;
  37. for (int i = 0; i < numElementsInArray (lastInputSamples); ++i)
  38. lastInputSamples[i] = 0;
  39. }
  40. int CatmullRomInterpolator::process (double actualRatio, const float* in, float* out, int numOut) noexcept
  41. {
  42. return interpolate<CatmullRomAlgorithm> (lastInputSamples, subSamplePos, actualRatio, in, out, numOut);
  43. }
  44. int CatmullRomInterpolator::processAdding (double actualRatio, const float* in, float* out, int numOut, float gain) noexcept
  45. {
  46. return interpolateAdding<CatmullRomAlgorithm> (lastInputSamples, subSamplePos, actualRatio, in, out, numOut, gain);
  47. }