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.

juce_ReverbAudioSource.cpp 2.5KB

10 years ago
10 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software 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. ReverbAudioSource::ReverbAudioSource (AudioSource* const inputSource, const bool deleteInputWhenDeleted)
  18. : input (inputSource, deleteInputWhenDeleted),
  19. bypass (false)
  20. {
  21. jassert (inputSource != nullptr);
  22. }
  23. ReverbAudioSource::~ReverbAudioSource() {}
  24. void ReverbAudioSource::prepareToPlay (int samplesPerBlockExpected, double sampleRate)
  25. {
  26. const ScopedLock sl (lock);
  27. input->prepareToPlay (samplesPerBlockExpected, sampleRate);
  28. reverb.setSampleRate (sampleRate);
  29. }
  30. void ReverbAudioSource::releaseResources() {}
  31. void ReverbAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill)
  32. {
  33. const ScopedLock sl (lock);
  34. input->getNextAudioBlock (bufferToFill);
  35. if (! bypass)
  36. {
  37. float* const firstChannel = bufferToFill.buffer->getWritePointer (0, bufferToFill.startSample);
  38. if (bufferToFill.buffer->getNumChannels() > 1)
  39. {
  40. reverb.processStereo (firstChannel,
  41. bufferToFill.buffer->getWritePointer (1, bufferToFill.startSample),
  42. bufferToFill.numSamples);
  43. }
  44. else
  45. {
  46. reverb.processMono (firstChannel, bufferToFill.numSamples);
  47. }
  48. }
  49. }
  50. void ReverbAudioSource::setParameters (const Reverb::Parameters& newParams)
  51. {
  52. const ScopedLock sl (lock);
  53. reverb.setParameters (newParams);
  54. }
  55. void ReverbAudioSource::setBypassed (bool b) noexcept
  56. {
  57. if (bypass != b)
  58. {
  59. const ScopedLock sl (lock);
  60. bypass = b;
  61. reverb.reset();
  62. }
  63. }