|
Post by redheronmusic on Mar 12, 2024 19:27:22 GMT
# General NRPN Engine
# Red Heron Music # March 12, 2024 # rev 1, add “stored MSB + LSB option”
# General conversion utility from Control Change to NRPN message # Conversions specified in L array # Options: # MSB only # MSB with zero value LSB # MSB + Previously stored LSB, send LSB first, stored until MSB data received # LSB + Previously stored MSB, send MSB first, stored until LSB data received
# Data matrix format, replace with your desired conversions # Input CC Channel (B0 + chan value 0-F) # | Input CC # # | | Action # | | | 0 MSB only, no LSB # | | | 1 MSB with zero LSB # | | | 2 MSB + LSB (LSB stored with action 4) # | | | 3 MSB + LSB (MSB stored with action 4) # | | | 4 Store LSB or MSB # | | | NRPN MSB (ignored action 4) # | | | | NRPN LSB (ignored action 4) # | | | | | Data # | | | | | | Action 0, 1 ignored # | | | | | | Action 2, 3, pointer to stored data, starting from 0 # | | | | | | Action 4, stored data # B0 3A 00 02 03 00 # Cc 3Ah (58) on Channel 1 to NRPN 02, 03, MSB only # B1 42 01 07 33 00 # Cc 42h (66) on Channel 2 to NRPN 07, 33, MSB+zero LSB # B1 43 02 07 33 03 # Cc 43h (67) on Channel 2 to NRPN 07, 33, MSB+LSB, LSB from line 03 (counting from 00) # B2 37 04 00 00 00 # Cc 37h (55) on Channel 3 - store LSB only (trailing three digits ignored) # BF 53 00 17 07 00 # Cc 53h (83) on Channel 15 to NRPN 17, 07, MSB only # B0 22 03 17 07 06 # Cc 22h (34) on Channel 1 to NRPN 17, 07, MSB + LSB from line 06 # B0 23 04 00 00 00 # Cc 23h (35) on Channel 1 - store LSB only # FF end of data marker
# indices increase by 6, use decimal ($) for easy indexing # NRPN channel will match input MSB Cc channel # if Input Cc Channel & # are duplicated, only first match is implemented
# L array stores conversion matrix # i0 for loop variable # i1 for loop variable + 1 # … # i5 loop variable + 5 # i6 Temp value
If Load Ass L$0 = B0 3A 00 02 03 00 Ass L$6 = B1 42 01 07 33 00 Ass L$12 = B1 43 02 07 33 03 Ass L$18 = B2 37 04 00 00 00 Ass L$24 = BF 53 00 17 07 00 Ass L$30 = B0 22 03 17 07 06 Ass L$36 = B0 23 04 00 00 00 Ass L$42 = FF
Alias i0 Loop Alias i1 Loop+1 Alias i2 Loop+2 Alias i3 Loop+3 Alias i4 Loop+4 Alias i5 Loop+5 Alias i6 Temp
Sub SendNRPN Bx N_Msb N_Lsb D_Msb D_Lsb Snd Bx 62 N_Lsb Snd Bx 63 N_Msb Snd Bx 06 D_Msb If D_Lsb != FF Snd Bx 26 D_Lsb End Snd Bx 62 7F Snd Bx 63 7F End
End
If MT == B0 Ass Loop = 0 Ass Loop+1 = 1 # only need first two until we have a match While Li0 != FF # alias not allowed on indirect
If M0 == Li0 Li1 # alias not allowed on indirect Mat Loop+2 = Loop + 2 # match, complete pointer values Mat Loop+3 = Loop + 3 Mat Loop+4 = Loop + 4 Mat Loop+5 = Loop + 5
If Li2 == 0 # MSB_Only, no LSB SendNRPN M0 Li3 Li4 M2 FF # alias not allowed on indirect End
If Li2 == 1 # MSB_Only, zero LSB SendNRPN M0 Li3 Li4 M2 00 # alias not allowed on indirect End
If Li2 == 2 # MSB + stored LSB Mat Temp = Li5 * 6 # alias not allowed on indirect Mat Temp = Temp + 5 SendNRPN M0 Li3 Li4 M2 Li6 # alias not allowed on indirect End
If Li2 == 3 # LSB + stored MSB Mat Temp = Li5 * 6 # alias not allowed on indirect Mat Temp = Temp + 5 SendNRPN M0 Li3 Li4 Li6 M2 # alias not allowed on indirect End
If Li2 == 4 # Store value Ass Li5 = M2 End
Block # discard input message Exit # had a match, so processing is complete End Mat Loop = Loop + 6 Mat Loop+1 = Loop + 1 End End
|
|