MIDI + Widget = Flipped values no matter what

Hi again,

I know this could be submitted as a support ticket, but I’d rather have an open discussion about the issue I’m facing. (If admin disagrees, feel free to remove this and contact me directly)

THE PROBLEM

Okay, I’ve already started a thread about what I’m trying to achieve using GPScript. I now have several ways of achieving that goal (thanks to the brilliant feedback I got from you guys there!).

But, this journey led me to discover a weird bug(?) when using a MIDI controller (MeloAudio MIDI Commander / Harley Benton MP-100) to trigger a button widget, which in turn triggers a script.

SETUP

Two expression pedal widgets
One button to switch between two plugins (bypass)
MIDI controls the button (CC#80 0 = Button OFF, CC#80 127 = Button On)
Script picks up the value of the button, decides which plugins to bypass

SCRIPT

Var
   GainBalance : PluginBlock
   GainPedal : PluginBlock
   WahPedal : PluginBlock
   WahActive : Widget
  
// Called when a widget value has changed
On WidgetValueChanged(newValue : double) from WahActive
  if newValue < 0.5 then
    SetPluginBypassed(GainPedal, false)
    SetPluginBypassed(WahPedal, true)
    Print("Volume")
    Print(GetWidgetValue(WahActive))
  else
    SetPluginBypassed(GainPedal, true)
    SetPluginBypassed(WahPedal, false)
    Print("Wah")
    Print(GetWidgetValue(WahActive))
  end
End

RESULT

If I trigger the button widget manually from the rackspace, everything works as intended.

However, with the MIDI controller, this doesn’t happen the same way. The MIDI controller itself sends the correct values (0 and 127), the button widget respons correctly, but the widget value becomes inverted.

It started correct, since I reset everything using the widget. But once I start triggering the widget using MIDI, it flips and 0 becomes 100.0, 127 becomes 0.0. This happens every time, even if I activate INVERT in either the widget value or on the MIDI parameter. What’s weird is the widget shows me the correct change (On = Button lights up), but the value is flipped.

Gig-file: wah-midi-issue.gig (18.2 KB)

If anyone with a MIDI device reads this, would you please open this gig and assign the button widget to a controller and see what it does on your end?

How looks your global Midi Monitor Window?

I’m occasionally getting the incorrect value displayed in the script logger, but the two plugins (gain and GR6) always get their bypasses toggled correctly (matching visually with the toggle widget).

Please take me through this. I can add a MIDI Monitor and hook it up with MIDI In (OMNI), but I don’t see anything no matter what button I’m pressing on the MIDI Controller. But I have no issues mapping the controller to a widget.

EDIT:

rank13 explained this further down. I hadn’t seen the global MIDI monitor view before.

In my case, the wrong value shown in the logger matches the state of the bypasses, but not the button graphic. So the script and actual effect (bypass) agrees on one value, the widget and my MIDI controller agrees on the opposite.

It may not matter, but deselect the Sync button unless your midi controller supports bidirectional midi and you want GP to send the message back to the controller.

I kept Sync on, because if I don’t, the value gets stuck on 1.0 for some reason:

image

Which is still weird, since the script itself realizes the value change (hence the different Prints).

That’s probably telling. Without sync selected, open the global midi monitor (View > Midi Monitor) and see what your controller is sending. Are you still getting alternate values of 0 and 127?

With Sync:

Without Sync:

This is a race condition. You are setting a parameter in a plugin to some value. There is a small amount of time needed for that change to reflect in the actual widget value.

So when you do

“SetPluginBypassed” immediately followed by “GetWidgetValue” of the widget connected to that bypass things could get out of sync and read the previous widget value just before the system had time to update it.

Try to use “IsPluginBypassed” instead of querying a widget.

You script however should work. It’s just that the values in the log may not be what you expect, but the correct plugins should get bypassed/unbypassed.

I will do it when back to home.
What happen if you remove the SYNC option from the button widget properties in the MIDI tab?

The reason why is probably important…

Could you please remove the MIDI assignation of the button widget, and monitor your MIDI message when pressing your controller button and when releasing?

I suppose you need the momentary to latch option in the widget properties.

Try this

    Var
       GainBalance : PluginBlock
       GainPedal : PluginBlock
       WahPedal : PluginBlock
       WahActive : Widget
      
    // Called when a widget value has changed
    On WidgetValueChanged(newValue : double) from WahActive
      if newValue < 0.5 then
        SetPluginBypassed(GainPedal, false)
        SetPluginBypassed(WahPedal, true)
        Print("Volume")
        //Print(GetWidgetValue(WahActive))
        Print(newValue)
      else
        SetPluginBypassed(GainPedal, true)
        SetPluginBypassed(WahPedal, false)
        Print("Wah")
        //Print(GetWidgetValue(WahActive))
        Print(newValue)
      end
    End
1 Like

And maybe it would be safer to use “if newValue <0.4 Then” and use an “elsif newValue>0.6 then” instead of just using “Else”.
To “spare out” the middle value of 0.5
Just a thought… most probably it will make no diffrence though. But it would be something to try.

I think it is a rutime issue

At the callback time the Widget itself reports the old value with GetWidgetValue(), while the callback
is called with the actual Value in the Parameter,
And this only happens when the widget is set by a mapped Midi Controller.

So the GetWidgetValue() within the callback…does that make sense?
The newValue is the value of the Widget,

I will check it out!

But they didn’t. They matched the wrong number printed by GetWidgetValue, not what my MIDI controller or the widget graphic showed. I double-check this!

The MIDI Monitor shows the exact same thing as before. CC#80 either 0 or 127, always alternating.
I activated Momentary to latching, but now I have to press the button twice to make it change value.

Thank you, this seems to have solved the wrong logging! So newValue is already given in the callback and is the actual value of the widget, while GetWidgetValue() for some reason is lagging behind.

I will keep testing and report back if I have any further issues. Right now, bypassing seems to be linked correctly to the state of the widget, while previously it also seemed to lag behind.

This seems to be working well now. Thank you all in this thread for your valuable feedback!
I’ve spent a lot of time making a UI for each of my NeuralDSP-plugins:

Switching and adding effects finally works with my MIDI commander. :slight_smile:

5 Likes