Kontakt Tutorials
Kontakt Scripting - How To Insert A MIDI File Into The MIDI Object
Learn how to Insert, export and navigate a MIDI File Into The MIDI Object in Kontakt with scripting. When you initialise an instrument, an empty MIDI object is initialised with it. You can either start editing the object by defining a buffer size and inserting events, or by inserting a whole MIDI file.
You can only use one MIDI object at a time within an NKI.
The MIDI object is held in memory and can be accessed by any of the script slots. It is possible to add, remove and edit MIDI events within the object, as well as import and export MIDI files.
The Multi Script can also hold one MIDI object, and handles it in the same way as an NKI.
If you want to create a MIDI sequence from scratch, you first need to assign a buffer size, which effectively creates a number of inactive MIDI events. From this point you can activate (ie. insert) and edit MIDI events using the MIDI event commands.
Loading a MIDI file in Kontakt
You can also load a MIDI file to use or edit the data in a script. Depending on the command and variables you use, this will either be combined with any existing MIDI data, or will replace the existing data. It should be noted that loading a MIDI file is an asynchronus command, and thus the common asynchronus loading commands and working methods apply.
Exporting a MIDI file in Kontakt
MIDI objects can be exported from KONTAKT either by using the save_midi_file() command, or via a drag and drop enabled label element. In either case, it is possible to define the export area, both in terms of start and end times, as well as the start and end tracks, by using the mf_set_export_area() command.
MIDI events in KONTAKT’s MIDI object are given event parameters, which are accessed using either the mf_get_event_par() or mf_set_event_par() commands. A unique event ID can be used to access a specific event, or you can navigate through events by position. The event ID is assigned whenever a MIDI event is created or loaded.
Navigating a MIDI file in Kontakt
In order to access the event data of a loaded MIDI file, you can navigate around the MIDI events with a position marker, something analogous to a play-head. The position marker will focus on one single event at a time, allowing you to use a variety of commands to access or edit the event‘s parameters.
You have the option to either navigate from one event to the next, or to specify exact positions in MIDI
Leave a question in the comments if you get stuck!