Midi handling within Audio Plugin

Hi all, I am developing an audio plugin with Juce. It must be able to filter incoming midi message so that the ones coming from a specific midi channel will be used, while the other will be ignored (deleted from midibuffer or left there for midi thru).
I’m just learning Juce programming and I’m not sure about the best choice on how to do it.
Can someone give me a suggestion?
Should I subclass the Synthesizer::noteOn() method?
Thank you in advance

Your AudioProcessor::processBlock() function receives incoming MIDI messages. You can simply filter the notes there. From the AudioProcessor::processBlock() docs:

[code]"If the filter is receiving a midi input, then the midiMessages array will be filled with the midi messages for this block. Each message’s timestamp will indicate the message’s time, as a number of samples from the start of the block.

Any messages left in the midi buffer when this method has finished are assumed to be the filter’s midi output. This means that your filter should be careful to clear any incoming messages from the array if it doesn’t want them to be passed-on."[/code]

You’ll also want to look at the MidiBuffer class! Good luck.

Thank you.
I’ll check the Midibuffer class.

I have a question very related to this one: I want to modify the events in the incoming MIDI stream; as far as I can tell, MidiBuffer::Iterator only allows a read-only access to the events. Is creating a new MidiBuffer the only way? Is it possible to modify the events in place?


The buffer is a packed read-only structure, so yes: create a new buffer with whatever data you want to return, and then use swapWith() to swap the old and new buffers.

Thanks Jules, I had overlooked swapWith() 8)