Created
February 21, 2019 11:32
-
-
Save olilarkin/1103fb82de3ace6d4c94660d534100d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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