The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

69 lines
2.8KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2016 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of the ISC license
  6. http://www.isc.org/downloads/software-support-policy/isc-license/
  7. Permission to use, copy, modify, and/or distribute this software for any
  8. purpose with or without fee is hereby granted, provided that the above
  9. copyright notice and this permission notice appear in all copies.
  10. THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD
  11. TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  12. FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
  13. OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  14. USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  16. OF THIS SOFTWARE.
  17. -----------------------------------------------------------------------------
  18. To release a closed-source product which uses other parts of JUCE not
  19. licensed under the ISC terms, commercial licenses are available: visit
  20. www.juce.com for more information.
  21. ==============================================================================
  22. */
  23. struct CatmullRomAlgorithm
  24. {
  25. static forcedinline float valueAtOffset (const float* const inputs, const float offset) noexcept
  26. {
  27. const float y0 = inputs[3];
  28. const float y1 = inputs[2];
  29. const float y2 = inputs[1];
  30. const float y3 = inputs[0];
  31. const float halfY0 = 0.5f * y0;
  32. const float halfY3 = 0.5f * y3;
  33. return y1 + offset * ((0.5f * y2 - halfY0)
  34. + (offset * (((y0 + 2.0f * y2) - (halfY3 + 2.5f * y1))
  35. + (offset * ((halfY3 + 1.5f * y1) - (halfY0 + 1.5f * y2))))));
  36. }
  37. };
  38. CatmullRomInterpolator::CatmullRomInterpolator() noexcept { reset(); }
  39. CatmullRomInterpolator::~CatmullRomInterpolator() noexcept {}
  40. void CatmullRomInterpolator::reset() noexcept
  41. {
  42. subSamplePos = 1.0;
  43. for (int i = 0; i < numElementsInArray (lastInputSamples); ++i)
  44. lastInputSamples[i] = 0;
  45. }
  46. int CatmullRomInterpolator::process (double actualRatio, const float* in, float* out, int numOut) noexcept
  47. {
  48. return interpolate<CatmullRomAlgorithm> (lastInputSamples, subSamplePos, actualRatio, in, out, numOut);
  49. }
  50. int CatmullRomInterpolator::processAdding (double actualRatio, const float* in, float* out, int numOut, float gain) noexcept
  51. {
  52. return interpolateAdding<CatmullRomAlgorithm> (lastInputSamples, subSamplePos, actualRatio, in, out, numOut, gain);
  53. }