JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_IIRFilterAudioSource.cpp
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
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
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
37
38//==============================================================================
40{
41 for (int i = iirFilters.size(); --i >= 0;)
42 iirFilters.getUnchecked (i)->setCoefficients (newCoefficients);
43}
44
46{
47 for (int i = iirFilters.size(); --i >= 0;)
48 iirFilters.getUnchecked (i)->makeInactive();
49}
50
51//==============================================================================
53{
54 input->prepareToPlay (samplesPerBlockExpected, sampleRate);
55
56 for (int i = iirFilters.size(); --i >= 0;)
57 iirFilters.getUnchecked (i)->reset();
58}
59
61{
62 input->releaseResources();
63}
64
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
Base class for objects that can produce a continuous stream of audio.
A set of coefficients for use in an IIRFilter object.
void makeInactive()
Calls IIRFilter::makeInactive() on all the filters being used internally.
void prepareToPlay(int samplesPerBlockExpected, double sampleRate) override
Tells the source to prepare for playing.
void setCoefficients(const IIRCoefficients &newCoefficients)
Changes the filter to use the same parameters as the one being passed in.
IIRFilterAudioSource(AudioSource *inputSource, bool deleteInputWhenDeleted)
Creates a IIRFilterAudioSource for a given input source.
void releaseResources() override
Allows the source to release anything it no longer needs after playback has stopped.
~IIRFilterAudioSource() override
Destructor.
void getNextAudioBlock(const AudioSourceChannelInfo &) override
Called repeatedly to fetch subsequent blocks of audio data.
An IIR filter that can perform low, high, or band-pass filtering on an audio signal,...
#define jassert(expression)
Platform-independent assertion macro.
JUCE Namespace.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88
Used by AudioSource::getNextAudioBlock().