Kontakt Scripting - Load a MIDI File With The File Selector
When you initialize an instrument, an empty MIDI object is initialized with it. You can either start editing the object by defining a buffer size and inserting events, or by inserting a whole MIDI file.. In today’s video tutorial I will show you how to create a Performance View that lets you Load a MIDI File With The File Selector.
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.
So far we have looked at how you can import files using the load midi and insert midi commands. While functional, these commands aren’t very practical in the real world where you will need to access MIDI files on the fly.
Today we will look at a new command that allows you to load files from a directory and navigate back and forth between them. We’ll use a new ui control, ui_file_selector.
Ui_file_selector has the following commands and built-in variables:
fs_get_filename – returns the filename of the last selected file in the ui file browser
ui-id – the id number of the ui control
0 – returns the filename w/out extension
1 – returns the filename with extension
2 – returns the whole path
fs_navigate – jump to the next/previous file in an ui file selector and trigger its callback.
ui-id – the ID number of the ui control
0: the previous file (in relation to the currently selected one) is selected
1: the next file (in relation to the currently selected one) is selected
Control_par_basepath – sets the basepath of the UI file browser. This control parameter can only be used in the init callback. Be careful with the number of subfolders of the basepath as it can take a long time to scan the subfolders. The scan process takes place every time the NKI is loaded.
Control_par_column_width – sets the width of the browser columns. This control parameter can only be used in the init callback.
Control_par_filepath – sets the actual path of the UI file browser which must be a subpath of the basepath. This control parameter is useful for recalling the last status of the browser upon loading the instrument. It can only be used in the init callback.
Control_par_file_type – sets the file type for file selector. It an only be used in the init callback. The following file types are available:
Remember to leave a comment to let us know what you think about the video, how you plan on using the techniques you have learned or if want to give us some feedback!