Unsolved Best Way to Record from DAW and Play Back in Synch?
Hi folks, I wish to record outgoing MIDI data from the host DAW, and then play it back from HISE in synch with the DAW (with the notes being triggered at their original times). If y'all can help me with this, I promise to write up the corresponding documentation and post my code (as I've done in the past).
Two ways I can think of here:
The potentially easy way is to use the record function of the MIDI Player. But as @Christoph-Hart notes, that's not what it's made for. I've been able to record into it from the host DAW (with a looooooong bar), and play stuff back—and use getEventList to get a nicely-wrapped array of Message Holders. But there are a lot of questions in the details of keeping everything in synch. The TransportHandler and transport functions of the MIDI player seem to overlap? @ulrik had some adventures here, though I think what he/you were doing was much more reasonable.
The more time-consuming (but probably proper) way is to create a real-time script that captures every incoming MIDI note. Package them manually into in an array of MessageHolders as the notes come in. Unless they're already coming in a Messages? It starts to get fuzzy. There's that nifty MIDI List thing, but that's only 128 entries long…I don't quite get what that's for? I'm back to the question of how to keep things in synch, but it's a little more clear because a TransportHanlder is definitely what's needed. (Although I might need stuff in the old JUCE Playhead struct? Like if the DAW transport is playing, but its recording, I don't want to try capturing anything.) But anyway, I use another real-time script to play the MIDI notes back—provided I get the clocks in synch, and know at all times where the DAW's playhead is. I think.
The callbacks to use in both seem pretty clear in both cases - a really nice feature of HISE. Transport starts. Transport stops.
Then there's the mighty MIDI Processor. I…honestly have no idea what it does. Only that it looks…useful. It's documented. I just…can't figure it out.
@clevername27 so I think you are on the right path with option2.
First you need some method(script) to record MIDI events arriving, and more specifically their time (as ppq?). So some "record" button that sets the script in ready mode, and on first event defines this as "start time", then everything is an offset from there until the user stops recording.
At this point you would have a long list of events, so playback should be pretty simple - especially if you are using ppq instead of milliseconds - so the playback can be tempo aligned with the DAW tempo