|
Post by mo13 on Feb 22, 2022 12:42:16 GMT
Hello, I can use some help with a (drum trigger) sequencer that sends 10 notes from 0 to 9, coming in from different channels.
First part - The first 6 notes which are arriving from Ch. 1, I'd like to have notes 0 & 2 (aka Kick & Snare) always go through, but also have only note 2 randomly shuffle with note 7 which is another Snare on another device. The rest come out randomized in a note range of 0-7 (as the receiving device has 8 notes) outgoing on Ch.12
90 00 - always through 90 01 - random 90 02 - only go out random - but either note 2 or 6 ( round robin it's called it I thnk ) 90 03 - +R 90 04 - +R 90 05 - +R 90 06 - +R 09 07 - +R
only notes on with forced velocity 7F should go out.
first part is not yet implemented in the below script
Second part - notes 6-9 arriving from Ch.13 to 16. always have send out random PC's with 50% probability, in range of PC 0-15 outgoing on ch.4 (+block the notes)
I've compiled a few bits and pieces from the forum for learning purposes and added to my own :
# make random probability gaps in incoming notes
IF LOAD ASS K0 = 32 IF MT == 90 IF M2 > 0 IF R64 > K0 XX = XX +B Block Block End END END END
# limit randomization range
If MT == 90 Calc M1 = $0 + R$15 +P End
#additional notes 6-9 to triggering random PC's
9C = C3 +C 9D = C3 +C 9E = C3 +C 9F = C3 +C XX = XX +B
still being in my SB learning journey, on the first set of rules I'm not yet in full understanding of how everything exactly works so it was a bit of a dice throw, some insight would be very educational as this is not the last time I want to be using probability+random.
|
|
|
Post by uncledave on Feb 22, 2022 16:37:49 GMT
Lets try to clean this up a bit. First, the top section is all enclosed in If load....End. So it will not run when a message arrives. You want to move (not copy) one of the ENDs up after the Ass of K0. Then, you're blocking a note 3 times at once. You need to read the "if this, do this, end" like a sentence, always starting with "if" and ending with "end".
But you effectively have 3 handlers for Note On (MT==90). You really need to put them all in one big if..end and sort them out by the note or channel values. Also, remember that you can modify the message (M0, M1, M2) and SB will send it on out. This business of cloning and then blocking is unnecessary, and confusing for both you and me.
Ah, I see, you mean for all the Note On handlers to run, servicing the random PC option. This could be a lot simpler.
Also, I don't know what you mean by "+P" on the Calc M1 step. You use +P when initializing variables in load that you want to save in a preset. It's meaningless in a calc outside of load.
Finally, you need to tighten up the spec before coding. Instead of trying to write code fragments, write down *exactly* what should happen when a specific note arrives on a specific channel. For example, do you want any note 6-9 on any channel 13-16 to trigger a PC with 50% probability, and that's a random PC # from 0-15? So the actual note value and channel number has no effect on the result? What happens to other notes on those channels? This is very easy, if that's what you want.
|
|
|
Post by uncledave on Feb 22, 2022 16:53:49 GMT
I think this does what you're trying to do with notes to PC. #NoteToPC If MT == 90 # we can add handlers for other channels here If MC >= C # channels 13-16 # do we need to check for notes 6-9? If R64 > 32 # skip half the time Block Else Ass M0 = C3 # change message to random PC Ass M1 = R$16 Ass M2 = 0 End End End
If MT == 80 If MC >= C # block note off from ch 13-16 Block End End
It checks the MIDI channels, blocks half the time, and selects a random PC otherwise. I need to check if Rn really includes n in its output. Notice how I indented the code blocks to make clear what is included in each If.
Edit: I checked, and Rn only returns values from 0 to (n-1), so you need R$16 to get 0..15 as a result. Note that this is actually n different values, in this case 16. Edit: Added block of note off, to avoid confusion.
|
|
|
Post by mo13 on Feb 22, 2022 19:26:20 GMT
#NoteToPC If MT == 90 # we can add handlers for other channels here If MC >= C # channels 13-16 # do we need to check for notes 6-9? If R64 > 32 # skip half the time Block Else Ass M0 = C3 # change message to random PC Ass M1 = R$16 Ass M2 = 0 End End End
If MT == 80 If MC >= C # block note off from ch 13-16 Block End End
responding to this meanwhile, the output is exactly what I ment but a 3rd byte on PC msges is a new one for me, because of that i think the receiving device is not able to pick it up. although if I feed your script into mfxMonitor then the 3rd byte is gone?  are you getting the same results on the SB monitor? -good one @note offs yes edit : adding : C3 = C3 +C XX = XX +Bnow all comes through without 3rd byte and responds @the receiving end!
|
|
|
Post by uncledave on Feb 22, 2022 22:15:13 GMT
Sorry, I wasn't sure about that, since we were updating the original note on message. But we can fix it by doing it correctly, instead of using one thing to undo another. Try this: #NoteToPC If MT == 90 # we can add handlers for other channels here If MC >= C # channels 13-16 # do we need to check for notes 6-9? If R64 > 32 # send half the time Snd C3 R$16 # send random PC End Block # always End End
If MT == 80 If MC >= C # block note off from ch 13-16 Block End End
The Snd creates a new message, and the Block means that none of these note messages goes through. This way, we don't have to block all messages in order to do it correctly.
|
|
|
Post by mo13 on Feb 22, 2022 23:16:29 GMT
yeah that's fixed! going to sleep a night over the first part of this post as tonight's attempts ended up a bit in vain, but thanks for putting an emphasis on 'getting the specs right' before attempting a script. The pitfalls examples of not doing that are more clear now.
|
|
|
Post by mo13 on Feb 23, 2022 13:05:42 GMT
uncledave , after more tryouts @first part, I still end up with multiple SB instances, i'd highly appriciate a moment of your time for a head start, especifically @being stuck with passing 2 notes (1 of them shuffled) and having the rest go out Rn. 90 00 - passes 90 01 - +R 90 02 - passes + randomly shuffles with note 6 90 03 - +R 90 04 - +R 90 05 - +R 90 06 - +R 09 07 - +R #only notes on with velocity 7F are coming out.
|
|
|
Post by uncledave on Feb 23, 2022 17:51:51 GMT
Okay, but first we need to clarify the spec. Here is what you said:
So, the sequencer sends notes 0..9 on "different" channels. I don't understand what different means or if we care.
Anyway, notes 0..5 are on channel 1. We need to send note 0 through on channel 1, changing the velocity to 7F.
Note 2 should be converted randomly to 2 or 7, and sent on channel 1 with velocity 7F. You mentioned Round Robin, but I believe that cycles through the possibilities, so in this case it would alternate between 2 and 7, not randomly. We could do alternating instead of random.
The other notes on channel 1 (notes 1 and 3..5) should be replaced by a random value between 0..7, velocity 7F, and sent on channel 12.
We can ignore notes 6..9. Should we block them?
We need to handle the Note Off messages in the same way, because the receiving apps/gear may be unhappy if they receive a lot of hung notes. If sustaining is not important, we might be able to just send a delayed Note Off with each Note On. Otherwise, we need to remember how we modified each input note, and modify the Note Off to match.
And this needs to be integrated with the other part that converts notes to PC messages.
Is that correct?
|
|
|
Post by mo13 on Feb 23, 2022 18:17:31 GMT
So, the sequencer sends notes 0..9 on "different" channels. I don't understand what different means or if we care
we don't, for this part, notes 0-5 come in on Ch.1, last notes 6-9 are coming from Ch.'s 13-16 but which we have already adressed in the 'notes to Rn PC' script from above.
Anyway, notes 0..5 are on channel 1. We need to send note 0 through on channel 1, changing the velocity to 7F.
yes.
Note 2 should be converted randomly to 2 or 7, and sent on channel 1 with velocity 7F. You mentioned Round Robin, but I believe that cycles through the possibilities, so in this case it would alternate between 2 and 7, not randomly. We could do alternating instead of random.
correct and that way it's good as well.
The other notes on channel 1 (notes 1 and 3..5) should be replaced by a random value between 0..7, velocity 7F, and sent on channel 12.
indeed, all of these 0-7 should go out on Ch.12.
We can ignore notes 6..9. Should we block them?
please block them for this part of the script, as we are already using those for the other part @notes to Rn PC.
We need to handle the Note Off messages in the same way, because the receiving apps/gear may be unhappy if they receive a lot of hung notes. If sustaining is not important, we might be able to just send a delayed Note Off with each Note On. Otherwise, we need to remember how we modified each input note, and modify the Note Off to match.
this is a very good point actually, as the device where I'm sending the notes from has infinite sustain on a fader which I'm occasionally using. Let's see how your idea reacts to it first?
And this needs to be integrated with the other part that converts notes to PC messages.
yes!
edit : It's 2 or 6! not like the above - Note 2 should be converted randomly to 2 or 7
|
|
|
Post by uncledave on Feb 23, 2022 23:45:22 GMT
OK. If we're only listening on channel 1, we won't see the other notes. We won't block them. The other part of the script will handle them.
And note 2 should be converted to either 2 or 6 (not 7).
I'm not sure about the random notes thing. We can't play a note that's still being played. So we need to be aware of which notes are currently active, and select a different random note. This is not difficult, just a little more complicated. Does your sender always send Note Off a little time after Note On? If it does, we can rely on its Note Off messages to help with our note management.
|
|
|
Post by mo13 on Feb 24, 2022 0:22:43 GMT
what i ment is, there are also other msges coming in besides the ones that are in focus here, so we only need to pass the ones concerning and block all else. yes, it's notes 2 or 6 on shuffle - here is what go's out :  the aim is to have notes 1, 3-7 randomized in the range of 0-7 but still taking into account that notes 0 and 2 should pass through with priority and left out of the Rn.
|
|
|
Post by mo13 on Mar 8, 2022 20:48:57 GMT
Sorry, I wasn't sure about that, since we were updating the original note on message. But we can fix it by doing it correctly, instead of using one thing to undo another. Try this: #NoteToPC If MT == 90 # we can add handlers for other channels here If MC >= C # channels 13-16 # do we need to check for notes 6-9? If R64 > 32 # send half the time Snd C3 R$16 # send random PC End Block # always End End
If MT == 80 If MC >= C # block note off from ch 13-16 Block End End
uncledave , do you happen to know if is there is a way to engage aka toggle this (or any) script in MidiFire - on/off only when it for instance receives B2 7F 7F ? [edit] script being off meaning that nothing comes out of it anymore so all either get’s blocked or comes through. I also tried to adjust the above rules for the purpose of : #convert notes 0-3 on ch.1 to random notes in the range of 8-40 on ch.12 with 50% probability, but am not succeeding in getting any further then random notes off's coming out. If MT == 90 If R64 > 32 # send half the time Snd 9B R40 # send random notes End Block # always End
If MT == 80 If MC >= 0 # block note off from ch 1 Block End End
# only pass notes 0-2 from Ch.1
90 00 = 90 00 +C 90 01 = 90 01 +C 90 02 = 90 02 +C
90 = 9B +C
# block notes 0-7 on Ch.12
9B 00 = 9B 00 +B
etc.. Would already be very greatful just to hear some insight on the first question, this Rn + probability thing hasn't been the easiest to communicate from my end sorry.
|
|