You are on page 1of 3

{***********************************************

Note Range to PC
Author: Native Instruments
Written by: Nicki Marinic
Modified: September 8, 2009
*************************************************}
on init
message("")
set_script_title("Notes to Prog Change")
set_ui_height(2)
declare $count
declare $prog_num
declare $learn_counter
declare $a
declare $x
declare ui_switch $learn_button
set_text($learn_button,"Learn Keyrange")
declare ui_switch $trigguer_button
set_text($trigguer_button, "Trigguer Off")
declare ui_label $label_1 (2,1)
set_text ($label_1,"Transform the note range from")
declare ui_label $label_2 (1,1)
set_text ($label_2,"to PC starting at:")
declare ui_label $readout_label (2,1)
set_text ($readout_label,"Out:")

declare ui_value_edit $Min (0,127,$VALUE_EDIT_MODE_NOTE_NAMES)


$Min := 37
declare ui_value_edit $Max (0,127,$VALUE_EDIT_MODE_NOTE_NAMES)
$Max := 48
declare ui_value_edit $First (1,128,1)
declare ui_value_edit $Key_Trigguer (0,127,$VALUE_EDIT_MODE_NOTE_NAMES)
$Key_Trigguer := 36
set_text ($Key_Trigguer,"Trigguer:")
make_persistent ($Key_Trigguer)
make_persistent ($Min)
make_persistent ($Max)
make_persistent ($First)
set_control_help ($learn_button,"Learn: Click to enable MIDI Learn for t
he keyrange. The keyrange is set by the next two received MIDI notes.")
set_control_help ($trigguer_button, "Indica se a tecla TRIGGUER esta pressio
nada ou nao")
set_control_help ($Key_Trigguer,"Informe a tecla que deseja usar como at
alho para mudanca de timbres.")
set_control_help ($Min,"Min: The lower limit of the keyrange. All notes
between <Min> and <Max> will not be played but transfromed into Program Change v
alues.")
set_control_help ($Max,"Max: The higher limit of the keyrange. All notes
between <Min> and <Max> will not be played but transfromed into Program Change
values.")
set_control_help ($First,"First: Sets the program change value for the l
owest, i.e. <Min> note.")
set_control_help ($readout_label,"Out: Displays the sent Program Change
values as well as the MIDI channel.")
move_control ($learn_button,1,3)
move_control ($trigguer_button, 1, 4)
move_control ($Key_trigguer, 2, 4)
move_control ($label_1,2,2)
move_control ($Min,2,3)
move_control ($Max,3,3)
move_control ($label_2,4,2)
move_control ($First,4,3)
move_control ($readout_label,5,3)
end on
on ui_control ($Min)
if ($Min > $Max)
$Max := $Min
end if
end on
on ui_control ($Max)
if ($Max < $Min)
$Min := $Max
end if
end on
on midi_in
if (($MIDI_COMMAND = $MIDI_COMMAND_NOTE_ON) and ($MIDI_BYTE_1 = $Key_Triggue
r) and ($MIDI_BYTE_2 > 0))
$x := 1
$trigguer_button := 1
set_text($trigguer_button, "Trigguer On")
end if
if (($MIDI_COMMAND = $MIDI_COMMAND_NOTE_ON) and ($MIDI_BYTE_1 = $Key_Triggue
r) and ($MIDI_BYTE_2 = 0))
$x := 0
$trigguer_button := 0
set_text($trigguer_button, "Trigguer Off")
end if
if ($x = 1)
ignore_midi
end if
if (($MIDI_COMMAND = $MIDI_COMMAND_NOTE_ON) and ($MIDI_BYTE_2 > 0) and ($x =
1))
{Key Range}
if ($learn_button = 1)
if ($learn_counter = 0)
$Min := $MIDI_BYTE_1
inc($learn_counter)
else
$Max := $MIDI_BYTE_1
$learn_counter := 0
$learn_button := 0
if ($Min > $Max)
$a := $Max
$Max := $Min
$Min := $a
end if
end if
ignore_midi
exit
end if
if (in_range($MIDI_BYTE_1,$Min,$Max))
ignore_midi
$prog_num := $MIDI_BYTE_1- $Min+ $First- 1
if ($prog_num > 127)
$prog_num := 127
end if
set_midi($MIDI_CHANNEL,$MIDI_COMMAND_PROGRAM_CHANGE,$pro
g_num,0)
set_text ($readout_label,"Out: PC #" & $prog_num+1 & " o
n MIDI Channel " & $MIDI_CHANNEL+1)
end if
end if
{Note Off Simple}
if (($MIDI_COMMAND = $MIDI_COMMAND_NOTE_ON and $MIDI_BYTE_2 = 0))
if (in_range($MIDI_BYTE_1,$Min,$Max))
set_text ($readout_label,"Out:")
end if
end if
{Note Off True}
if ($MIDI_COMMAND = $MIDI_COMMAND_NOTE_OFF)
if (in_range($MIDI_BYTE_1,$Min,$Max))
set_text ($readout_label,"Out:")
end if
end if
end on

You might also like