Unsolved How to Play Back Notes at Specific Timestamps?
In my last post, I shared a general-purpose snippet for capturing incoming MIDI notes in real-time, regardless of context.
But how to play them back (sample-accurate, if possible) at their timestamps, in synch with a host?
The immediate way is with a MIDI Player, but there seem to be limitations that preclude this — I don't really know. Here are the issues I've encountered:
- Based on the API, and some documentation by @Christoph-Hart, that the MIDI player is only intended for short passages, mainly loops.
- An empty sequence must first be created for a MIDI Player—this sequence can apparently only be one bar long, and a time signature must be established. However, incoming MIDI data may be many bars, and have multiple time signatures.
- It appears that both a Transport Hanlder and a MIDI Player would be required for this approach, but there seem to be overlapping methods here leading to some ambiguity. (I posted a guess on this in the previous thread.)
Any ideas or thoughts? I think this is of general interest to many users, and as always, I'll post a fully commented snippet (once I understand the solution).
that the MIDI player is only intended for short passages, mainly loops.
No, it can have any arbitrary length.
this sequence can apparently only be one bar long,
That's not correct. You can set any length by giving the MidiPlayer a time signature object with
I think the main problem with the MIDI Player is that it's highly under documented up to a point where it gets ridiculous - and if I'm being honest, every time I'm using the MIDI Player, I end up looking in the source code how it works and a programmer with a little bit more self-awareness would have taken this as hint to improve the docs...
It appears that both a Transport Hanlder and a MIDI Player would be required for this approach, but there seem to be overlapping methods here leading to some ambiguity.
Of course they have some overlapping methods, but that's because the Transport Handler will act as external synchronization source for multiple MIDI Players. These are the cases where you want to hook up one or more MIDI players to the transport handler:
- multiple MIDI players that should play in sync
- synchronisation to an external clock like the DAW timeline.
However If you start the MIDI players from a note callback (I'm doing this in PercX) you can synchronize them without the need of the transport handler.