I recently wrote a script (maybe not very elegant, but it works ) to realize a so called "radio-button"functionality. Some of you may still know those station buttons on old radios, where only one could be pressed at a time. I did that with LED-buttons.
In this example-rackspace i used this script to switch the transpose-setting for incoming notes by whole octaves. So there are seven buttons for a transposition of -3, -2, -1, 0, +1, +2, +3 octaves.
Maybe you have to insert a new MIDI-IN block, which then had to be named as “tp_midi_in” for the script to work properly.
Here is the link to the rackspace (you have to import it to your gig-file!):
EDIT: There was a faulty button-configuration in the rackspace which caused the buttons to flicker around and refuse to react - i uploaded a new one.
Sorry for any inconvenience
And this is the code (which also is embedded in the rackspace)… have fun.
var
bt_vs1 : widget
bt_vs2 : widget
bt_vs3 : widget
bt_vs4 : widget
bt_vs5 : widget
bt_vs6 : widget
bt_vs7 : widget
tp_midi_in : MidiInBlock
vs1_active : boolean
vs2_active : boolean
vs3_active : boolean
vs4_active : boolean
vs5_active : boolean
vs6_active : boolean
vs7_active : boolean
tp_amt : integer
Function set_tp (vs1 : double, vs2 : double, vs3 : double, vs4 : double, vs5 : double, vs6 : double, vs7 : double)
SetWidgetValue(bt_vs1, vs1)
if vs1 == 0 then
vs1_active=false
else
vs1_active=true
end
SetWidgetValue(bt_vs2, vs2)
if vs2 == 0 then
vs2_active=false
else
vs2_active=true
end
SetWidgetValue(bt_vs3, vs3)
if vs3 == 0 then
vs3_active=false
else
vs3_active=true
end
SetWidgetValue(bt_vs4, vs4)
if vs4 == 0 then
vs4_active=false
else
vs4_active=true
end
SetWidgetValue(bt_vs5, vs5)
if vs5 == 0 then
vs5_active=false
else
vs5_active=true
end
SetWidgetValue(bt_vs6, vs6)
if vs6 == 0 then
vs6_active=false
else
vs6_active=true
end
SetWidgetValue(bt_vs7, vs7)
if vs7 == 0 then
vs7_active=false
else
vs7_active=true
end
end
initialization
vs1_active = false
vs2_active = false
vs3_active = false
vs4_active = false
vs5_active = false
vs6_active = false
vs7_active = false
end
On Activate// Called when rackspace is activated
// SetWidgetValue (bt_vs4,1) //Button #4 is activated -> Transpose=0
End
//Called when a NoteOn or NoteOff message is received at some MidiIn block
//Note: this will NOT be called for NoteOn/NoteOff messages if you have explicit
//NoteOnEvent/NoteOffEvent respectively callbacks defined
On NoteEvent(m : NoteMessage) from tp_midi_in
SendNow(tp_midi_in, Transpose(m,tp_amt))
End
// Called when a widget value has changed
On WidgetValueChanged(tp_val : double) from bt_vs1
if tp_val == 1 And vs1_active == false then
set_tp (1,0,0,0,0,0,0)
tp_amt = -36
end
if tp_val == 0 And vs1_active == true then
vs1_active = true
SetWidgetValue(bt_vs1,1)
end
end
On WidgetValueChanged(tp_val : double) from bt_vs2
if tp_val == 1 And vs2_active == false then
set_tp (0,1,0,0,0,0,0)
tp_amt = -24
end
if tp_val == 0 And vs2_active == true then
vs2_active = true
SetWidgetValue(bt_vs2,1)
end
end
On WidgetValueChanged(tp_val : double) from bt_vs3
if tp_val == 1 And vs3_active == false then
set_tp (0,0,1,0,0,0,0)
tp_amt = -12
end
if tp_val == 0 And vs3_active == true then
vs3_active = true
SetWidgetValue(bt_vs3,1)
end
end
On WidgetValueChanged(tp_val : double) from bt_vs4
if tp_val == 1 And vs4_active == false then
set_tp (0,0,0,1,0,0,0)
tp_amt = 0
end
if tp_val == 0 And vs4_active == true then
vs4_active = true
SetWidgetValue(bt_vs4,1)
end
end
On WidgetValueChanged(tp_val : double) from bt_vs5
if tp_val == 1 And vs5_active == false then
set_tp (0,0,0,0,1,0,0)
tp_amt = 12
end
if tp_val == 0 And vs5_active == true then
vs5_active = true
SetWidgetValue(bt_vs5,1)
end
end
On WidgetValueChanged(tp_val : double) from bt_vs6
if tp_val == 1 And vs6_active == false then
set_tp (0,0,0,0,0,1,0)
tp_amt = 24
end
if tp_val == 0 And vs6_active == true then
vs6_active = true
SetWidgetValue(bt_vs6,1)
end
end
On WidgetValueChanged(tp_val : double) from bt_vs7
if tp_val == 1 And vs7_active == false then
set_tp (0,0,0,0,0,0,1)
tp_amt = 36
end
if tp_val == 0 And vs7_active == true then
vs7_active = true
SetWidgetValue(bt_vs7,1)
end
end