Hello everyone
Lately I have been using this scriptlet made with some gpt help. Maybe it is helpful for you. This scriptlet provides MIDI routing and transformation designed for expressive performance control. I use it because I do the complete MIDI routing in the wiring view.
Multi-Source Routing
-
Converts Channel Aftertouch into up to three independent CC outputs
-
Provides three additional CC-to-CC mapping slots
-
Each slot processes one input source and can generate multiple output target
Multi-Target Output Per Slot
Each slot can transmit to:
-
Up to three independent target CC numbers
-
Each target can use a different MIDI channel (1–16)
Per-Target Scaling
Each target supports individual:
-
Minimum output value
-
Maximum output value
This allows different modulation ranges for each controlled parameter.
Response Curve Processing
Each slot includes an adjustable curve that smoothly blends between:
-
Logarithmic response
-
Linear response
-
Exponential response
This allows precise control over controller sensitivity.
Slot Control Options
Every slot includes:
-
Enable switch
Activates or bypasses the slot
-
Invert switch
Reverses controller polarity (0 ↔ 127)
-
Pass-Through switch
Allows the original MIDI message to pass alongside the mapped output
All targets within a slot share the same input and curve processing, but each output can have unique scaling and channel routing.
If there is any issue let me know.
code:
// ============================================================
// ================= AFTERTOUCH SLOT ===========================
// ============================================================
var AT_Enable : Parameter 0..1 = 1
var AT_Invert : Parameter 0..1 = 0
var AT_PassThrough : Parameter 0..1 = 0
var AT_Target_CC1 : Parameter 0..127 = 1
var AT_Target_CC2 : Parameter 0..127 = 11
var AT_Target_CC3 : Parameter 0..127 = 74
var AT_Ch1 : Parameter 1..16 = 1
var AT_Ch2 : Parameter 1..16 = 1
var AT_Ch3 : Parameter 1..16 = 1
var AT_Curve : Continuous Parameter = 0.5
var AT_Min1 : Parameter 0..127 = 63
var AT_Max1 : Parameter 0..127 = 127
var AT_Min2 : Parameter 0..127 = 63
var AT_Max2 : Parameter 0..127 = 127
var AT_Min3 : Parameter 0..127 = 63
var AT_Max3 : Parameter 0..127 = 127
// ============================================================
// ================= SLOT 2 ====================================
// ============================================================
var CC2_Enable : Parameter 0..1 = 1
var CC2_Invert : Parameter 0..1 = 0
var CC2_PassThrough : Parameter 0..1 = 0
var CC2_Source : Parameter 0..127 = 2
var CC2_Target_CC1 : Parameter 0..127 = 11
var CC2_Target_CC2 : Parameter 0..127 = 74
var CC2_Target_CC3 : Parameter 0..127 = 71
var CC2_Ch1 : Parameter 1..16 = 1
var CC2_Ch2 : Parameter 1..16 = 1
var CC2_Ch3 : Parameter 1..16 = 1
var CC2_Curve : Continuous Parameter = 0.5
var CC2_Min1 : Parameter 0..127 = 0
var CC2_Max1 : Parameter 0..127 = 127
var CC2_Min2 : Parameter 0..127 = 0
var CC2_Max2 : Parameter 0..127 = 127
var CC2_Min3 : Parameter 0..127 = 0
var CC2_Max3 : Parameter 0..127 = 127
// ============================================================
// ================= SLOT 3 ====================================
// ============================================================
var CC3_Enable : Parameter 0..1 = 1
var CC3_Invert : Parameter 0..1 = 0
var CC3_PassThrough : Parameter 0..1 = 0
var CC3_Source : Parameter 0..127 = 12
var CC3_Target_CC1 : Parameter 0..127 = 74
var CC3_Target_CC2 : Parameter 0..127 = 1
var CC3_Target_CC3 : Parameter 0..127 = 91
var CC3_Ch1 : Parameter 1..16 = 1
var CC3_Ch2 : Parameter 1..16 = 1
var CC3_Ch3 : Parameter 1..16 = 1
var CC3_Curve : Continuous Parameter = 0.5
var CC3_Min1 : Parameter 0..127 = 0
var CC3_Max1 : Parameter 0..127 = 127
var CC3_Min2 : Parameter 0..127 = 0
var CC3_Max2 : Parameter 0..127 = 127
var CC3_Min3 : Parameter 0..127 = 0
var CC3_Max3 : Parameter 0..127 = 127
// ============================================================
// ================= SLOT 4 ====================================
// ============================================================
var CC4_Enable : Parameter 0..1 = 1
var CC4_Invert : Parameter 0..1 = 0
var CC4_PassThrough : Parameter 0..1 = 0
var CC4_Source : Parameter 0..127 = 13
var CC4_Target_CC1 : Parameter 0..127 = 71
var CC4_Target_CC2 : Parameter 0..127 = 10
var CC4_Target_CC3 : Parameter 0..127 = 93
var CC4_Ch1 : Parameter 1..16 = 1
var CC4_Ch2 : Parameter 1..16 = 1
var CC4_Ch3 : Parameter 1..16 = 1
var CC4_Curve : Continuous Parameter = 0.5
var CC4_Min1 : Parameter 0..127 = 0
var CC4_Max1 : Parameter 0..127 = 127
var CC4_Min2 : Parameter 0..127 = 0
var CC4_Max2 : Parameter 0..127 = 127
var CC4_Min3 : Parameter 0..127 = 0
var CC4_Max3 : Parameter 0..127 = 127
// ============================================================
// ================= VARIABLES =================================
// ============================================================
var ccMsg : ControlChangeMessage
// ============================================================
// ================= CURVE =====================================
// ============================================================
Function ApplyCurve(v : Double, curveAmount : Double) Returns Double
var resultVal : Double
var strength : Double
strength = (curveAmount - 0.5) * 2.0
if strength > 0.0 then
resultVal = v * (1.0 - strength) + (v * v) * strength
elsif strength < 0.0 then
resultVal = v * (1.0 + strength) + (1.0 - (1.0 - v) * (1.0 - v)) * (-strength)
else
resultVal = v
end
result = resultVal
End
// ============================================================
// ================= UNIVERSAL TARGET SENDER ===================
// ============================================================
Function SendTargets3(value : Integer,
invert : Integer,
t1 : Integer, ch1 : Integer, min1 : Integer, max1 : Integer,
t2 : Integer, ch2 : Integer, min2 : Integer, max2 : Integer,
t3 : Integer, ch3 : Integer, min3 : Integer, max3 : Integer,
curve : Double)
var norm : Double
var midiValue : Integer
var scaled : Integer
if invert == 1 then
value = 127 - value
end
norm = value / 127.0
norm = ApplyCurve(norm, curve)
midiValue = Round(norm * 127.0)
scaled = ScaleInt(midiValue, 0, 127, min1, max1)
ccMsg = MakeControlChangeMessageEx(t1, scaled, ch1)
SendNow(ccMsg)
scaled = ScaleInt(midiValue, 0, 127, min2, max2)
ccMsg = MakeControlChangeMessageEx(t2, scaled, ch2)
SendNow(ccMsg)
scaled = ScaleInt(midiValue, 0, 127, min3, max3)
ccMsg = MakeControlChangeMessageEx(t3, scaled, ch3)
SendNow(ccMsg)
End
// ============================================================
// ================= AFTERTOUCH ================================
// ============================================================
On AfterTouchEvent(m : AfterTouchMessage)
var value : Integer
value = GetAfterTouchValue(m)
if AT_Enable == 1 then
SendTargets3(value, AT_Invert,
AT_Target_CC1, AT_Ch1, AT_Min1, AT_Max1,
AT_Target_CC2, AT_Ch2, AT_Min2, AT_Max2,
AT_Target_CC3, AT_Ch3, AT_Min3, AT_Max3,
AT_Curve)
if AT_PassThrough == 1 then
SendNow(m)
end
else
SendNow(m)
end
End
// ============================================================
// ================= CC EVENTS =================================
// ============================================================
On ControlChangeEvent(c : ControlChangeMessage)
var value : Integer
var number : Integer
var handled : Boolean = false
value = GetCCValue(c)
number = GetCCNumber(c)
if number == CC2_Source then
if CC2_Enable == 1 then
SendTargets3(value, CC2_Invert,
CC2_Target_CC1, CC2_Ch1, CC2_Min1, CC2_Max1,
CC2_Target_CC2, CC2_Ch2, CC2_Min2, CC2_Max2,
CC2_Target_CC3, CC2_Ch3, CC2_Min3, CC2_Max3,
CC2_Curve)
handled = true
if CC2_PassThrough == 1 then
SendNow(c)
end
else
SendNow(c)
end
end
if number == CC3_Source then
if CC3_Enable == 1 then
SendTargets3(value, CC3_Invert,
CC3_Target_CC1, CC3_Ch1, CC3_Min1, CC3_Max1,
CC3_Target_CC2, CC3_Ch2, CC3_Min2, CC3_Max2,
CC3_Target_CC3, CC3_Ch3, CC3_Min3, CC3_Max3,
CC3_Curve)
handled = true
if CC3_PassThrough == 1 then
SendNow(c)
end
else
SendNow(c)
end
end
if number == CC4_Source then
if CC4_Enable == 1 then
SendTargets3(value, CC4_Invert,
CC4_Target_CC1, CC4_Ch1, CC4_Min1, CC4_Max1,
CC4_Target_CC2, CC4_Ch2, CC4_Min2, CC4_Max2,
CC4_Target_CC3, CC4_Ch3, CC4_Min3, CC4_Max3,
CC4_Curve)
handled = true
if CC4_PassThrough == 1 then
SendNow(c)
end
else
SendNow(c)
end
end
if handled == false then
SendNow(c)
end
End