|
Post by espiegel123 on Jun 26, 2018 16:49:07 GMT
Hi,
I am wanting to generate some random sample/hold effects in some synths that don't have Random S/H, and I am wondering if it is reasonable to use Stream Byter to generate CC values and notes the way that a noise generator does using the random math function. I am still getting up to speed on what MIDI Fire can do and the clock functions are something I haven't look into yet.
Is this a reasonable thing to do?
Thanks, E
|
|
nic
Soapbox Supremo
Troublemaker
Press any key to continue
Posts: 2,011
|
Post by nic on Jun 27, 2018 6:45:25 GMT
Hi espiegel123 , It is definitely possible to generate random events (eg. notes, CC's and their values) using the special R variable. Here's a basic example of generating a random note event over the entire keyboard range: ASS L0 = R7F # choose random note from entire range MAT L1 = 20 + R20 # random velocity between 32 and 64 MAT L2 = C8 + RC8 # random length between 200 and 400 ms SND 90 L0 L1 # send note on straight away SND 80 L0 00 +DL2 # send note off after delayIf you wanted to generate, say 3 random notes all in sequence with each other (ie. next note starts when previous note ends) then you would add +D flags with applicable values to the note on too. Regards, Nic.
|
|
|
Post by espiegel123 on Jun 27, 2018 22:13:53 GMT
Awesome. Thanks. Is there a way around the 128 iteration limit on loops? I was kinda hoping to have it run indefinitely.
|
|
nic
Soapbox Supremo
Troublemaker
Press any key to continue
Posts: 2,011
|
Post by nic on Jun 28, 2018 5:30:25 GMT
Hi espiegel123 , Yeah, I figured you might want this! To iterate more than 128 times you would nest two loop blocks and get 16k iterations, but for what you want, you probably want to use the SND with a +I flag (Inject) which is a little convoluted but incredibly handy. Here is how it works: When you specify a +I flag to a SND rule, the event does not get forwarded out of the module's output (and on to the next connected module(s)) but gets injected into the MidiFire routing engine as if it had been received on the input port that caused the SND to issue (or if SND +I is inside an IF/LOAD then falls back to the 'MidiFire' virtual port). Let's say you have an external controller connected to a Stream Byter and you want to start a loop when you press note C3 and stop it when you release that note: # setup IF LOAD # constant - loopback event ASS K0 = BF 35 7F # variable - flag if we are looping ASS L0 = 0 END
# handle loop trigger on/off events 9X XX 00 = 8X # convert note on/vel0 to note off IF M0 == 90 3C # got our trigger note on, start looping # by sending an internal loop trigger event # that we will receive back in 100ms SND K0 K1 K2 +I +D100
# mark as looping ASS L0 = 1 END IF M0 == 80 3C # got our trigger note off # mark as no longer looping ASS L0 = 0 END
# handle internal loopback event IF M0 == K0 K1 K2 # we got our trigger event, so # here is where you do your stuff # in the loop body ... your code
# if we are still looping, # send another loopback event # to do it all again in 100ms IF L0 == 1 SND K0 K1 K2 +I +D100 END
# the loopback event is internal # so we should never send it out XX = XX +B END
When you hold down that note, your loop body will get called indefinitely in 100ms intervals until you release the note and then it should stop. The trigger event doesn't have to be a note - could be a CC on/off - you just change the logic to match your trigger on and trigger off events. If you want to block the trigger event from being sent on out of the Stream Byter then add XX = XX +B in the trigger on/off logic blocks. Obviously you can change the trigger interval from 100ms to whatever suits. As usual, I just typed in the above. There may be compile/logic errors - it's the method that counts. Finally, beware while writing this type of stuff since it does create infinite (and undetectable) loops that you don't hang the app by having no delay on the SND +I and no way to stop looping! This is a MidiFire trick - you cannot do this in the AUv3 or Midi Designer Stream Byter (just in case someone comes across this thread in that context) Regards, Nic.
|
|