11namespace tracktion {
inline namespace engine
14PhaserPlugin::PhaserPlugin (PluginCreationInfo info) : Plugin (info)
16 auto um = getUndoManager();
18 depth.referTo (state, IDs::depth, um, 5.0f);
19 rate.referTo (state, IDs::rate, um, 0.4f);
20 feedbackGain.referTo (state, IDs::feedback, um, 0.7f);
23PhaserPlugin::~PhaserPlugin()
25 notifyListenersOfDeletion();
28const char* PhaserPlugin::xmlTypeName =
"phaser";
32 sampleRate = info.sampleRate;
35 const float delayMs = 100.0f;
40void PhaserPlugin::deinitialise()
51 const double range =
pow (2.0, (
double) depth);
52 const double sweepUp =
pow (range, rate / (sampleRate / 2));
53 const double sweepDown = 1.0 / sweepUp;
55 const float delayMs = 100.0f;
58 double swpFactor = sweepFactor > 1.0 ? sweepUp : sweepDown;
71 const double coef = (1.0 - swp) / (1.0 + swp);
72 double*
const fv = filterVals[chan];
74 double t = inval + feedbackGain * fv[7];
78 fv[1] = coef * (fv[1] + t) - fv[0];
82 fv[3] = coef * (fv[3] + fv[1]) - fv[2];
86 fv[5] = coef * (fv[5] + fv[3]) - fv[4];
90 fv[7] = coef * (fv[7] + fv[5]) - fv[6];
94 inval += (
float)fv[7];
101 if (swp > maxSweep) swpFactor = sweepDown;
102 else if (swp < minSweep) swpFactor = sweepUp;
106 zeroDenormalisedValuesIfNeeded (*fc.
destBuffer);
109 sweepFactor = swpFactor;
114 return TRANS(
"Phaser Plugin");
117void PhaserPlugin::restorePluginStateFromValueTree (
const juce::ValueTree& v)
119 copyPropertiesToCachedValues (v, depth, rate, feedbackGain);
121 for (
auto p : getAutomatableParameters())
122 p->updateFromAttachedValue();
Type * getWritePointer(int channelNumber) noexcept
int getNumChannels() const noexcept
#define TRANS(stringLiteral)
#define JUCE_UNDENORMALISE(x)
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.
int bufferNumSamples
The number of samples to write into the audio buffer.
juce::AudioBuffer< float > * destBuffer
The target audio buffer which needs to be filled.
int bufferStartSample
The index of the start point in the audio buffer from which data must be written.