How do I implement a loop in MDP StreamByter?

0 votes
asked Aug 31, 2020 in Advanced by dsabou2062 (3,570 points)
Quick note: it could be that we need to update the plugin, but Audeonic changed many things so it'll be a chunk of work. Let's see when we can get this on the map. Thanks!
I found several ways to use MidiFire, but I am still working on getting the MDP Plugin to work. Since I am controlling a computer App (Hauptwerk from MDP) I activate the IAC Driver in the Audio Midi Setup (Mac OS). Then in MidiFire I can connect Network Session 1 to the IAC Driver with Stream Byter controlling the output to IAC. Hauptwerk is connected to IAC for its Input, not Network Session 1.

An alternate approach is to use the Midifire app in the iPad. Output from MDP goes to Midifire which I connected to the Network via Stream Byter. I haven't actually tried to use either MidiFire approach (yet).
Thanks for the response. Actually, only WHILE didn't work but IF with +L does. I was getting an error with MAT because I used a dash instead of the minus sign. There is a difference in the iPad keyboard! A dash may look like a minus sign, but Stream Byter throws an ERR and it is not obvious at all why.

2 Answers

+1 vote
Raised a similar question 2 years ago:

https://mididesigner.com/qa/6645/stream-byter-and-md-no-support-for-looped-conditionals

It seems that the SB support is still pretty poor with regards to loops.
answered Sep 1, 2020 by qdrtshlz (450 points)
Actually, the IF with loop does work, but I still have a problem in my application. See my response to jkhiser.
+1 vote
If you stick with the older commands, it should work - ie no “While.”  Should be no problem with Mat or Ass - I use both often in rules.  I don’t think I have built a loop, but here is a sample loop from Ibo Kai’s latest update that also includes both Mat and Ass.

IF M00 == F0 43 00 03 #Check ID
  ASS I00 = 00 #Parameter number and loop counter
  ASS I01 = 06 #Parameter value
  IF I00 < 93 +L #Loop 92 times
    SND F0 43 10 12 I00 MI01 F7 #Parameter send
    MAT I00 = I00 + 1 #Next parameter
    MAT I01 = I01 + 1 #Next value
  END
END
answered Sep 1, 2020 by jkhiser (19,810 points)
I didn't realize on the iPad keyboard there is a difference between the minus sign and a dash. The dash is above the x key, which I tend to use for the minus sign. The minus sign is on the number keyboard next to the plus sign. My ERR went away when I used the proper minus sign. Since I had an ERR on the WHILE as well, I assumed the IF with loop wouldn't work either because of the MAT error. In fact, it does not create an ERR.

Now I have another problem in that I am trying to use the value of the CC Midi Off-On as a variable to control the loop. But when I try to use it as a parameter in the loop (J1) the loop thinks it is 0 and does not work. I just asked for help from Nic, waiting for his reply.

IF M0 == B6 0F # CC 7 16 # looking for CC 7 16 J1, where J1 varies between 1 and 10
 ASS J0 = 0   # initialize loop variable
 ASS J1 = M2 # Hundreds digit (variable 1 - 10)
 SND B5 10 J1 # used for verification test   

 IF J0 < J1 +L  # loop to be repeated J1 times
   SND B8 01 J0 # CC 9 1 J0 # used for verification test   
   MAT J0 = J0 + 1
 END
CC 7 16 is B6 10, not B6 0F.  Seems to work with that change.

(Channels are one off, but not individual ccs)
Thanks, that was it. I was confused by too many errors and didn't see the problem with the hex value.
Just two weeks ago, I lost an entire day when I entered F0h for 120 instead of 78h.  Added all sorts of debug statements to find the problem, and they never got triggered.  Don’t know how I finally discovered the error.  F0 wasn’t even close - it happens to anyone who codes.
...