I am trying to toggle the tuner on a long press of a FCB1010 button. I let the FCB1010 send midi note 21, and I time it in GP. The print statements actually work as expected! However, when I introduce ToggleTunerVisible() (line 32), I am only able to toggle tuner once on, and unable to toggle it off! When the tuner is showing, the “Note on” is not printed, indicating that the script is not receiving the NoteOnEvent, even though I see it in the global midi monitor.
How can I toggle the tuner? I have also tried (in script) setting widget value on a widget that is connected to a system event tuner, and making a system event block in wiring view, with similar behavior of only turning on once. Other suggestions at solving this welcome, appreciate any input.
EMS_simplified.gig (83.0 KB)
Const
matchNote : int = 21 // Change to the note number being sent by your midi controller.
Var
FCB1010 : MidiInBlock
targetTime : Double
pressLength : Integer
timerActive : boolean
Initialization
targetTime = 0.0
pressLength = 1000 // Time in milliseconds for when a press becomes a long press.
timerActive = false
SetTimersRunning(false)
End
On NoteOnEvent(m : NoteMessage) Matching matchNote from FCB1010
if IsNoteOn(m) then
Print("Note on")
targetTime = TimeSinceStartup() + pressLength
timerActive = true
SetTimersRunning(true)
end
End
Function shortPress ()
Print("Short press.")
End
Function longPress ()
Print("Long press.")
ToggleTunerVisible()
End
On NoteOffEvent(m : NoteMessage) Matching matchNote from FCB1010
if timerActive and targetTime >= TimeSinceStartup() then
SetTimersRunning(false)
timerActive = false
shortPress()
end
End
On TimerTick(ms : double)
If timerActive and ms >= targetTime Then
SetTimersRunning(false)
timerActive = false
longPress()
End
End