Hi all this is more of a beginner C++ question than a JUCE question but anyhow …
How would I put this code into a function inside the audio ?
What’s a good way to do this?
I am trying to put some midi processing into a function …
Not sure if this is kosher !
Thanks for your generous replies
//can/should I declare these 3 variables globally
//at the top of PluginProcessor.cpp
MidiMessage m;
MidiBuffer processedMidi;
int time;
void WaylochorderAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
{
ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
buffer.clear();
for (MidiBuffer::Iterator i (midiMessages); i.getNextEvent (m, time);)
{
if (m.isNoteOff()){
sendAllNotesOff(m.getChannel(), time);
}
midiMessages.swapWith (processedMidi);
}
void WaylochorderAudioProcessor::sendAllNotesOff (int channel, int Time)
{
for (int i = 0; i < 128; ++i){
m = MidiMessage::noteOff(channel, i, 0.0f);
processedMidi.addEvent(m, Time);
}
}