Friday, February 17, 2017

Recording generated MIDI to drag'n'drop object in Kontakt

Someone asked me to add MIDI drag'n'drop function to Rhythm Assembler sequencer. Apparently, in some DAWs recording MIDI notes generated by Kontakt is not quite trouble free. While adding this function to Rhythm Assembler would be a bit of a hassle, I thought, that capturing generated notes live and making the recording a drag'n'drop object inside Kontakt would be quite easy.

So, here's this simple script named "MIDI catch'n'drop". It will memorize all note on/note off messages (both send into Kontakt and those generated by instrument scripts) and write them into a drag'n'drop MIDI object. Suppose, you want to export a drum pattern from Kontakt instrument to MIDI. You load the instrument, put the catch'n'drop into empty script slot, press "start recording" button, start the drum sequencer, wait for the pattern to play through and then drag'n'drop midi pattern to your DAW or file system.

Some notes:
When you press "start recording" button, previous recording is deleted.
The script will only record notes generated by the instrument it's placed into and by scripts placed in previous script slots. So, it's best to place it in the last script slot.
Essentially this script is thought to help with instruments, which do not use MIDI object functionality. Instruments which actually use MIDI data, may have drag'n'drop function already available. Also note, that whenever you start recording in catch'n'drop script, it clears MIDI buffer in Kontakt. So, if the instrument is using MIDI object for note patterns, it will not play back anything, as the MIDI pattern will be deleted.
This script only records note on/note off messages.
While recording, the script will display buffer status and time of recording. Buffer defines how many notes you can record. When it goes to zero, the recording will stop and script will display message "buffer is full". Default buffer setting is 10000, so the script can record up to 5000 notes (two messages per note). You can rise buffer size in the script, changing $MIDI_BUFFER_SIZE, up to one million. Time is displayed in MIDI ticks (960 ticks per quarter note here).
If you plan to create a file, rather than dropping pattern straight into a DAW, you can change generated file name. Just double click "file_name" and enter new name. Note that it may not be possible while sequencer is running (it's Kontakt's "feature").

You can get the script here:
as preset file
or in plain text

Use at your own risk! This script is provided ‘as is’ and there is no warranty of any kind.