Post by ki on Nov 17, 2018 19:27:04 GMT
AB forum user ohwell asked in an AB forum thread for a script to remap the limited note range of his controller into the full note range used by Ruismaker Noir.
So i made one
So i made one

# SpreadNoteRange - spread out a range of notes to full 00-7F range.
# Version v2 / 17.11.2018 -ki
#
# Used for converting the limited key range of an external controller
# or keyboard to full 128 notes supported by Ruismaker Noir.
#
# The script needs two input variables specifiying the lowest and highest
# note of the controller. See instructions below.
#
# Left label always outputs the incomming note in hexadecimal
# Right label outputs transformed note in hexadecimal or a hyphen
# if the incomming note is out of the scripted range
#
# Installation
# =============
# You can find out the hexadecimal values of the lowest and highest input
# note by pressing „Install Rules“ to start the script and then pressing
# the keys with the lowest and highest note on the controller one after
# the other - note down their hex value shown in the left label.
#
# Then edit the following lines with the values you aquired and press
# „Install Rules“ again to update/restart the script.
# It is also advised that you then use the Au hosts preset mechanism to save
# the script into a „SpreadNoteRange“ preset.
# Saving a session will also save the script and when reloading, it is
# installed and run automatically.
IF LOAD
ASS J0 = 24 # minNote Lowest incomming note in hexadecimal
ASS J1 = 30 # maxNote Highest incomming note in hexadecimal
END
# // ========== Do not modify below this line if you dont know what you are doing ====
#
# Author:
# -ki https://forum.audiob.us/profile/_ki
#
# Versions:
# v2 / 17.11.2018 Better range spreading by using fixed point math and rounding
# v1 / 17.11.2018 Inital version
9X XX 00 = 8X # // Remap NoteOn with vel=0 to NoteOff
# // Display incomming NoteOn in hexadecimal on left label
IF MT == 90 # if (NoteOn) {
SET LB0 M1 # show(LeftLabel, inputNote)
END # }
IF MT <= 90 # if (NoteOn or NoteOff) {
ASS K1 = FFFF # outputNote = OutOfRange
# // Transform NoteOn AND NoteOff if in the given range
IF M1 >= J0 # if (inputNote >= minNotej {
IF M1 <= J1 # if (inputNote <= maxNote) {
MAT J2 = J1 - J0 # notesInRange = maxNote - minNote
MAT J3 = 7F00 / J2 # scaleFactor = 127 * 256 / notesInRange
MAT I0 = M1 - J0 # deltaNote = inputNote - minNote
MAT I1 = I0 * J3 # scaledDelta = deltaNote * scaleFactor
MAT I2 = I1 + FF # roundedScakedDelta = scaledDelta+ 255
MAT K1 = I2 / 100 # outputNote = roundedScaledDelta / 256
SND M0 K1 M2 # send(inputCmd, outputNote, inputVelocity)
END # }
END # }
# // On NoteOn display either a hypen or the output note
IF MT == 90 # if (NoteOn) {
IF K1 == FFFF # if (outputNote == OutOfRange) {
SET LB1 S- # show(RightLabel, „-„)
END # }
IF K1 != FFFF # if (outputNote != OutOfRange) {
SET LB1 K1 # show(RightLabel, outputNote)
END # }
END # }
XX = XX +B # // Block the initially received NoteOn and NoteOff
END # }