I'm going to write a VST plugin that both receives and sends
MIDI messages. Let's say it will be a kind of sequencer with ability
of being triggered by incoming MIDI messages. And I want
it to work with AudioMulch. AudioMulch with its new MIDI
routing feature seems to be well suited for such kind of plugins.
To test the feasibility of my idea I've created a simple plugin
(I'm using MS Windows) in which I have set
AEffect::numInputs and AEffect::numOutputs to 0,
AEffect::flags to (effFlagsCanReplacing | effFlagsProgramChunks).
I send audioMasterWantMidi in my effOpen handler, and also
respond with: receiveVstMidiEvent, receiveVstTimeInfo,
and sendVstMidiEvent to effCanDo message.
After loading it into AM it shows up with no audio in/outputs,
but with MIDI input and output, just as one would expect.
However there is a problem: AM sends each MIDI message
repeated twice at the same sample frame. For example
when I press a key on my MIDI keyboard, the plugin receives
effProcessEvents with two NoteOn messages with
exactly the same parameters including the same deltaFrames value.
The same applies to NoteOff and every other message.
Curiously enough, this only happens when something (some VST synth) is connected
to MIDI output of my plugin. When I disconnect the other plugin the problem goes away.
Is this a bug in AudioMulch, or am I doing something wrong?
BTW, I'm not calling audioMasterProcessEvents to forward messages to
the output, so it's not the case that I'm receiving what I have sent myself,
I'm just logging the incoming messages.