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.

88 lines
2.8KB

  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. BEGIN_JUCE_NAMESPACE
  19. //==============================================================================
  20. ReverbAudioSource::ReverbAudioSource (AudioSource* const inputSource, const bool deleteInputWhenDeleted)
  21. : input (inputSource, deleteInputWhenDeleted),
  22. bypass (false)
  23. {
  24. jassert (inputSource != nullptr);
  25. }
  26. ReverbAudioSource::~ReverbAudioSource() {}
  27. void ReverbAudioSource::prepareToPlay (int samplesPerBlockExpected, double sampleRate)
  28. {
  29. const ScopedLock sl (lock);
  30. input->prepareToPlay (samplesPerBlockExpected, sampleRate);
  31. reverb.setSampleRate (sampleRate);
  32. }
  33. void ReverbAudioSource::releaseResources() {}
  34. void ReverbAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill)
  35. {
  36. const ScopedLock sl (lock);
  37. input->getNextAudioBlock (bufferToFill);
  38. if (! bypass)
  39. {
  40. float* const firstChannel = bufferToFill.buffer->getSampleData (0, bufferToFill.startSample);
  41. if (bufferToFill.buffer->getNumChannels() > 1)
  42. {
  43. reverb.processStereo (firstChannel,
  44. bufferToFill.buffer->getSampleData (1, bufferToFill.startSample),
  45. bufferToFill.numSamples);
  46. }
  47. else
  48. {
  49. reverb.processMono (firstChannel, bufferToFill.numSamples);
  50. }
  51. }
  52. }
  53. void ReverbAudioSource::setParameters (const Reverb::Parameters& newParams)
  54. {
  55. const ScopedLock sl (lock);
  56. reverb.setParameters (newParams);
  57. }
  58. void ReverbAudioSource::setBypassed (bool b) noexcept
  59. {
  60. if (bypass != b)
  61. {
  62. const ScopedLock sl (lock);
  63. bypass = b;
  64. reverb.reset();
  65. }
  66. }
  67. END_JUCE_NAMESPACE