|
Post by uncledave on Feb 18, 2021 23:21:32 GMT
Posting this in case it may help someone else.
I have a controller (Behringer X-Touch Mini) that can receive MIDI messages to set encoder values and lights. I tried to initialize these in the If load block, but it seems that the messages are never sent. They're displayed in the StreamByter monitor, but never reach the controller. I tried delaying the messages and using Set Flush , all ineffective. Finally, I realized that the trick is to put this initialization after the end of If load , as the first item in the main part of the program, controlled by
If T0 == 0 # put controller initialization here End
As the manual states, T0 is only zero the first time after restoring a scene. If prior data was initialized with +P, so values are saved in the scene, they will be restored, and can be used to reset the controller to its prior state. Now, this won't work until a MIDI message is received, so you need some controller action to trigger it. I use an innocuous button press. Now, finally, the controller state immediately matches the restored state in the script.
You can see that T0 works like a traditional "first time" flag, since it's only zero once. I kinda hate having the extra test in there for every message, but this is only a controller, not a keyboard, so performance is not critical.
The script is configured in Audiobus 3 to receive input from the controller and send output both to the app and back to the controller. They are on separate MIDI channels, so this does not confuse them.
|
|
nic
Soapbox Supremo
Troublemaker
Press any key to continue
Posts: 2,011
|
Post by nic on Feb 19, 2021 16:01:13 GMT
Hi uncledave , If the SB event monitor is showing the events going out from inside if/load, then it is the host that hasn't passed it on! ;-) I found with AB3 that I needed to add a 2 or 5 (can't remember) second delay to all send statements inside an if/load for them to be consumed. Your method is very smart even if it uses a side effect and if it works, then that is great. I would not be losing sleep about having to evaluate the timer value during each message cycle. Regards, Nic.
|
|
|
Post by uncledave on Feb 19, 2021 22:47:12 GMT
Hi nic, Thanks for the advice. I tried +D500, figuring that was plenty. I'll try +D5000, to see if it helps. I thought maybe that the host needed an input message to trigger collection of the output messages. Cheers, Dave
|
|
|
Post by uncledave on Feb 22, 2021 19:13:15 GMT
I tried this, using Send in If Load, with +D5000 and even +D10000, and nothing is sent when restoring a preset in Audiobus, or a session in AUM. Could this be another change in iOS 14 MIDI? (I'm on iPadOS 14.4 on iPad 6.) However, the trick of testing T0==0 lets me send the init messages on the first input from the controller.
|
|
|
Post by uncledave on Mar 5, 2021 2:18:52 GMT
However, it turns out I was wrong overall. When you first start Audiobus and load a preset including SB, T0 is zero initially, and this works. But if you then load another preset, I guess SB is already running, so T0 is not zero anymore. But a conventional first-time flag does work. Initialize to 1 in the load section, test and clear it on the first event, and use that to trigger hardware initialization messages.
|
|