Cockos Incorporated Forums

Cockos Incorporated Forums (
-   WDL users forum (
-   -   Using IMidiQueue for MIDI output only (

RichB74 03-02-2018 04:20 PM

Using IMidiQueue for MIDI output only
I'm trying to make a plugin that generates MIDI CC without any MIDI input, but generates MIDI data based on audio volume. It works fine when I limit the CC data to one PDR block, but I'm struggling to get get an IMidiQueue to output MIDI data at better resolution than one block.

Does anyone have a snippet of code that shows how to send out the MIDI data added to an IMidiQueue such that the data is sent 'during' each audio processing block? - not too bothered if the data is sent a block late - it's only MIDI after all ;)

I don't think ProcessMidiMsg will help here, as it deals with incoming MIDI messages.

Putting it in ProcessDoubleReplacing would probably be OK from a performance point of view for this application, but everything I have tried so far has failed - all messages are still sent at the block rate.

Any ideas? - thanks

Tale 03-03-2018 02:01 AM

Are you setting IMidiMsg::mOffset? Becaue that controls the timing within the audio block.

RichB74 03-03-2018 02:39 AM

Hi Tale.

Yes, but there must be something wrong with the method. (or my understanding!)

for (int s = 0; s < nFrames; ++s, ++in1, ++in2, ++out1, ++out2) {
while (!MIDIqueue.Empty())
IMidiMsg* pMsg = MIDIqueue.Peek();
if (pMsg->mOffset > s) break;

and to generate the MIDI data:

MIDImessage.MakeControlChangeMsg(IMidiMsg::EContro lChangeMsg::kPolyModeOn, value, chan)
MIDImessage.mOffset = offset; //(passed the value of s to offset here)

Tale 03-05-2018 07:10 AM


Originally Posted by RichB74 (Post 1961957)
MIDImessage.mOffset = offset; //(passed the value of s to offset here)

Well, as long as your offset if in samples from the start of the next audio buffer (i.e. not from the current sample!), this should work I guess.

BTW, you don't have to loop through all samples i.e. you could probably do this more efficient, because it doesn't matter when you SendMidiMsg(), as long as the offset is correct.

RichB74 03-06-2018 08:30 AM

Thanks Tale. I think that may be the issue - I'll have another go!

All times are GMT -7. The time now is 04:47 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.