MIDI CC switch toggle

Hi all,

I’m using a scriptlet to convert a Note ON message into a MIDI CC message (CC #102) to toggle a button in Gig Performer. The script works, but the button seems to act like it’s velocity-sensitive: it only switches ON when the note velocity is above 50 and switches OFF when it’s below 50.

I’ve tried the “Momentary to Latching” option, which works perfectly when using a direct Note ON MIDI message to toggle the button, but it doesn’t seem to function correctly with the MIDI CC output from my scriptlet. My goal is to toggle the button ON/OFF with any key press, regardless of velocity.

I’ve attached a .gig file that includes the scriptlet, button, and MIDI setup. What am I missing here? Is there a way to make the CC message behave like a simple toggle, or do I need to adjust something in the button’s settings or the script?

Thanks for any help!
SCRIPTLET to MIDI CC.rackspace (97.3 KB)

If all you want is to toggle the button, send along velocity 127 instead of the velocity of the incoming note. With that type of widget, its only going to switch to an On state if the value received is greater than 63.

var
   Connected : Parameter 0..1 = 1
   cc : ControlChangeMessage

On NoteOnEvent(m : NoteOnMessage) 
         cc := MakeControlChangeMessageEx(102, 127, 1) 
         InjectMidiEvent("Local GP Port", cc) 
End

Thank you, @edm11 . I don’t have any trouble turning the switch ON—it works fine for that. What I’m trying to do is toggle it both ON and OFF with a single key press, regardless of the velocity amount. So, are you saying this behavior is tied to a widget setting rather than the script itself?

Are you wanting an alternating press of the key to toggle the widget on and off? e.g. you press once it turns the widget on, you press again it turns the widget off?

Yes, that’s my wish. One press ON, another Off. The strange thing is that with this witget ‘Momentary to latching’ is working with Note ON message, but not with MIDI CC. Now I’ve tried other two types of switches and the both work - but they don’t fit into my rackspace.

Try this:

var
   Connected : Parameter 0..1 = 1
   cc : ControlChangeMessage
   trigger : Boolean = True

On NoteOnEvent(m : NoteOnMessage) 
    If trigger == True then
            cc := MakeControlChangeMessageEx(102, 127, 1) 
            InjectMidiEvent("Local GP Port", cc)
            trigger = false
    Else
    cc := MakeControlChangeMessageEx(102, 0, 1) 
            InjectMidiEvent("Local GP Port", cc)
            trigger = true
    End
End
1 Like

It works!! Thank you. :blush:

1 Like