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

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