MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / ProcessAudio

Method ProcessAudio

Source/ButterworthFilterEffect.cpp:58–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58void ButterworthFilterEffect::ProcessAudio(double time, ChannelBuffer* buffer)
59{
60 PROFILER(ButterworthFilterEffect);
61
62 if (!mEnabled)
63 return;
64
65 float bufferSize = buffer->BufferSize();
66 mDryBuffer.SetNumActiveChannels(buffer->NumActiveChannels());
67
68 const float fadeOutStart = mFSlider->GetMax() * .75f;
69 const float fadeOutEnd = mFSlider->GetMax();
70 bool fadeOut = mF > fadeOutStart;
71 if (fadeOut)
72 mDryBuffer.CopyFrom(buffer);
73
74 for (int i = 0; i < bufferSize; ++i)
75 {
76 ComputeSliders(i);
77 if (mCoefficientsHaveChanged)
78 {
79 mButterworth[0].Set(mF, mQ);
80 for (int ch = 1; ch < buffer->NumActiveChannels(); ++ch)
81 mButterworth[ch].CopyCoeffFrom(mButterworth[0]);
82 mCoefficientsHaveChanged = false;
83 }
84 for (int ch = 0; ch < buffer->NumActiveChannels(); ++ch)
85 buffer->GetChannel(ch)[i] = mButterworth[ch].Run(buffer->GetChannel(ch)[i]);
86 }
87
88 if (fadeOut)
89 {
90 for (int ch = 0; ch < buffer->NumActiveChannels(); ++ch)
91 {
92 float dryness = ofMap(mF, fadeOutStart, fadeOutEnd, 0, 1);
93 Mult(buffer->GetChannel(ch), 1 - dryness, bufferSize);
94 Mult(mDryBuffer.GetChannel(ch), dryness, bufferSize);
95 Add(buffer->GetChannel(ch), mDryBuffer.GetChannel(ch), bufferSize);
96 }
97 }
98}
99
100void ButterworthFilterEffect::DrawModule()
101{

Callers

nothing calls this directly

Calls 12

ofMapFunction · 0.85
MultFunction · 0.85
AddFunction · 0.85
BufferSizeMethod · 0.80
SetNumActiveChannelsMethod · 0.80
NumActiveChannelsMethod · 0.80
GetChannelMethod · 0.80
RunMethod · 0.80
GetMaxMethod · 0.45
CopyFromMethod · 0.45
SetMethod · 0.45
CopyCoeffFromMethod · 0.45

Tested by

no test coverage detected