Thank you rank13. I corrected these mistakes and it behave much better indeed. I also used David-san radio button script which works better I believe.Thanks David.
Now I have an issue. I created another (empty for now) Rackspace and when I go back and forth between the Rackspace the SyncBCF function does not work correctly and my faders are all changed to value 127. It’s likely my misunderstanding of basics. What happens with the variables when I switch Rackspace.
BCF2000_Mixers(12.3).gig (1.0 MB)
//$<AutoDeclare>
// DO NOT EDIT THIS SECTION MANUALLY
Var
MIXA : PluginBlock
MIXB : PluginBlock
BCF2000_Out : MidiOutBlock
CH_A1_Volume : Widget
CH_A2_Volume : Widget
CH_A3_Volume : Widget
CH_A4_Volume : Widget
CH_A5_Volume : Widget
CH_A6_Volume : Widget
CH_A7_Volume : Widget
CH_A8_Volume : Widget
CH_A1_Pan : Widget
CH_A2_Pan : Widget
CH_A3_Pan : Widget
CH_A4_Pan : Widget
CH_A5_Pan : Widget
CH_A6_Pan : Widget
CH_A7_Pan : Widget
CH_A8_Pan : Widget
CH_A1_Solo : Widget
CH_A1_Mute : Widget
CH_A2_Solo : Widget
CH_A2_Mute : Widget
CH_A3_Solo : Widget
CH_A3_Mute : Widget
CH_A4_Solo : Widget
CH_A4_Mute : Widget
CH_A5_Solo : Widget
CH_A5_Mute : Widget
CH_A6_Solo : Widget
CH_A6_Mute : Widget
CH_A7_Solo : Widget
CH_A7_Mute : Widget
CH_A8_Solo : Widget
CH_A8_Mute : Widget
Button_A : Widget
Panel_Name: widget
CH_B1_Volume : Widget
CH_B2_Volume : Widget
CH_B3_Volume : Widget
CH_B4_Volume : Widget
CH_B5_Volume : Widget
CH_B6_Volume : Widget
CH_B7_Volume : Widget
CH_B8_Volume : Widget
CH_B1_Pan : Widget
CH_B2_Pan : Widget
CH_B3_Pan : Widget
CH_B4_Pan : Widget
CH_B5_Pan : Widget
CH_B6_Pan : Widget
CH_B7_Pan : Widget
CH_B8_Pan : Widget
CH_B1_Solo : Widget
CH_B1_Mute : Widget
CH_B2_Solo : Widget
CH_B2_Mute : Widget
CH_B3_Solo : Widget
CH_B3_Mute : Widget
CH_B4_Solo : Widget
CH_B4_Mute : Widget
CH_B5_Solo : Widget
CH_B5_Mute : Widget
CH_B6_Solo : Widget
CH_B6_Mute : Widget
CH_B7_Solo : Widget
CH_B7_Mute : Widget
CH_B8_Solo : Widget
CH_B8_Mute : Widget
Button_B : Widget
//Other Declarations
CC_Array_A : widget array
CC_Array_B : widget array
buttons : widget array = [Button_A ,Button_B ]
last : Integer // buffer variables to store the last pressed button
Initialization
var i : Integer
CC_Array_A = [CH_A1_Volume,CH_A1_Solo,CH_A1_Mute,CH_A1_Pan,
CH_A2_Volume,CH_A2_Solo,CH_A2_Mute,CH_A2_Pan,
CH_A3_Volume,CH_A3_Solo,CH_A3_Mute,CH_A3_Pan,
CH_A4_Volume,CH_A4_Solo,CH_A4_Mute,CH_A4_Pan,
CH_A5_Volume,CH_A5_Solo,CH_A5_Mute,CH_A5_Pan,
CH_A6_Volume,CH_A6_Solo,CH_A6_Mute,CH_A6_Pan,
CH_A7_Volume,CH_A7_Solo,CH_A7_Mute,CH_A7_Pan,
CH_A8_Volume,CH_A8_Solo,CH_A8_Mute,CH_A8_Pan]
CC_Array_B = [CH_B1_Volume,CH_B1_Solo,CH_B1_Mute,CH_B1_Pan,
CH_B2_Volume,CH_B2_Solo,CH_B2_Mute,CH_B2_Pan,
CH_B3_Volume,CH_B3_Solo,CH_B3_Mute,CH_B3_Pan,
CH_B4_Volume,CH_B4_Solo,CH_B4_Mute,CH_B4_Pan,
CH_B5_Volume,CH_B5_Solo,CH_B5_Mute,CH_B5_Pan,
CH_B6_Volume,CH_B6_Solo,CH_B6_Mute,CH_B6_Pan,
CH_B7_Volume,CH_B7_Solo,CH_B7_Mute,CH_B7_Pan,
CH_B8_Volume,CH_B8_Solo,CH_B8_Mute,CH_B8_Pan]
//Check & store state of buttons - if all off, assume the first as "ON"
For i = 0; i < Size(buttons); i = i + 1 Do
If GetWidgetValue(buttons[i]) == 1.0 Then
last = i
Else
last = 0
End
End
End
//Functions/////////////////////////////
//Change Preset Function
Function ChangePreset (Preset:integer)
var SysexMsg : SysexMessage
SysexMsg = # F0 00 20 32 00 14 22 00 F7;// Preset select sysex String
SM_ChangeValue(SysexMsg, 7, Preset);//Change byte 7 to preset value
SendSysexExternal(BCF2000_Out, SysexMsg);
End
//Synchronize BCF and Widgets Function
Function SyncBCF (CC_Array : widget array)
var x : integer
For x=0 ; x<32 ; x=x+1 Do
ResyncWidget(CC_Array[x]);
End;
End
/////////////////////////////////////////
On WidgetValueChanged(w : Widget, index: integer, newValue : double) from Button_A , Button_B
var i : integer
if newValue == 1.0 and index <> last then
// Deselect other buttons
for i = 0; i < Size(buttons); i = i + 1 do
if i <> index then SetWidgetValue(buttons[i],0.0) end
End
last = index
end
select last == 0 do
SetWidgetLabel (Panel_Name, "MIX A")
ChangePreset(0)
SyncBCF (CC_Array_A)
last == 1 do
SetWidgetLabel (Panel_Name, "MIX B")
ChangePreset(1)
SyncBCF (CC_Array_B)
End
// Prevent a button to be switched off manually
If newValue == 0.0 and index == last Then SetWidgetValue(buttons[index],1.0) End
End