Iβm not the author of this script, but since it was buried deep in a thread, I thought I could post it here so it could help others, like it helped me. I only tweaked it so it could display the current song name (if in setlist mode) and the rackspace name on the LCD screen of the Keylab. You can of course create your own display logic by modifying the strings fed to the KeylabLCD function on line 74.
It has been tested with the Keylab Essential and the Keylab MkII.
var
SysexMng : SysexManager
KeylabMidiOut : MidiOutBlock // Replace 'KeylabMidiOut' with your own handle
KEYLAB_LCD_PRE : String
KEYLAB_LCD_SEP : String
KEYLAB_LCD_END : String
ASCII_STRING : String
ASCII_HEX_STRING : String array
Initialization
ASCII_STRING = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[Y]^_`abcdefghijklmnopqrstuvwxyz{|}><";
ASCII_HEX_STRING = ["20","21","22","23","24","25","26","27","28","29","2A","2B","2C","2D","2E","2F","30","31","32","33","34","35","36","37","38","39","3A","3B","3C","3D","3E","3F","40","41","42","43","44","45","46","47","48","49","4A","4B","4C","4D","4E","4F","50","51","52","53","54","55","56","57","58","59","5A","5B","5C","5D","5E","5F","60","61","62","63","64","65","66","67","68","69","6A","6B","6C","6D","6E","6F","70","71","72","73","74","75","76","77","78","79","7A","7B","7C","7D","7E","7F"];
KEYLAB_LCD_PRE = "# F0 00 20 6B 7F 42 04 00 60 01 "
KEYLAB_LCD_SEP = " 00 02 "
KEYLAB_LCD_END = " 00 F7"
End
// ******************** Utils ********************
Function Trim(s : String) returns string
/* Trim the string if its length is greater than 16 characters */
var temp : String // Avoid modifying argument in-place
If Length(s) > 16 Then
temp = CopySubstring(s, 0, 16)
Else
temp = s
End
result = temp
End
Function StringToHexString(str : String) Returns String
/* Hack provided by David-san */
var i : Integer
result = ""
For i=0; i<Length(str) ; i=i+1 Do
result = result + ASCII_HEX_STRING[IndexOfSubstring(ASCII_STRING, CopySubstring(str,i,1), True)]
End
End
// ***************** Keylab display *****************
Function KeylabLCD(line1 : String, line2 : String)
/* Display each line on the LCD screen of the Keylab */
var msg : String
msg = KEYLAB_LCD_PRE + StringToHexString(Trim(line1)) + KEYLAB_LCD_SEP + StringToHexString(Trim(line2)) + KEYLAB_LCD_END
SM_CreateSysexFromString(SysexMng, msg)
SM_SendMidiOut(SysexMng, KeylabMidiOut)
End
// ******************* Callbacks *******************
On Activate
var song : String
If InSetlistMode() Then
song = GetCurrentSongName()
Else
song = "N/A"
End
KeylabLCD("S:" + song, "R:" + GetRackspaceName())
End
The original post can be found here: Dynamic composition of a SysEx message with variable content and length