
When playing without transport, it just increments $cur_song_pos variable on every listener tick (listener runs even if transport is off).Īs for wait($diff), I think this is for MIDI events that are not exactly happening on the listener tick grid. Not sure if this is your intention, though. Sure you'll get a delay, but it will be on grid. As mentioned, if you need your MIDI playback to start right smack on the grid, you need to use input quantize in a script slot before your MIDI playback engine. However I don't think that 1/32T is anywhere near "significant", since that's the worst case scenario if you hit a key RIGHT after a listener tick has happened. It is what it is, that delay is something you can't go without. You cannot fix it (at least AFAIK) - it's inherent to the design of listener callback. So I still can’t get what this wait($diff) is necessary for? But when I commented out that block nothing happened in the script action.
#Kontakt 6 player midi code
And it’s still not clear for me where KSP takes info about absolute time measure for a beat when playing back a midi in standalone version or when transport is not running? I supposed that wait($diff) in the code above was responsible for that. When I put simply $LISTENER_BEAT_LENGTH_TICKS := 960 the midi playback speeds up tremendously, though “reaction time”, i.e. Moreover the delay stays the same even when I change $LISTENER_RESOL, I think because it appears in $LISTENER_BEAT_LENGTH_TICKS := 960 / ($LISTENER_RESOL) $start_of_beat := $end_of_beat - $LISTENER_BEAT_LENGTH_TICKSĮven with the highest resolution $LISTENER_RESOL := 24 there is a significant delay.
#Kontakt 6 player midi mod
$end_of_beat := $end_of_beat mod $mf_length If (mf_get_command() = $MIDI_COMMAND_NOTE_OFF or (mf_get_command() = $MIDI_COMMAND_NOTE_ON and mf_get_byte_two() = 0)) If (mf_get_command() = $MIDI_COMMAND_NOTE_ON and mf_get_byte_two() # 0) $end_of_beat := $cur_song_pos mod $mf_length + $LISTENER_BEAT_LENGTH_TICKS $start_of_beat := $cur_song_pos mod $mf_length Mf_get_next_at(0, $cur_song_pos mod $mf_length) $cur_song_pos := $cur_song_pos + $LISTENER_BEAT_LENGTH_TICKS Set_listener($NI_SIGNAL_TIMER_BEAT, $LISTENER_RESOL)

And so on.ĭoes this methodology make sense? Or, as is so often the case, am I missing some much easier way of playing back MIDI sequences in Kontakt?ĭeclare const $LISTENER_BEAT_LENGTH_TICKS := 960 / ($LISTENER_RESOL) Then $NI_SIGNAL_TIMER_BEAT gets triggered again for the next beat by the on listener callback, where the sequence continues for the stuff that occurs during beat 2. In this callback, there would be an "if loop is triggered" statement, in which case my scrupt would play the first note, then use "wait" to delay an 1/8 note's worth of time to play the second note. I plan to accomplish this by using the "on listener" callback with $NI_SIGNAL_TIMER_BEAT as the relevant parameter. (My plan would be that a user hits the "Go" button on my instrument slightly *before* the downbeat.) Question #2 - I want Kontakt to play back a preprogrammed sequence (drum loop) that I include with my Kontakt instrument, but I'd like to add a feature where you can assure that this drum loop plays in sync with the user's sequencer, even if you don't start the Kontakt drum loop exactly on the beat. Is this indeed what everyone has been referring to? In other words, there isn't some special "Import MIDI file" button hiding somewhere, is there? I've been doing a little hunting and the only method I can see for doing this is the factory "Session Recorder" script. I seem to remember people talking about being able to import MIDI sequences into K5.
