What's new

Importing MIDI sequences into Kontakt (and playing them back)

olmerk

Member
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...
I measured the delay using ENGINE_UPTIME and it is about 0,5sec between I hit play button and the first midi event plays. That's too much I think and I can't decrease it...

Could you please tell me what is a tick timewise? I understand what is setting the listener to ms (with $NI_SIGNAL_TIMER_MS), but setting it to ticks is somewhat still obscure for me. A MIDI file is just a list of events, and if Kontakt disregards tempo information, thus mf_get_next() command, being looped, can run trough all midi events in a split of a second. But it doesn't. Obviously that ticks have some time interval.
 

EvilDragon

KSP Wizard
Tick is a MIDI time unit lower than a beat (quarter note, most often). So when you run your listener in tick mode at maximum of 24 ticks per quarter note, the interval is (1/BPM/24) milliseconds. The benefit of tick mode is that it automatically syncs to incoming tempo information, which ms mode doesn't do, since it's time linear.

What's happening in your note/play button callback? If you get half a second delay, I don't think it's listener callback's fault.
 

olmerk

Member
What's happening in your note/play button callback? If you get half a second delay, I don't think it's listener callback's fault.
Yes, I found the mistake by making more precise measurements of the delay inside script's blocks and discovering I have a delay of about 20-30ms when just pressing play button and 500ms when pressing a key. The reason was missed block of pgs_set_key_vals used in NI Studio Drummer script exactly for grid snapping. That caused a delay as snapping didn't work properly on_note.

So 20-30ms is a justified delay for 24 ticks resolution?

the interval is (1/BPM/24) milliseconds
That's a valuable input, thanks! But where from Kontakt retrieve info about BMP? If it runs in DAW - does it use a current tempo, set in the host (even if the transport is not running)? And what if Kontakt runs as a standalone? Does it use then some built-in standard BMP?
 

EvilDragon

KSP Wizard
It uses tempo of the DAW yes, even when transport is not running. In standalone, it uses tempo as defined in Master panel (unless you sync Kontakt to external tempo via MIDI controller).
 

olmerk

Member
Working with the midi-player I’ve noticed that it gets a midi file length by checking the last midi event. Generally like this:

mf_get_last($track_idx)
$mf_length := mf_get_pos()

But the last event is not always the end of a midi file. What if I want to have a rest (silence) between the release of the last note and end of the file? Check my picture. It visually demonstrates that the script gets mf_length incorrectly in that case. And as soon as it reads the last midi event it starts midi file playback right from the start, disregarding the last rest.

Is there any work-around for that?
 

Attachments

olmerk

Member
The problem is - no one knows what kind of odd measures user can put in the midi file. So which duration should script round mf_length to?
 

Lindon

VST/AU Developer
So what I did was let the user decide the length of playback, so:
1. User sets playback length to = (say) 8 bars
2. import midi file
3. play midi events: if next event > play-back length then go to start of midi file
if last event in midi file AND less than 8 bars wait(difference between 8 bars and last time)
 

Flaneurette

Active Member
The MIDI player I wrote, was a rather naïve hack. It proposed a practical way, or rather a proof of concept, that one could play midi files and display the notes inside Kontakt. It did not pretend anything beyond that. Perhaps, Kontakt is not the proper environment to work with MIDI. It certainly would not be my first choice. Is there benefit in doing so?
 

Lindon

VST/AU Developer
The MIDI player I wrote, was a rather naïve hack. It proposed a practical way, or rather a proof of concept, that one could play midi files and display the notes inside Kontakt. It did not pretend anything beyond that. Perhaps, Kontakt is not the proper environment to work with MIDI. It certainly would not be my first choice. Is there benefit in doing so?
its simple, quick, easy and reliable. Once you have your concepts sorted out.
 

topaz

Member
Is there still no way to have a midi loop in a script to trigger a sliced loop from inside kontakt on a given midi note ??
 

topaz

Member
I can't (lord knows I have tried)

I want to be able to have ie: this midi file on slot 1 to trigger a sliced drum loop (mapped to c3 up)
Even a simple script to get me going would help, hit a brick wall on this one :-(
 

Attachments

Lindon

VST/AU Developer
.. theres an example right here in this thread, or you could pay someone to do it for you.
 
Top Bottom