Skip to content

Instantly share code, notes, and snippets.

@Xenakios
Created July 19, 2020 16:33
Show Gist options
  • Save Xenakios/42d8374516847e273de351a9f31d8c49 to your computer and use it in GitHub Desktop.
Save Xenakios/42d8374516847e273de351a9f31d8c49 to your computer and use it in GitHub Desktop.
class APGWrapper
{
public:
AudioProcessorGraph graph;
void prepare (const dsp::ProcessSpec& spec)
{
helperbuf.setSize(spec.numChannels, spec.maximumBlockSize);
graph.prepareToPlay(spec.sampleRate, spec.maximumBlockSize);
}
void process (const dsp::ProcessContextReplacing<float>& context) noexcept
{
auto& outblock = context.getOutputBlock();
helperbuf.setSize((int)outblock.getNumChannels(), (int)outblock.getNumSamples(), false, false, true);
outblock.copyTo(helperbuf);
graph.processBlock(helperbuf, midibuf);
outblock.copyFrom(helperbuf);
}
private:
AudioBuffer<float> helperbuf;
MidiBuffer midibuf;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment