Switching a rotary effect via widget/aftertouch and sustain pedal


#1

Heyho everyone,
i thought that some of you might be interested in that little script i wrote for handling a rotary effect.
I also attached a rackspace which is using the B3-V organ VST from Arturia, so if you own this plugin too, you might be ‘ready to go’ with this one. But i think it should be easy to adapt to other similar plugins.

Besides the normal button widgets (LED-buttons on the right), there is the Leslie-section (with the big status label). As you can see, there is one toggle switch for the rotary speed and another one for the brake.
Luckily there are enough buttons on my keyboard (M-Audio Code 61) to map all those widgets to, so i also mapped the leslie switches to hardware buttons (see widget captions ‘B1’ and ‘B2’).
This allows me to switch the Leslie with the buttons - no magic so far. :wink:

But what does the script?
The script allows you to switch the leslie speed also by shortly pressing the aftertouch (need a value >80 to prevent you from accidentally switching the speed), OR you can use a sustain pedal to do the switching (because the sustain is passed through, you may also do a ‘keyboard-slide’ while the leslie accelerates, which can be a cool effect). In addition to this, the big widget will change its text according to the chosen speed, so it always gives you a clear information (FAST/SLOW/STOP).

That’s it - maybe you like it? :sunglasses:

The script-code:

//$<AutoDeclare>
// DO NOT EDIT THIS SECTION MANUALLY
Var
   mid_in1 : MidiInBlock
   B3V_vst : PluginBlock
   tgg_LES_SPD : Widget
   tgg_LES_BRK : Widget
   btn_OD : Widget
   btn_REV : Widget
   btn_PHA : Widget
   btn_FLA : Widget
   btn_CHO : Widget
   btn_DEL : Widget
   lbl_rot_state : Widget
//$</AutoDeclare>

var 
    got_AT : boolean
    is_sustained : boolean

Initialization
    SetWidgetLabel(lbl_rot_state, "SLOW")
    SetWidgetValue(tgg_LES_SPD, 0)
    SetWidgetValue(tgg_LES_BRK, 0)
    SetWidgetValue(btn_OD, 0)
    SetWidgetValue(btn_REV, 1.0)
    SetWidgetValue(btn_PHA, 0)
    SetWidgetValue(btn_FLA, 0)
    SetWidgetValue(btn_CHO, 0)
    SetWidgetValue(btn_DEL, 0)
    got_AT = false
    is_sustained = false
End

//User-defined function to set the label-text according to the chosen speed
Function SetLeslieLabel()

        //FAST is ON and BRAKE is OFF
        If GetWidgetValue(tgg_LES_SPD)>0.5 and GetWidgetValue(tgg_LES_BRK)<0.5
        Then
            SetWidgetLabel(lbl_rot_state, "FAST")
            
        //FAST is OFF and BRAKE is OFF
        Elsif GetWidgetValue(tgg_LES_SPD)<0.5 and GetWidgetValue(tgg_LES_BRK)<0.5
        Then
            SetWidgetLabel(lbl_rot_state, "SLOW")
            
        //When BRAKE is ON
        Elsif GetWidgetValue(tgg_LES_BRK)>0.5
        Then
            SetWidgetLabel(lbl_rot_state, "STOP")
        End
End


//Aftertouch handling
On AfterTouchEvent(m : AfterTouchMessage) from mid_in1

    //catch Aftertouch values over 80 while Sustain-pedal switching is not in progress
    If (got_AT == false and is_sustained == false and GetAfterTouchValue(m) >= 80)
    Then
        got_AT=true //Aftertouch recognized
        
        //switch value of Leslie-Speed widget from 0 to 1 and vice versa
        SetWidgetValue(tgg_LES_SPD,1.0-GetWidgetValue(tgg_LES_SPD))
        
        //call user-function to set the big label according to the new value
        SetLeslieLabel()
        
    //when Aftertouch is over
    Elsif (got_AT==true and GetAfterTouchValue(m) < 1)
    Then
        got_AT=false
    End
    
End

//Sustain-pedal handling (CC64)
On ControlChangeEvent(m : ControlChangeMessage) Matching 64 from mid_in1
SendNow(mid_in1, m) // pass on the sustain-signal

    //sustain is pressed and Aftertouch-switching is not in progress
    If (got_AT == false and is_sustained == false and GetCCValue(m)>1)
    Then
        is_sustained=true //sustain recognized
        
        //switch value of Leslie-Speed widget from 0 to 1 and vice versa
        SetWidgetValue(tgg_LES_SPD,1.0-GetWidgetValue(tgg_LES_SPD))
        
        //call user-function to set the big label according to the new value
        SetLeslieLabel()
        
    Else
        is_sustained=false //sustain released
    End
End


On WidgetValueChanged(newValue : double) from tgg_LES_BRK
    //call user-function to set the big label according to the new value
    SetLeslieLabel()
End

test

B3V_Organ1.rackspace (100.2 KB)


#2

Thanks for sharing! and the script IS a nice touch :wink:

Just to make clear, those two vertical meters are supposed to be mapped to Output Level 1 and 2?
When I open here its not correct? bug? somehow?


#3

I am glad, you like it. :blush:

I mapped them to the output levels of my Audio-Out block (chan 1 and 2 of my interface).
Maybe it’s because you have another hardware? But it’s a little bit strange though…

BTW: I re-thought the script… there was the possibility that you could manually toggle the speed-switch (by mouse) and the label wouldn’t have been changed. Now, the label is updated any time when the speed-toggle is changed. That should work for all the possibilties. I also cleaned it a bit from unused variables.

Var
   mid_in1 : MidiInBlock
   tgg_LES_SPD : Widget
   tgg_LES_BRK : Widget
   lbl_rot_state : Widget
   got_AT : boolean
   is_sustained : boolean

Initialization
    SetWidgetLabel(lbl_rot_state, "SLOW")
    SetWidgetValue(tgg_LES_SPD, 0)
    SetWidgetValue(tgg_LES_BRK, 0)
    got_AT = false
    is_sustained = false
End

//User-defined function to set the label-text according to the chosen speed
Function SetLeslieLabel()

        //FAST is ON and BRAKE is OFF
        If GetWidgetValue(tgg_LES_SPD)>0.5 and GetWidgetValue(tgg_LES_BRK)<0.5
        Then
            SetWidgetLabel(lbl_rot_state, "FAST")
            
        //FAST is OFF and BRAKE is OFF
        Elsif GetWidgetValue(tgg_LES_SPD)<0.5 and GetWidgetValue(tgg_LES_BRK)<0.5
        Then
            SetWidgetLabel(lbl_rot_state, "SLOW")
            
        //When BRAKE is ON
        Elsif GetWidgetValue(tgg_LES_BRK)>0.5
        Then
            SetWidgetLabel(lbl_rot_state, "STOP")
        End
End


//Aftertouch handling
On AfterTouchEvent(m : AfterTouchMessage) from mid_in1

    //catch Aftertouch values over 80 while Sustain-pedal switching is not in progress
    If (got_AT == false and is_sustained == false and GetAfterTouchValue(m) >= 80)
    Then
        got_AT=true //Aftertouch recognized
        
        //switch value of Leslie-Speed widget from 0 to 1 and vice versa
        SetWidgetValue(tgg_LES_SPD,1.0-GetWidgetValue(tgg_LES_SPD))
        
    //when Aftertouch is over
    Elsif (got_AT==true and GetAfterTouchValue(m) < 1)
    Then
        got_AT=false
    End
    
End

//Sustain-pedal handling (CC64)
On ControlChangeEvent(m : ControlChangeMessage) Matching 64 from mid_in1
SendNow(mid_in1, m) // pass on the sustain-signal

    //sustain is pressed and Aftertouch-switching is not in progress
    If (got_AT == false and is_sustained == false and GetCCValue(m)>1)
    Then
        is_sustained=true //sustain recognized
        
        //switch value of Leslie-Speed widget from 0 to 1 and vice versa
        SetWidgetValue(tgg_LES_SPD,1.0-GetWidgetValue(tgg_LES_SPD))
    Else
        is_sustained=false //sustain released
    End
End


On WidgetValueChanged(newValue : double) from tgg_LES_BRK
    //call user-function to set the big label according to the new value
    SetLeslieLabel()
End

On WidgetValueChanged(newValue : double) from tgg_LES_SPD
    //call user-function to set the big label according to the new value
    SetLeslieLabel()
End

The new rackspace is attached. B3V_Organ1.rackspace (99.7 KB)