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.9KB

10 years ago
10 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2016 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of the ISC license
  6. http://www.isc.org/downloads/software-support-policy/isc-license/
  7. Permission to use, copy, modify, and/or distribute this software for any
  8. purpose with or without fee is hereby granted, provided that the above
  9. copyright notice and this permission notice appear in all copies.
  10. THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD
  11. TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  12. FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
  13. OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  14. USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  16. OF THIS SOFTWARE.
  17. -----------------------------------------------------------------------------
  18. To release a closed-source product which uses other parts of JUCE not
  19. licensed under the ISC terms, commercial licenses are available: visit
  20. www.juce.com for more information.
  21. ==============================================================================
  22. */
  23. ReverbAudioSource::ReverbAudioSource (AudioSource* const inputSource, const bool deleteInputWhenDeleted)
  24. : input (inputSource, deleteInputWhenDeleted),
  25. bypass (false)
  26. {
  27. jassert (inputSource != nullptr);
  28. }
  29. ReverbAudioSource::~ReverbAudioSource() {}
  30. void ReverbAudioSource::prepareToPlay (int samplesPerBlockExpected, double sampleRate)
  31. {
  32. const ScopedLock sl (lock);
  33. input->prepareToPlay (samplesPerBlockExpected, sampleRate);
  34. reverb.setSampleRate (sampleRate);
  35. }
  36. void ReverbAudioSource::releaseResources() {}
  37. void ReverbAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill)
  38. {
  39. const ScopedLock sl (lock);
  40. input->getNextAudioBlock (bufferToFill);
  41. if (! bypass)
  42. {
  43. float* const firstChannel = bufferToFill.buffer->getWritePointer (0, bufferToFill.startSample);
  44. if (bufferToFill.buffer->getNumChannels() > 1)
  45. {
  46. reverb.processStereo (firstChannel,
  47. bufferToFill.buffer->getWritePointer (1, bufferToFill.startSample),
  48. bufferToFill.numSamples);
  49. }
  50. else
  51. {
  52. reverb.processMono (firstChannel, bufferToFill.numSamples);
  53. }
  54. }
  55. }
  56. void ReverbAudioSource::setParameters (const Reverb::Parameters& newParams)
  57. {
  58. const ScopedLock sl (lock);
  59. reverb.setParameters (newParams);
  60. }
  61. void ReverbAudioSource::setBypassed (bool b) noexcept
  62. {
  63. if (bypass != b)
  64. {
  65. const ScopedLock sl (lock);
  66. bypass = b;
  67. reverb.reset();
  68. }
  69. }