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.

66 lines
2.2KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. The code included in this file is provided under the terms of the ISC license
  8. http://www.isc.org/downloads/software-support-policy/isc-license. Permission
  9. To use, copy, modify, and/or distribute this software for any purpose with or
  10. without fee is hereby granted provided that the above copyright notice and
  11. this permission notice appear in all copies.
  12. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  13. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  14. DISCLAIMED.
  15. ==============================================================================
  16. */
  17. namespace juce
  18. {
  19. struct CatmullRomAlgorithm
  20. {
  21. static forcedinline float valueAtOffset (const float* const inputs, const float offset) noexcept
  22. {
  23. auto y0 = inputs[3];
  24. auto y1 = inputs[2];
  25. auto y2 = inputs[1];
  26. auto y3 = inputs[0];
  27. auto halfY0 = 0.5f * y0;
  28. auto halfY3 = 0.5f * y3;
  29. return y1 + offset * ((0.5f * y2 - halfY0)
  30. + (offset * (((y0 + 2.0f * y2) - (halfY3 + 2.5f * y1))
  31. + (offset * ((halfY3 + 1.5f * y1) - (halfY0 + 1.5f * y2))))));
  32. }
  33. };
  34. CatmullRomInterpolator::CatmullRomInterpolator() noexcept { reset(); }
  35. CatmullRomInterpolator::~CatmullRomInterpolator() noexcept {}
  36. void CatmullRomInterpolator::reset() noexcept
  37. {
  38. subSamplePos = 1.0;
  39. for (auto& s : lastInputSamples)
  40. s = 0;
  41. }
  42. int CatmullRomInterpolator::process (double actualRatio, const float* in, float* out, int numOut) noexcept
  43. {
  44. return interpolate<CatmullRomAlgorithm> (lastInputSamples, subSamplePos, actualRatio, in, out, numOut);
  45. }
  46. int CatmullRomInterpolator::processAdding (double actualRatio, const float* in, float* out, int numOut, float gain) noexcept
  47. {
  48. return interpolateAdding<CatmullRomAlgorithm> (lastInputSamples, subSamplePos, actualRatio, in, out, numOut, gain);
  49. }
  50. } // namespace juce