Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
static constexpr int kNumModSources = 10;
class MySynth
{
public:
MySynth()
{
SetScratchBuffers(DEFAULT_BLOCK_SIZE);
}
// call in OnReset()
void SetScratchBuffers(int blockSize)
{
// could check and only resize if blockSize > current blocksize
mModScratch.Resize(blockSize * kNumModSources); // resize scratch buffers
memset(mModScratch.Get(), 0, blockSize * kNumModSources * sizeof(float)); zero the memory
mModulations.Empty(); // empty the ptr list
for(auto i = 0; i < kNumModSources; i++)
{
mModulations.Add(mModScratch.Get() + (i * blockSize)); // update the ptrs
}
}
void ProcessBlock(int nFrames)
{
float** moduation = mModulations.GetList();
float* mod1 = modulation[0];
for(int i=0i<nFrames;i++)
{
*mod1 = runMyLFO(); // update per sample
mod1++;
}
}
private:
WDL_TypedBuf<float> mModScratch;
WDL_PtrList<float> mModulations;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment