on init set_ui_height(5) declare ui_label $Label (6,1) declare ui_knob $Input (0,63,1) declare ui_knob $Output (0,63,1) declare ui_knob $CC (0,119,1) declare ui_switch $Reset declare ui_table %Map[128] (6,6,127) declare $i declare %store[128 * 120] declare !port[4] !port[0] := "[A]" !port[1] := "[B]" !port[2] := "[C]" !port[3] := "[D]" declare !names[64] $i := 0 while ($i < 64) !names[$i] := " " & !port[$i / 16] & " " & ($i mod 16) + 1 inc($i) end while $i := 0 while ($i < 128 * 120) %store[$i] := $i mod 128 inc($i) end while set_control_par(get_ui_id($Reset),$CONTROL_PAR_TEXT_ALIGNMENT,1) set_control_par(get_ui_id($Label),$CONTROL_PAR_TEXT_ALIGNMENT,1) set_control_par(get_ui_id($Label),$CONTROL_PAR_WIDTH,518) set_control_par(get_ui_id(%Map),$CONTROL_PAR_WIDTH,518) set_control_par(get_ui_id(%Map),$CONTROL_PAR_HEIGHT,133) move_control_px($Label,60,2) move_control_px(%Map,60,23) move_control_px($Reset,428,181) move_control($Input,2,9) move_control($CC,3,9) move_control($Output,4,9) make_persistent($Input) make_persistent($CC) make_persistent($Output) make_persistent(%store) read_persistent_var($Input) read_persistent_var($CC) read_persistent_var($Output) read_persistent_var(%store) $i := 0 while ($i < 128) %map[$i] := %store[($CC * 128) + $i] inc($i) end while set_text($Label,"MIDI CC Remapping") set_text($CC,"CC Num") set_knob_label($Input,!names[$Input]) set_knob_label($Output,!names[$Output]) message("") end on on ui_control ($Input) set_knob_label($Input,!names[$Input]) end on on ui_control ($CC) $i := 0 while ($i < 128) %map[$i] := %store[($CC * 128) + $i] inc($i) end while end on on ui_control ($Output) set_knob_label($Output,!names[$Output]) end on on ui_control ($Reset) $i := 0 while ($i < 128) %map[$i] := $i %store[($CC * 128) + $i] := $i inc($i) end while $Reset := 0 end on on ui_control (%map) $i := 0 while ($i < 128) %store[($CC * 128) + $i] := %map[$i] inc($i) end while end on on midi_in if ($MIDI_CHANNEL = $Input and $MIDI_COMMAND = $MIDI_COMMAND_CC and in_range($MIDI_BYTE_1,0,119)) ignore_midi set_midi($Output,$MIDI_COMMAND_CC,$MIDI_BYTE_1,%store[($MIDI_BYTE_1 * 128) + $MIDI_BYTE_2]) end if end on