tracktion-engine 3.0-10-g034fdde4aa5
Tracktion Engine — High level data model for audio applications

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_ImpulseResponsePlugin.h
Go to the documentation of this file.
1 /*
2 ,--. ,--. ,--. ,--.
3 ,-' '-.,--.--.,--,--.,---.| |,-.,-' '-.`--' ,---. ,--,--, Copyright 2024
4 '-. .-'| .--' ,-. | .--'| /'-. .-',--.| .-. || \ Tracktion Software
5 | | | | \ '-' \ `--.| \ \ | | | |' '-' '| || | Corporation
6 `---' `--' `--`--'`---'`--'`--' `---' `--' `---' `--''--' www.tracktion.com
7
8 Tracktion Engine uses a GPL/commercial licence - see LICENCE.md for details.
9*/
10
11
12namespace tracktion { inline namespace engine
13{
14
15//==============================================================================
21{
22public:
28
30 ~ImpulseResponsePlugin() override;
31
32 static const char* getPluginName();
33 static inline const char* xmlTypeName = "impulseResponse";
34
35 //==============================================================================
39 bool loadImpulseResponse (const void* sourceData, size_t sourceDataSize);
40
44 bool loadImpulseResponse (const juce::File& fileImpulseResponse);
45
49 bool loadImpulseResponse (juce::AudioBuffer<float>&& bufferImpulseResponse,
50 double sampleRateToStore,
51 int bitDepthToStore);
52
53 //==============================================================================
64 //==============================================================================
66 juce::String getName() const override;
68 juce::String getShortName (int /*suggestedLength*/) override;
70 juce::String getPluginType() override;
72 bool needsConstantBufferSize() override;
75
77 double getLatencySeconds() override;
79 void initialise (const PluginInitialisationInfo&) override;
81 void deinitialise() override;
83 void reset() override;
85 void applyToBuffer (const PluginRenderContext&) override;
87 void restorePluginStateFromValueTree (const juce::ValueTree&) override;
88
89private:
90 //==============================================================================
91 enum
92 {
93 convolutionIndex,
94 HPFIndex,
95 LPFIndex,
96 gainIndex,
97 };
98
99 juce::CachedValue<float> gainValue, mixValue;
100 juce::CachedValue<float> highPassCutoffValue, lowPassCutoffValue;
102
106 juce::dsp::Gain<float>> processorChain;
107 juce::SmoothedValue<float> highFreqSmoother, lowFreqSmoother, gainSmoother, wetGainSmoother, dryGainSmoother, qSmoother;
108
109 struct WetDryGain { float wet, dry; };
110 static WetDryGain getWetDryLevels (float mix)
111 {
112 const float dry = 1.0f - (mix * mix);
113 float temp = 1.0f - mix;
114 const float wet = 1.0f - (temp * temp);
115
116 return { wet, dry };
117 }
118 void loadImpulseResponseFromState();
119
120 void valueTreePropertyChanged (juce::ValueTree&, const juce::Identifier&) override;
121
123};
124
125}} // namespace tracktion { inline namespace engine
ImpulseResponsePlugin that loads an impulse response and applies it the audio stream.
bool loadImpulseResponse(const void *sourceData, size_t sourceDataSize)
Loads an impulse from binary audio file data i.e.
AutomatableParameter::Ptr gainParam
Parameter for the gain to apply.
AutomatableParameter::Ptr mixParam
Parameter for the mix control, 0.0 = dry, 1.0 = wet.
juce::CachedValue< juce::String > name
A name property.
void initialise(const PluginInitialisationInfo &) override
Gives the plugin a chance to set itself up before being played.
juce::String getSelectableDescription() override
Subclasses must return a description of what they are.
juce::String getName() const override
The name of the type, e.g.
void applyToBuffer(const PluginRenderContext &) override
Process the next block of data.
void deinitialise() override
Called after play stops to release resources.
AutomatableParameter::Ptr lowPassCutoffParam
Cutoff frequency for the low pass filter to applied after the IR.
AutomatableParameter::Ptr filterQParam
Parameter for the Q factor of the high pass and low pass filters.
juce::CachedValue< bool > normalise
Normalise the IR file when loading from the state.
AutomatableParameter::Ptr highPassCutoffParam
Cutoff frequency for the high pass filter to applied after the IR.
juce::CachedValue< bool > trimSilence
Trim silence from the IR file when loading from the state.
void reset() override
Should reset synth voices, tails, clear delay buffers, etc.
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Passed into Plugins when they are being initialised, to give them useful contextual information that ...
The context passed to plugin render methods to provide it with buffers to fill.