behaviour of MIDIFlushOutput
behaviour of MIDIFlushOutput
- Subject: behaviour of MIDIFlushOutput
- From: "Evan Laforge" <email@hidden>
- Date: Tue, 9 Sep 2008 21:24:20 -0700
Hi, new to mac programming here.
Could someone explain the behaviour of the MIDIFlushOutput function?
I'm seeing something strange. It looks like scheduled note-offs are
retained, but played right after the flush, and *sometimes* a pitch
bend becomes a pitchbend to 0 (i.e. lowest position). The following
program reproduces this on my machine (System 10.5.4):
#include <CoreAudio/HostTime.h>
#include <CoreMIDI/CoreMIDI.h>
MIDIClientRef client;
MIDIPortRef port;
MIDIEndpointRef dest;
MIDITimeStamp start;
void
send(double offset, Byte b0, Byte b1, Byte b2)
{
Byte bytes[3] = {b0, b1, b2};
MIDIPacketList packets;
MIDIPacket *packet = MIDIPacketListInit(&packets);
MIDITimeStamp ts = start + offset * 1000000;
MIDIPacketListAdd(&packets, sizeof packets, packet, ts, 3, bytes);
MIDISend(port, dest, &packets);
}
int
main(int argc, char **argv)
{
MIDIClientCreate(CFSTR("core midi"), NULL, NULL, &client);
MIDIOutputPortCreate(client, CFSTR("output port"), &port);
dest = MIDIGetDestination(0);
start = AudioGetCurrentHostTime();
send(0, 144, 53, 70);
send(400, 128, 53, 70);
send(500, 144, 55, 70);
send(900, 128, 55, 70);
send(1000, 144, 57, 70);
send(1000, 224, 102, 76); // pitchbend
send(1400, 128, 57, 70);
usleep(500000);
MIDIFlushOutput(NULL);
sleep(3);
return 0;
}
When run, here's what a separate midi monitor shows:
(175987598,"IAC Driver IAC Bus 1",ChannelMessage 0 (NoteOn 53 70))
(175987998,"IAC Driver IAC Bus 1",ChannelMessage 0 (NoteOff 53 70))
(175988098,"IAC Driver IAC Bus 1",ChannelMessage 0 (NoteOn 55 70))
(175988099,"IAC Driver IAC Bus 1",ChannelMessage 0 (NoteOff 55 64))
(175988099,"IAC Driver IAC Bus 1",ChannelMessage 0 (NoteOff 57 64))
(175988099,"IAC Driver IAC Bus 1",ChannelMessage 0 (PitchBend (-1.0)))
Notice how I got an extra NoteOff 57, even though the NoteOn was
descheduled by the flush. And more worryingly, the PitchBend -1,
which screws up synth state. Obviously, this is over IAC, I haven't
tried an external port yet.
Thanks!
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden