|
Post by mo13 on May 27, 2022 12:05:25 GMT
I'm still generally good on the CPU, it was just interesting to see it with the new statistics, this is the SB instance with the merged scripts: 
|
|
|
Post by uncledave on May 27, 2022 12:08:23 GMT
Hi. I looked at your code. You don't need the If M0 == B2 and its End inside the Else, because it's already tested higher up. This whole block is the handler for B2 CCs. Also, you need to remove the first Block, before the resendMessage receiver. Blocking there clears the buffer, so M0 will be zero after that.
Is needResend meant to to send the CC as B3 to actually trigger the Solo in AUM? If so, that logic can probably be removed if it's no longer required. The incorrect Block I mentioned above has probably already done this, since the resendMessage will never be received.
|
|
|
Post by uncledave on May 27, 2022 12:12:37 GMT
I'm still generally good on the CPU, it was just interesting to see it with the new statistics, this is the SB instance with the merged scripts:  That's Peak DSP (since when?). It might be from the initialization, or from the bank clearing, when it sends 32 messages rapid-fire. Or from AllSolosOff when it runs quite a lot of code to update all the Solos and Mutes.
|
|
|
Post by mo13 on May 27, 2022 12:54:12 GMT
yeah removing all that didn't do anything for the rest so that's good. only missing the LED feedback for CC119 in the code now but I can live with that, will try to figure it out in the meantime:
|
|
|
Post by uncledave on May 27, 2022 13:36:10 GMT
I checked and the resend was only meant to activate the AUM Solo in AllSolosOff, so it is redundant now. I revised your script with all the extras commented out, so you can see what is removed. You could remove these lines, making the script simpler.
What feedback are you looking for from CC 119? It's a momentary action, so it should not remain lighted. Should it light at the start of AllSolosOff and clear at the end? That might be too quick to notice. Should it light for 1 second, then clear? Which color numbers for on and off?
Here's the updated script: #SetLedMerged
If load Alias $32 bankSize Alias 4 numBanks Alias B2 setCommand Alias $112 totalBanks Alias 8 togSize # two rows of 8 toggles Alias 10 buttonBase # offset to button data in J and K Alias 20 transBase # offset to transition data in K # Alias J18 needResend Alias 4 soloBit Alias 2 muteBit Ass J10 = 2 2 2 2 2 2 2 0 # J18... contains working variables Ass J18 = 0 0 0 0 0 0 0 0 # K10, etc. contains 16 ON colors Ass K10 = 5 5 5 5 5 5 5 6 2 2 2 2 2 2 2 5 # K20 is transition table for first 7 columns, K28 for last column # Each entry is new states for a given state. High nybble for top button, # low nybble for bottom button. Ass K20 = 42 52 50 50 04 25 24 25 Ass K28 = 42 42 60 60 06 06 24 24 # Note that the values in the K array are packed together, with no gaps. # There are 16 colors, then 2 transition tables of 8. # our own internal SysEx message # Define resendMessage F0 7D 02 # Sets one LED. pState is 0 for OFF, non-zero for ON. # pCol is the column number, pOffset is 0 for top row, 8 for bottom. Sub SetOneLed pValue pCol pOffset # determine the color If pValue > 0 Mat I28 = pCol + buttonBase # index column color Mat I28 = I28 + pOffset Ass I28 = KI28 # index ON color from table Else Ass I28 = 3 End # determine CC# Mat I29 = pCol + totalBanks Mat I29 = I29 + pOffset Send setCommand I29 I28 # set the LED End Ass J00 = 80 80 80 80 Ass K00 = 5 6 4 6 3 0 3 0 Sub SetLedPair pCol pState Mat I20 = pState & soloBit # top button state SetOneLed I20 pCol 0 Mat I20 = pState & muteBit # bottom button state SetOneLed I20 pCol togSize End # Updates data for one column. pNumb is button number, 0..15 Sub UpdateToggle pNumb Mat I10 = pNumb % togSize # column index 0..7 Mat I11 = pNumb / togSize # row number 0, 1 Mat I12 = I10 + buttonBase # index state, JI12 is state value Set LB0 JI12 # display entering state Mat I13 = JI12 + transBase # index transition entry for state # use second transition table for last column If I10 == 7 Mat I13 = I13 + togSize End # update new state from table, using high or low nybble of transition # in KI13. Top row uses high nybble, bottom uses low If I11 == 0 Mat JI12 = KI13 / 10 # divide moves high nybble to low Mat JI12 = JI12 & F # ensure nothing crazy Else Mat JI12 = KI13 & F # mask selects low nybble End Set LB1 JI12 # display new state # update leds in this column SetLedPair I10 JI12 End Sub PresetToggles Ass I10 = 0 # loop over columns While I10 < togSize Mat I12 = I10 + buttonBase SetLedPair I10 JI12 Mat I10 = I10 + 1 End Set LB0 STogs_Init End Sub ClearBank pBank Mat I20 = pBank * bankSize Mat I21 = I20 + bankSize If I21 > totalBanks Ass I21 = totalBanks End Mat I22 = pBank + numBanks Ass I22 = KI22 While I20 < I21 Send setCommand I20 I22 Mat I20 = I20 + 1 End End Sub SetLedAny pNumb Mat I10 = pNumb / bankSize If JI10 == 80 ClearBank I10 Else Mat I11 = I10 + numBanks Send setCommand JI10 KI11 End Send setCommand pNumb KI10 Ass JI10 = pNumb End Sub AllSolosOff # messages sent with +I flag go to the SB input queue, not outside. # Send resendMessage 1 F7 +I # send internal msg to enable resend Ass I10 = 0 Ass I11 = togSize Mat I11 = I11 - 1 # I10 will run 0-6 While I10 < I11 Mat I12 = I10 + buttonBase # index button states Mat I12 = JI12 & soloBit # test the Solo bit If I12 != 0 Mat I13 = I10 + totalBanks # create the CC# Send setCommand I13 $127 +I # send internal cmd to push solo End Mat I10 = I10 + 1 End # Send resendMessage 0 F7 +I # cancel previous resend enable End Set Name LedTog # new name reflecting merge End # Initialization ———————————————————————————
If M0 == B2 If M1 < totalBanks SetLedAny M1 Else # If M0 == B2 # If M1 >= totalBanks # handle toggles if M1 == $119 AllSolosOff Else Mat I00 = M1 - totalBanks # value 0..15 UpdateToggle I00 # If needResend == 1 # Mat M0 = M0 + 1 # send msg on next higher channel # Send M0 M1 M2 # send this msg out (clone) # End End # End # End End End # Block
# If M0 == resendMessage # M3 is 1 to enable resend, 0 to disable # Ass needResend = M3 # End Block # all input messages are blocked
|
|
|
Post by mo13 on May 27, 2022 13:50:56 GMT
thanks! so once one or multiple Solos are engaged then CC119 should receive value 06 aka Cyan blinking, and it should go back to value 0 either upon releasing the last active Solo manually or by pressing CC119 aka UNsolo ALL. so in the script it's just an indicator that Solo bank is now active/deactivated.
[edit] value 0 should be value 3 as that's UNlit
|
|
|
Post by uncledave on May 27, 2022 14:27:06 GMT
thanks! so once one or multiple Solos are engaged then CC119 should receive value 06 aka Cyan blinking, and it should go back to value 0 either upon releasing the last active Solo manually or by pressing CC119 aka UNsolo ALL. so in the script it's just an indicator that Solo bank is now active/deactivated. [edit] value 0 should be value 3 as that's UNlit Ah. I remember we talked about this before. It's a little complicated because we need to monitor changes in the Solo states. If done, it will automatically handle UNsolo ALL, because AllSolosOff just pushes the button for each Soloed channel. Why is this useful, since the lighted Solos show that they're active? As I said, it's complicated because we do not actually know when Solo changes. Each event (input) triggers a state transition, then we set both lights accordingly, but we don't detect changes in the light settings. I'll have to think about it. Edit: Almost got it. Update should be soon.
|
|
|
Post by uncledave on May 27, 2022 16:06:28 GMT
OK. Here it is. Wasn't too difficult. Any change in a Solo state increases or decreases the soloCount, and CC# 119 is lit if the count > 0. The new UpdateSoloCount does all the work. Also, I restored the call to PresetToggles, which had been accidentally deleted. I tested this with my test rig, and it seems to work as intended. #SetLedMerged
If load Alias $32 bankSize Alias 4 numBanks Alias B2 setCommand Alias $112 totalBanks Alias 8 togSize # two rows of 8 toggles Alias 10 buttonBase # offset to button data in J and K Alias 20 transBase # offset to transition data in K Alias J20 soloCount Alias 4 soloBit Alias 2 muteBit
# data for banks Ass J00 = 80 80 80 80 Ass K00 = 5 6 4 6 3 0 3 0 # all channels start muted Ass J10 = 2 2 2 2 2 2 2 0 # J18... contains working variables Ass J18 = 0 0 0 0 0 0 0 0 Ass J20 = 0 0 0 0 0 0 0 0 # K10, etc. contains 16 ON colors Ass K10 = 5 5 5 5 5 5 5 6 2 2 2 2 2 2 2 5 # K20 is transition table for first 7 columns, K28 for last column # Each entry is new states for a given state. High nybble for top button, # low nybble for bottom button. Ass K20 = 42 52 50 50 04 25 24 25 Ass K28 = 42 42 60 60 06 06 24 24 # Note that the values in the K array are packed together, with no gaps. # There are 16 colors, then 2 transition tables of 8. # Sets one LED. pState is 0 for OFF, non-zero for ON. # pCol is the column number, pOffset is 0 for top row, 8 for bottom. Sub SetOneLed pValue pCol pOffset # determine the color If pValue > 0 Mat I28 = pCol + buttonBase # index column color Mat I28 = I28 + pOffset Ass I28 = KI28 # index ON color from table Else Ass I28 = 3 End # determine CC# Mat I29 = pCol + totalBanks Mat I29 = I29 + pOffset Send setCommand I29 I28 # set the LED End # maintains the count of active solos, lights button 119 # parameters are the new and prior states Sub UpdateSoloCount pNew pOld Mat I20 = pNew ^ pOld # differences are non-zero Mat I20 = I20 & soloBit # detect change in solo bit If I20 != 0 # here when solo has changed Mat I21 = pNew & soloBit # check new solo state # logic prevents count from going out of bounds, even on error. If I21 == 0 # here when solo now off If soloCount > 0 Mat soloCount = soloCount - 1 End Else # here when solo now on If soloCount < 7 Mat soloCount = soloCount + 1 End End # select color for current count Ass I20 = 3 If soloCount > 0 Ass I20 = 6 End Send setCommand $119 I20 # update the led End End Sub SetLedPair pCol pState Mat I20 = pState & soloBit # top button state SetOneLed I20 pCol 0 Mat I20 = pState & muteBit # bottom button state SetOneLed I20 pCol togSize End # Updates data for one column. pNumb is button number, 0..15 Sub UpdateToggle pNumb Mat I10 = pNumb % togSize # column index 0..7 Mat I11 = pNumb / togSize # row number 0, 1 Mat I12 = I10 + buttonBase # index state, JI12 is state value Set LB0 JI12 # display entering state Ass I14 = JI12 # remember prior state Mat I13 = JI12 + transBase # index transition entry for state # use second transition table for last column If I10 == 7 Mat I13 = I13 + togSize End # update new state from table, using high or low nybble of transition # in KI13. Top row uses high nybble, bottom uses low If I11 == 0 Mat JI12 = KI13 / 10 # divide moves high nybble to low Mat JI12 = JI12 & F # ensure nothing crazy Else Mat JI12 = KI13 & F # mask selects low nybble End Set LB1 JI12 # display new state UpdateSoloCount JI12 I14 # update leds in this column SetLedPair I10 JI12 End Sub PresetToggles Ass I10 = 0 # loop over columns While I10 < togSize Mat I12 = I10 + buttonBase SetLedPair I10 JI12 Mat I10 = I10 + 1 End Set LB0 STogs_Init Ass soloCount = 0 End Sub ClearBank pBank Mat I20 = pBank * bankSize Mat I21 = I20 + bankSize If I21 > totalBanks Ass I21 = totalBanks End Mat I22 = pBank + numBanks Ass I22 = KI22 While I20 < I21 Send setCommand I20 I22 Mat I20 = I20 + 1 End End Sub SetLedAny pNumb Mat I10 = pNumb / bankSize If JI10 == 80 ClearBank I10 Else Mat I11 = I10 + numBanks Send setCommand JI10 KI11 End Send setCommand pNumb KI10 Ass JI10 = pNumb End Sub AllSolosOff # messages sent with +I flag go to the SB input queue, not outside. Ass I10 = 0 Ass I11 = togSize Mat I11 = I11 - 1 # I10 will run 0-6 While I10 < I11 Mat I12 = I10 + buttonBase # index button states Mat I12 = JI12 & soloBit # test the Solo bit If I12 != 0 Mat I13 = I10 + totalBanks # create the CC# Send setCommand I13 $127 +I # send internal cmd to push solo End Mat I10 = I10 + 1 End End
PresetToggles # initialize the lights Set Name LedTog # new name reflecting merge End # Initialization ———————————————————————————
If M0 == B2 If M1 < totalBanks SetLedAny M1 Else if M1 == $119 AllSolosOff Else Mat I00 = M1 - totalBanks # value 0..15 UpdateToggle I00 End End End
Block # all input messages are blocked
|
|
|
Post by mo13 on May 28, 2022 11:53:48 GMT
fantastic Dave, thank you!
final thing for this script, I'm trying to figure out how to crop bank B to B2 20-37, and have an extra function bank of 8 on/off LEDs from B2 38 to 3F, these would be the same on/off's as the last bank of mute LEDs, thus with different colors which I now know how to change but the rest still a little tricky, I assume there is more to this then changing the data in Aliases :bankSize, numBanks and totalbanks?
|
|
|
Post by uncledave on May 28, 2022 14:31:16 GMT
Changing the aliases would affect all the banks. We'd need to create an array with the start index and length of each bank. Then analyze each incoming CC# to see which bank it falls in. A bit more complicated but not difficult. Give me a couple of days.
How do you mean the new bank would be the same as the mutes? The mutes are special because they're tied to the solos. I guess you mean they'd be toggles with different on and off colors.
|
|
|
Post by mo13 on May 28, 2022 16:14:05 GMT
Great, meanwhile I'll try to find more sense in aliases's relationship to the arrays.
Exactly, nothing to do with the special case of mutes, only referred to those to demonstrate the on/off function.
|
|
|
Post by uncledave on May 28, 2022 17:51:07 GMT
Great, meanwhile I'll try to find more sense in aliases's relationship to the arrays. Good. Those aliases are mainly just names for numbers, like bankSize for $32. If you look where they're used you'll see how they work. We do some computer geeky stuff, like dividing the CC# by 32 to get an integer (0..3) giving the number of the bank. Remember, SB data is all integers, so 5/32 gives 0, while 63/32 gives 1, with no rounding. The first 4 entries in J (J00..J03) contain the number of the current light in each bank. They're initialized to 80, which is off-scale, so it cannot happen. K00..K03 contain the lit color for each bank, K04..K07 contain the off color for each bank. With that, you should be able to understand SetLedAny. Remember that arrays are indexed like KI00, the position in array K selected by the value of I00; for example, if I00 contains 5, KI00 is the same as K05. Most programming languages would do something like K[I00]; SB just joins 'em up.
|
|