I’m extremely new to C++ and JUCE so please bare with me.
I am trying to create a drum machine plugin, where I can cue drum sounds at certain samples (ex: play kick at sample number 88200). I’m trying to do this by adding custom MidiMessage note on events into a MidiBuffer and passing it into a sampler, as such:
void SamplerAudioProcessor::processBlock (AudioBuffer& buffer, MidiBuffer& midiMessages)
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i) buffer.clear (i, 0, buffer.getNumSamples()) midiMessages.addEvents(manualMidiBuffer, 0 , 352800, 0); mSampler.renderNextBlock(buffer, midiMessages, 0, buffer.getNumSamples());
where manualMidiBuffer has some MidiMessage note on events. It is clearly not working as I intend it to. Where am I going wrong?