COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 03-02-2018, 04:20 PM   #1
RichB74
Human being with feelings
 
Join Date: Mar 2018
Posts: 3
Default 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
RichB74 is offline   Reply With Quote
Old 03-03-2018, 02:01 AM   #2
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: Holland
Posts: 2,890
Default

Are you setting IMidiMsg::mOffset? Becaue that controls the timing within the audio block.
Tale is offline   Reply With Quote
Old 03-03-2018, 02:39 AM   #3
RichB74
Human being with feelings
 
Join Date: Mar 2018
Posts: 3
Default

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;
SendMidiMsg(pMsg);
MIDIqueue.Remove();
}
..//..
MIDIqueue.Flush(nFrames);
}
............

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)
MIDIqueue.Add(&MIDImessage);
RichB74 is offline   Reply With Quote
Old 03-05-2018, 07:10 AM   #4
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: Holland
Posts: 2,890
Default

Quote:
Originally Posted by RichB74 View Post
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.
Tale is offline   Reply With Quote
Old 03-06-2018, 08:30 AM   #5
RichB74
Human being with feelings
 
Join Date: Mar 2018
Posts: 3
Default

Thanks Tale. I think that may be the issue - I'll have another go!
RichB74 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 11:27 AM.


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