CoreMIDI schedule ahead
CoreMIDI schedule ahead
- Subject: CoreMIDI schedule ahead
- From: Jonatan Liljedahl <email@hidden>
- Date: Wed, 16 Mar 2016 22:27:21 +0100
Hi,
When CoreMIDI delivers an event to a virtual destination endpoint,
it's delivered "on time", +/- 1ms or so.
However, I'd like to use the timestamp for the events to set the
sample frame offset when calling MusicDeviceMIDIEvent() or the midi
block of an AUv3 unit.
Getting the packets delivered for time "now" is not enough in this
case, I would need to get them a bit (at least one buffer duration +
safety margin) before "now" so that there's room to handle them on
time in the audio thread before rendering the AU.
Of course this is only theoretically possible if the packets was sent
with a timestamp in the future from the start, but the main usage here
is MIDI from other apps over virtual endpoints so that's not a
problem.
There is the `kMIDIPropertyAdvanceScheduleTimeMuSec` property that can
be set on a virtual destination, to get the packets directly as they
are sent. However, that means I need to manage the scheduling myself,
which gets tricky by the fact that events might not be sent with
increasing timestamps, for example if multiple sources are sending to
this virtual destinations with different amounts of ahead-time. That
means I need a priority queue, and that it has to be real-time audio
safe (lock-free/wait-free, etc.. any suggestions are welcome!).
Maybe that's the only way to solve it? Or is there any way I could get
CoreMIDI to use its already existing scheduler, but just not deliver
packets for time "now" but some short time before that?
Cheers
--
/Jonatan
http://kymatica.com
_______________________________________________
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