OpenShot Audio Library | OpenShotAudio: juce_IIRFilterAudioSource.cpp Source File

OpenShot Audio Library | OpenShotAudio 0.3.1

Loading...
Searching...
No Matches
juce_IIRFilterAudioSource.cpp
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2017 - ROLI Ltd.
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23namespace juce
24{
25
26IIRFilterAudioSource::IIRFilterAudioSource (AudioSource* const inputSource,
27 const bool deleteInputWhenDeleted)
28 : input (inputSource, deleteInputWhenDeleted)
29{
30 jassert (inputSource != nullptr);
31
32 for (int i = 2; --i >= 0;)
33 iirFilters.add (new IIRFilter());
34}
35
36IIRFilterAudioSource::~IIRFilterAudioSource() {}
37
38//==============================================================================
39 void IIRFilterAudioSource::setCoefficients (const IIRCoefficients& newCoefficients)
40{
41 for (int i = iirFilters.size(); --i >= 0;)
42 iirFilters.getUnchecked(i)->setCoefficients (newCoefficients);
43}
44
45 void IIRFilterAudioSource::makeInactive()
46{
47 for (int i = iirFilters.size(); --i >= 0;)
48 iirFilters.getUnchecked(i)->makeInactive();
49}
50
51//==============================================================================
52 void IIRFilterAudioSource::prepareToPlay (int samplesPerBlockExpected, double sampleRate)
53{
54 input->prepareToPlay (samplesPerBlockExpected, sampleRate);
55
56 for (int i = iirFilters.size(); --i >= 0;)
57 iirFilters.getUnchecked(i)->reset();
58}
59
60 void IIRFilterAudioSource::releaseResources()
61{
62 input->releaseResources();
63}
64
65 void IIRFilterAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill)
66{
67 input->getNextAudioBlock (bufferToFill);
68
69 const int numChannels = bufferToFill.buffer->getNumChannels();
70
71 while (numChannels > iirFilters.size())
72 iirFilters.add (new IIRFilter (*iirFilters.getUnchecked (0)));
73
74 for (int i = 0; i < numChannels; ++i)
75 iirFilters.getUnchecked(i)
76 ->processSamples (bufferToFill.buffer->getWritePointer (i, bufferToFill.startSample),
77 bufferToFill.numSamples);
78}
79
80} // namespace juce
juce::AudioBuffer::getWritePointer
Type * getWritePointer(int channelNumber) noexcept
Definition: juce_AudioSampleBuffer.h:273
juce::AudioBuffer::getNumChannels
int getNumChannels() const noexcept
Definition: juce_AudioSampleBuffer.h:233
juce::AudioSource
Definition: juce_AudioSource.h:110
juce::IIRCoefficients
Definition: juce_audio_basics/utilities/juce_IIRFilter.h:37
juce::IIRFilterAudioSource::makeInactive
void makeInactive()
Definition: juce_IIRFilterAudioSource.cpp:45
juce::IIRFilterAudioSource::prepareToPlay
void prepareToPlay(int samplesPerBlockExpected, double sampleRate) override
Definition: juce_IIRFilterAudioSource.cpp:52
juce::IIRFilterAudioSource::setCoefficients
void setCoefficients(const IIRCoefficients &newCoefficients)
Definition: juce_IIRFilterAudioSource.cpp:39
juce::IIRFilterAudioSource::IIRFilterAudioSource
IIRFilterAudioSource(AudioSource *inputSource, bool deleteInputWhenDeleted)
Definition: juce_IIRFilterAudioSource.cpp:26
juce::IIRFilterAudioSource::releaseResources
void releaseResources() override
Definition: juce_IIRFilterAudioSource.cpp:60
juce::IIRFilterAudioSource::~IIRFilterAudioSource
~IIRFilterAudioSource() override
Definition: juce_IIRFilterAudioSource.cpp:36
juce::IIRFilterAudioSource::getNextAudioBlock
void getNextAudioBlock(const AudioSourceChannelInfo &) override
Definition: juce_IIRFilterAudioSource.cpp:65
juce::IIRFilter
Definition: juce_audio_basics/utilities/juce_IIRFilter.h:157
juce::AudioSourceChannelInfo
Definition: juce_AudioSource.h:33
juce::AudioSourceChannelInfo::numSamples
int numSamples
Definition: juce_AudioSource.h:81
juce::AudioSourceChannelInfo::buffer
AudioBuffer< float > * buffer
Definition: juce_AudioSource.h:73
juce::AudioSourceChannelInfo::startSample
int startSample
Definition: juce_AudioSource.h:77