Delaying program change

Trying to delay a PC message. I want to catch whatever PC message is coming out of the ZSYNTHPC13 midiIn block and delay it. Script compiles, but as I’m looking at the midi monitor, I don’t see any delay. What am I doing wrong? Still very much learning scripting… Thanks!

var
ZSYNTHPC13: MidiInBlock
programChange: integer


On ProgramChangeEvent (m : ProgramChangeMessage) from ZSYNTHPC13
    programChange = GetProgramChangeNumber(m)
    ZSYNTHPC13.SendLater(m, 500)
End

What MIDI monitor are you looking?

I connected a GP midi monitor to the midi in block.

Am I supposed to put the “programChange” in the last line somewhere? Whatever I tried wasn’t working…

Please open additionally the global MIDI Monitor.
There you see the incoming MIDI messages and the you should see the delayed MIDI message in the other MiDI monitor.

Nothing is showing up there at all related to these PC messages. The ZSYNTHPC13 in the script is a virtual midi in block. When I manually turn the widget producing the initial PC messages (that are supposed to be “caught”) are not showing up in the global midi monitor either. But the PC are working. The script just isn’t making any difference at all. Does it look right to you?

I’ve got a multi in Kontakt that I use PC to select sounds from. Problem is, the “unbypass” and PC messages are being sent at the same time and Kontakt goes to the wrong preset. All other plugins have no problem getting the PC message and getting the bypass turned off, but Kontakt is. If I manually send the PC message AFTER its already bypassed, it works fine. So the PC message must be delayed that is being sent at the same time as the un-bypass command. Thanks!

Please upload a small gig, I can check

Here you go. I just put the basics in there. The widget that produces the PC messages and the midiIn block with Kontakt (or any other plugin…not really needed). What I would like to happen, is when the widget is turned and PC messages are produced, those messages would be “caught” and sent out delayed. Even if there are 2 PC messages (original + delayed on) is OK. Although if this script only send the delayed one, even more elegant. :slight_smile:
Thanks!

PCdelayedtest.gig (1.3 MB)

I’m actually wondering if sticking a scriptlet between the midi in block and the plug-in to delay all PC messages might make more sense?

You have to use this wiring
Bildschirmfoto 2021-12-16 um 08.28.16

PCdelayedtest_Working.gig (1.3 MB)

This is because the widget sending the PC message is assigned to the MIDI out.
Therefore your script is not executed at all.
The widget is now mapped to the “Dummy” MIDI In (OSC).
The ZSYNTHPC13 has checked “Enable MIDI Merge”
And now the script is executed.

And YES: A scriptlet would work also.
And with a scriptlet with parameters you can decide the delay length vie Widgets mapped to exposed scriptlet parameters.

Thank you very much for this! I’ll check it out in about 8 hours.

I like the scriptlet idea. Would you mind helping with that?

Sure, gimme some more minutes.

1 Like

Here you go:
PCdelayedtest_Working.gig (1.3 MB)

This is the scriplet code

var VDelay : parameter 0..1000 = 500

//Called when a program change message is received
On ProgramChangeEvent(m : ProgramChangeMessage)
 SendLater(m,VDelay)
End

And a widget is assigned to the parameter VDelay

3 Likes

Nice! Can’t wait to check it out in the morning! Thanks again!

1 Like

This one is my favorite solution as its simple, clean and can be immediately available if other plugins need it. Thank you!

I would still like to understand and learn why my brain wasn’t getting the script solution. You said it wasn’t working b/c the widget is sending the PC messages to the midi out port. BUT! The script says get PC messages FROM midi block, (which in my brain anyway) would expect it to come from the midi out. So I would expect the script to be looking for PC messages coming FROM the midi out of the midi block.

In reality, what is happening is even though the script language says On ProgramChangeEvent …FROM XYZ midi block, it is really looking for ProgramChangeEvent going INTO XYZ midi block. So perhaps I’m being too literal, but this is confusing to me. Thank you for explaining why it wasn’t working! :slight_smile:

OK, the widget mapped to PC messages and the MIDI In block sends the pc message to the MIDI Out of the MIDI Block.
A script call back reacts on incoming Messages and not on outgoing.

Yeah I get it now. Perhaps the code language would be more accurately descriptive if it said “On ProgramChangeEvent… IN” midi block, not “FROM”. At least to newbies :slight_smile:

Ah OK, you took to too wordly (German Translation to English).

You took it too literally

1 Like

But the program change did come from that particular block, as opposed to coming from some other Midi In block.