Add remaining files
[juce-lv2.git] / juce / source / src / audio / audio_sources / juce_ReverbAudioSource.cpp
blob303e5a0dad5a31df0e37bf4b687b092aa65de1ad
1 /*
2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #include "../../core/juce_StandardHeader.h"
28 BEGIN_JUCE_NAMESPACE
30 #include "juce_ReverbAudioSource.h"
33 //==============================================================================
34 ReverbAudioSource::ReverbAudioSource (AudioSource* const inputSource, const bool deleteInputWhenDeleted)
35 : input (inputSource, deleteInputWhenDeleted),
36 bypass (false)
38 jassert (inputSource != nullptr);
41 ReverbAudioSource::~ReverbAudioSource() {}
43 void ReverbAudioSource::prepareToPlay (int samplesPerBlockExpected, double sampleRate)
45 const ScopedLock sl (lock);
46 input->prepareToPlay (samplesPerBlockExpected, sampleRate);
47 reverb.setSampleRate (sampleRate);
50 void ReverbAudioSource::releaseResources() {}
52 void ReverbAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill)
54 const ScopedLock sl (lock);
56 input->getNextAudioBlock (bufferToFill);
58 if (! bypass)
60 float* const firstChannel = bufferToFill.buffer->getSampleData (0, bufferToFill.startSample);
62 if (bufferToFill.buffer->getNumChannels() > 1)
64 reverb.processStereo (firstChannel,
65 bufferToFill.buffer->getSampleData (1, bufferToFill.startSample),
66 bufferToFill.numSamples);
68 else
70 reverb.processMono (firstChannel, bufferToFill.numSamples);
75 void ReverbAudioSource::setParameters (const Reverb::Parameters& newParams)
77 const ScopedLock sl (lock);
78 reverb.setParameters (newParams);
81 void ReverbAudioSource::setBypassed (bool b) noexcept
83 if (bypass != b)
85 const ScopedLock sl (lock);
86 bypass = b;
87 reverb.reset();
92 END_JUCE_NAMESPACE