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.

82 lines
2.7KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-11 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. ReverbAudioSource::ReverbAudioSource (AudioSource* const inputSource, const bool deleteInputWhenDeleted)
  19. : input (inputSource, deleteInputWhenDeleted),
  20. bypass (false)
  21. {
  22. jassert (inputSource != nullptr);
  23. }
  24. ReverbAudioSource::~ReverbAudioSource() {}
  25. void ReverbAudioSource::prepareToPlay (int samplesPerBlockExpected, double sampleRate)
  26. {
  27. const ScopedLock sl (lock);
  28. input->prepareToPlay (samplesPerBlockExpected, sampleRate);
  29. reverb.setSampleRate (sampleRate);
  30. }
  31. void ReverbAudioSource::releaseResources() {}
  32. void ReverbAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill)
  33. {
  34. const ScopedLock sl (lock);
  35. input->getNextAudioBlock (bufferToFill);
  36. if (! bypass)
  37. {
  38. float* const firstChannel = bufferToFill.buffer->getSampleData (0, bufferToFill.startSample);
  39. if (bufferToFill.buffer->getNumChannels() > 1)
  40. {
  41. reverb.processStereo (firstChannel,
  42. bufferToFill.buffer->getSampleData (1, bufferToFill.startSample),
  43. bufferToFill.numSamples);
  44. }
  45. else
  46. {
  47. reverb.processMono (firstChannel, bufferToFill.numSamples);
  48. }
  49. }
  50. }
  51. void ReverbAudioSource::setParameters (const Reverb::Parameters& newParams)
  52. {
  53. const ScopedLock sl (lock);
  54. reverb.setParameters (newParams);
  55. }
  56. void ReverbAudioSource::setBypassed (bool b) noexcept
  57. {
  58. if (bypass != b)
  59. {
  60. const ScopedLock sl (lock);
  61. bypass = b;
  62. reverb.reset();
  63. }
  64. }