This script creates a MIDI channel menu with 64 options corresponding to MIDI channels and ports, maps incoming MIDI CC messages on that channel to MIDI notes for channel translation, and ignores CC messages not in the mapped ranges.
on init
set_script_title("CC ToPC Marcelo Duarte")
message("")
declare ui_menu $Channel1
declare $count
declare !port[4]
!port[0] := "[A]"
!port[1] := "[B]"
!port[2] := "[C]"
!port[3] := "[D]"
while ($count <= 63)
add_menu_item($Channel1,"Port: " & !port[$count / 16] & " Ch: " & $count mod
16 + 1,$count)
inc($count)
end while
make_persistent($Channel1)
end on
on midi_in
message($MIDI_BYTE_2)
if ($MIDI_COMMAND = 176 and $MIDI_CHANNEL = $Channel1 and (($MIDI_BYTE_1
>= 20 and $MIDI_BYTE_1 <= 23) or ($MIDI_BYTE_1 >= 32 and $MIDI_BYTE_1 <= 35)))
ignore_midi
if ($MIDI_BYTE_2 < 42)
set_midi(0,192,$MIDI_BYTE_1 - 20,0)
end if
if (($MIDI_BYTE_2 > 42) and ($MIDI_BYTE_2 < 84))
set_midi(0,192,$MIDI_BYTE_1 - 12,0)
end if
if ($MIDI_BYTE_2 > 84)
set_midi(0,192,$MIDI_BYTE_1,0)
end if
end if
if ($MIDI_COMMAND = 176 and $MIDI_CHANNEL = $Channel1 and ($MIDI_BYTE_1 >= 24
and $MIDI_BYTE_1 <= 31))
ignore_midi
set_midi($Channel1,192,$MIDI_BYTE_1,0)
end if
end on