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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_Delay.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
11namespace tracktion { inline namespace engine
12{
13
15{
17
18 void ensureMaxBufferSize (int size)
19 {
20 if (++size > bufferSamples)
21 {
22 bufferSamples = size;
23 buffers[0].ensureSize ((size_t) bufferSamples * sizeof (float) + 32, true);
24 buffers[1].ensureSize ((size_t) bufferSamples * sizeof (float) + 32, true);
25
26 if (bufferPos >= bufferSamples)
27 bufferPos = 0;
28 }
29 }
30
31 void clearBuffer()
32 {
33 buffers[0].fillWith (0);
34 buffers[1].fillWith (0);
35 }
36
37 void releaseBuffer()
38 {
39 bufferSamples = 0;
40 bufferPos = 0;
41 buffers[0].setSize (0);
42 buffers[1].setSize (0);
43 }
44
45 int bufferPos = 0, bufferSamples = 0;
46 juce::MemoryBlock buffers[2];
47
48private:
50};
51
52
53//==============================================================================
54class DelayPlugin : public Plugin
55{
56public:
58 ~DelayPlugin() override;
59
60 //==============================================================================
61 static const char* getPluginName() { return NEEDS_TRANS("Delay"); }
62 static const char* xmlTypeName;
63
64 juce::String getName() const override { return TRANS("Delay"); }
65 juce::String getPluginType() override { return xmlTypeName; }
66 juce::String getSelectableDescription() override { return TRANS("Delay Plugin"); }
67 bool needsConstantBufferSize() override { return false; }
68
69 int getNumOutputChannelsGivenInputs (int numInputChannels) override { return juce::jmin (numInputChannels, 2); }
70 void initialise (const PluginInitialisationInfo&) override;
71 void deinitialise() override;
72 void reset() override;
73 void applyToBuffer (const PluginRenderContext&) override;
74
75 void restorePluginStateFromValueTree (const juce::ValueTree&) override;
76
77 juce::CachedValue<float> feedbackValue, mixValue;
79
80 AutomatableParameter::Ptr feedbackDb, mixProportion;
81
82 static float getMinDelayFeedbackDb() noexcept { return -30.0f; }
83
84
85private:
86 DelayBufferBase delayBuffer;
87
89};
90
91}} // namespace tracktion { inline namespace engine
void fillWith(uint8 valueToUse) noexcept
void setSize(size_t newSize, bool initialiseNewSpaceToZero=false)
void ensureSize(size_t minimumSize, bool initialiseNewSpaceToZero=false)
void applyToBuffer(const PluginRenderContext &) override
Process the next block of data.
juce::String getName() const override
The name of the type, e.g.
juce::String getSelectableDescription() override
Subclasses must return a description of what they are.
int getNumOutputChannelsGivenInputs(int numInputChannels) override
This must return the number of output channels that the plugin will produce, given a number of input ...
void deinitialise() override
Called after play stops to release resources.
void reset() override
Should reset synth voices, tails, clear delay buffers, etc.
#define TRANS(stringLiteral)
#define NEEDS_TRANS(stringLiteral)
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
constexpr Type jmin(Type a, Type b)
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.