Post by deepmago on May 15, 2022 16:42:29 GMT
Hello,
I would like to share the code I’ve written to create presets in AUM. It works these way, when a program change is received, StreamByter send 7 control change state saved in 127 positions. The only thing I cannot doing working is the channel reassign: in Q8 it’s stored a channel number I would like to assign for the CC sent instead of the fixed value BF (control change channel 16) in my code.
At the end of code there are extra commands I send as fixed condition, obviously could be delayed or changed.
Next to try is to do the same for faders, I know it could be written better but I’m not a programmer, if someone would like to optimize the code it would be great.
The Code:
# Preset Saver
IF LOAD
set name PRESET_7_SWITCH
set slider_display 1
#—————————————————————————————————————-configure widgets name and range
SET Q0 PROGRAM_CHANGE +M
SET Q1 SW1 +T
SET Q2 SW2 +T
SET Q3 SW3 +T
SET Q4 SW4 +T
SET Q5 SW5 +T
SET Q6 SW6 +T
SET Q7 SW7 +T
SET Q8 CHANNEL $1 $16 +M
SET Q9 SW1_CC +M
SET QA SW2_CC +M
SET QB SW3_CC +M
SET QC SW4_CC +M
SET QD SW5_CC +M
SET QE SW6_CC +M
SET QF SW7_CC +M
#———————————————————————————————————————————-set widget initial values
ASS Q0 = 0 0 0 0 0 0 0 0
ASS Q8 = K8 K9 KA KB KC KD KE KF
#———————————————————————————————————————————-cc table
ASS K0 = 0 1 2 4 8 10 20 40 # and operator
ASS K8 = 0 0 0 0 0 0 0 0 +P
#———————————————————————————————————————————-preset table
ASS L$0 = 0 0 0 0 0 0 0 0 +P
ASS L$8 = 0 0 0 0 0 0 0 0 +P
ASS L$16 = 0 0 0 0 0 0 0 0 +P
ASS L$24 = 0 0 0 0 0 0 0 0 +P
ASS L$32 = 0 0 0 0 0 0 0 0 +P
ASS L$40 = 0 0 0 0 0 0 0 0 +P
ASS L$48 = 0 0 0 0 0 0 0 0 +P
ASS L$56 = 0 0 0 0 0 0 0 0 +P
ASS L$64 = 0 0 0 0 0 0 0 0 +P
ASS L$72 = 0 0 0 0 0 0 0 0 +P
ASS L$80 = 0 0 0 0 0 0 0 0 +P
ASS L$88 = 0 0 0 0 0 0 0 0 +P
ASS L$96 = 0 0 0 0 0 0 0 0 +P
ASS L$104 = 0 0 0 0 0 0 0 0 +P
ASS L$112 = 0 0 0 0 0 0 0 0 +P
ASS L$120 = 0 0 0 0 0 0 0 0 +P
ASS L$128 = 0 0 0 0 0 0 0 0 +P
ASS L$136 = 0 0 0 0 0 0 0 0 +P
ASS L$144 = 0 0 0 0 0 0 0 0 +P
ASS L$152 = 0 0 0 0 0 0 0 0 +P
ASS L$160 = 0 0 0 0 0 0 0 0 +P
ASS L$168 = 0 0 0 0 0 0 0 0 +P
ASS L$176 = 0 0 0 0 0 0 0 0 +P
ASS L$184 = 0 0 0 0 0 0 0 0 +P
ASS L$192 = 0 0 0 0 0 0 0 0 +P
ASS L$200 = 0 0 0 0 0 0 0 0 +P
ASS L$208 = 0 0 0 0 0 0 0 0 +P
ASS L$216 = 0 0 0 0 0 0 0 0 +P
ASS L$224 = 0 0 0 0 0 0 0 0 +P
ASS L$232 = 0 0 0 0 0 0 0 0 +P
ASS L$240 = 0 0 0 0 0 0 0 0 +P
ASS L$248 = 0 0 0 0 0 0 0 0 +P
END
# ——————————————————————————————————————————-handle widget movements
IF M0 == F0 7D 01
# 0 PC, 8 midi ch, 1-7 switch, 9-15 switch cc number
IF M3 == 0
ASS K0 = Q0
SET LB0 SPC
SET LB1 KM3 +D
ASS I2 = 0
WHILE I2 < 7
MAT I2 = I2 + 1
#send CC
MAT I0 = LK0 & KI2
IF I0 != 0
ASS I0 = 7F
ASS QI2 = 1
ELSE
ASS QI2 = 0
END
MAT I1 = I2 + 8
SND BF KI1 I0 #send CC SAVED VALUE
END
END
IF M3 > 7
ASS KM3 = QM3
END
IF M3 > 0
IF M3 < 8
SET LB0 LK0
#send CC and save
MAT I0 = LK0 & KM3
IF I0 != 0
ASS I0 = 7F
END
MAT I1 = M3 + 8
SND BF KI1 I0 #send CC SAVED VALUE
MAT I0 = LK0 ^ KM3
ASS LK0 = I0
SET LB1 LK0
END
END
END
#————————————————————————————————————-———-send default cc
IF M0 == CF
SET Q0 M1 #set slider PC
SND BF $88 LQ0 #send CC SAVED VALUE
#———————————————————————————————————————fixed command send every PC RECEIVED
SND BF $15 0
SND BF $16 0
SND BF $17 0
SND BF $18 0
#———————————————————————————————————————send CC saved values
ASS K0 = Q0
SET LB0 SPC
SET LB1 KM3 +D
ASS I2 = 0
WHILE I2 < 7
MAT I2 = I2 + 1
#send CC
MAT I0 = LK0 & KI2
IF I0 != 0
ASS I0 = 7F
ASS QI2 = 1
ELSE
ASS QI2 = 0
END
MAT I1 = I2 + 8
SND BF KI1 I0 #send CC SAVED VALUE
END
#—————————————————————————————————extra CONVERTED commands
#rainstick CC65 TO C6
BF 41 7F = 99 54 7F
END
I would like to share the code I’ve written to create presets in AUM. It works these way, when a program change is received, StreamByter send 7 control change state saved in 127 positions. The only thing I cannot doing working is the channel reassign: in Q8 it’s stored a channel number I would like to assign for the CC sent instead of the fixed value BF (control change channel 16) in my code.
At the end of code there are extra commands I send as fixed condition, obviously could be delayed or changed.
Next to try is to do the same for faders, I know it could be written better but I’m not a programmer, if someone would like to optimize the code it would be great.
The Code:
# Preset Saver
IF LOAD
set name PRESET_7_SWITCH
set slider_display 1
#—————————————————————————————————————-configure widgets name and range
SET Q0 PROGRAM_CHANGE +M
SET Q1 SW1 +T
SET Q2 SW2 +T
SET Q3 SW3 +T
SET Q4 SW4 +T
SET Q5 SW5 +T
SET Q6 SW6 +T
SET Q7 SW7 +T
SET Q8 CHANNEL $1 $16 +M
SET Q9 SW1_CC +M
SET QA SW2_CC +M
SET QB SW3_CC +M
SET QC SW4_CC +M
SET QD SW5_CC +M
SET QE SW6_CC +M
SET QF SW7_CC +M
#———————————————————————————————————————————-set widget initial values
ASS Q0 = 0 0 0 0 0 0 0 0
ASS Q8 = K8 K9 KA KB KC KD KE KF
#———————————————————————————————————————————-cc table
ASS K0 = 0 1 2 4 8 10 20 40 # and operator
ASS K8 = 0 0 0 0 0 0 0 0 +P
#———————————————————————————————————————————-preset table
ASS L$0 = 0 0 0 0 0 0 0 0 +P
ASS L$8 = 0 0 0 0 0 0 0 0 +P
ASS L$16 = 0 0 0 0 0 0 0 0 +P
ASS L$24 = 0 0 0 0 0 0 0 0 +P
ASS L$32 = 0 0 0 0 0 0 0 0 +P
ASS L$40 = 0 0 0 0 0 0 0 0 +P
ASS L$48 = 0 0 0 0 0 0 0 0 +P
ASS L$56 = 0 0 0 0 0 0 0 0 +P
ASS L$64 = 0 0 0 0 0 0 0 0 +P
ASS L$72 = 0 0 0 0 0 0 0 0 +P
ASS L$80 = 0 0 0 0 0 0 0 0 +P
ASS L$88 = 0 0 0 0 0 0 0 0 +P
ASS L$96 = 0 0 0 0 0 0 0 0 +P
ASS L$104 = 0 0 0 0 0 0 0 0 +P
ASS L$112 = 0 0 0 0 0 0 0 0 +P
ASS L$120 = 0 0 0 0 0 0 0 0 +P
ASS L$128 = 0 0 0 0 0 0 0 0 +P
ASS L$136 = 0 0 0 0 0 0 0 0 +P
ASS L$144 = 0 0 0 0 0 0 0 0 +P
ASS L$152 = 0 0 0 0 0 0 0 0 +P
ASS L$160 = 0 0 0 0 0 0 0 0 +P
ASS L$168 = 0 0 0 0 0 0 0 0 +P
ASS L$176 = 0 0 0 0 0 0 0 0 +P
ASS L$184 = 0 0 0 0 0 0 0 0 +P
ASS L$192 = 0 0 0 0 0 0 0 0 +P
ASS L$200 = 0 0 0 0 0 0 0 0 +P
ASS L$208 = 0 0 0 0 0 0 0 0 +P
ASS L$216 = 0 0 0 0 0 0 0 0 +P
ASS L$224 = 0 0 0 0 0 0 0 0 +P
ASS L$232 = 0 0 0 0 0 0 0 0 +P
ASS L$240 = 0 0 0 0 0 0 0 0 +P
ASS L$248 = 0 0 0 0 0 0 0 0 +P
END
# ——————————————————————————————————————————-handle widget movements
IF M0 == F0 7D 01
# 0 PC, 8 midi ch, 1-7 switch, 9-15 switch cc number
IF M3 == 0
ASS K0 = Q0
SET LB0 SPC
SET LB1 KM3 +D
ASS I2 = 0
WHILE I2 < 7
MAT I2 = I2 + 1
#send CC
MAT I0 = LK0 & KI2
IF I0 != 0
ASS I0 = 7F
ASS QI2 = 1
ELSE
ASS QI2 = 0
END
MAT I1 = I2 + 8
SND BF KI1 I0 #send CC SAVED VALUE
END
END
IF M3 > 7
ASS KM3 = QM3
END
IF M3 > 0
IF M3 < 8
SET LB0 LK0
#send CC and save
MAT I0 = LK0 & KM3
IF I0 != 0
ASS I0 = 7F
END
MAT I1 = M3 + 8
SND BF KI1 I0 #send CC SAVED VALUE
MAT I0 = LK0 ^ KM3
ASS LK0 = I0
SET LB1 LK0
END
END
END
#————————————————————————————————————-———-send default cc
IF M0 == CF
SET Q0 M1 #set slider PC
SND BF $88 LQ0 #send CC SAVED VALUE
#———————————————————————————————————————fixed command send every PC RECEIVED
SND BF $15 0
SND BF $16 0
SND BF $17 0
SND BF $18 0
#———————————————————————————————————————send CC saved values
ASS K0 = Q0
SET LB0 SPC
SET LB1 KM3 +D
ASS I2 = 0
WHILE I2 < 7
MAT I2 = I2 + 1
#send CC
MAT I0 = LK0 & KI2
IF I0 != 0
ASS I0 = 7F
ASS QI2 = 1
ELSE
ASS QI2 = 0
END
MAT I1 = I2 + 8
SND BF KI1 I0 #send CC SAVED VALUE
END
#—————————————————————————————————extra CONVERTED commands
#rainstick CC65 TO C6
BF 41 7F = 99 54 7F
END