Post by dusty on Jul 1, 2020 17:39:50 GMT
I'm working on a script that will recreate the functionality of the APC40. I have a bunch of things worked out and now I'm trying to figure out how to reduce my script to something more manageable.
One thing that I needed to do was capture a button press, and send it back to the APC light up the button. So in the code below, I'm capturing the note on saving that state in to a variable L0. The note off that happens immediately after is dropped and on the second push of the button it blocks the note on but the note off turns off the light and returns the variable to it's default state of 0. ready for the next button press.
The issue is there are 87 buttons so the code is becoming very long and unmanageable. I was hoping to use a subroutine to generalize this block of code. I'm getting errors with how I'm trying to use variables this way, so I think I'm missing something important. I would appreciate any direction or thoughts..
Here is what I currently have:
IF LOAD
ASS L0 = 1
END
# Launch clip row: 0, position: 1
IF M0 == 90 30 7F
IF L0 == 0
BLOCK
ASS L0 = 1
SEND 90 30 7F
ELSE
BLOCK
END
END
IF M0 == 80 30 7F
IF L0 == 2
BLOCK
SEND 80 30 7F
ASS L0 = 0
ELSE
BLOCK
ASS L0 = 2
END
END
What I'm trying to get worked out (this is pseudo-code, not a working version to be clear)
IF LOAD
ASS L0 = 0
clipBtnRemap noteNum var_pos
IF M0 == 90 noteNum 7F
IF var_pos == 0
BLOCK
ASS var_pos = 1
SEND 90 noteNum 7F
ELSE
BLOCK
END
END
IF M0 == 80 noteNum 7F
IF var_pos == 2
BLOCK
SEND 80 noteNum 7F
ASS var_pos = 0
ELSE
BLOCK
ASS var_pos = 2
END
END
END
END
IF M0 == 90 30 7F
clipBtnRemap 30 L0
One thing that I needed to do was capture a button press, and send it back to the APC light up the button. So in the code below, I'm capturing the note on saving that state in to a variable L0. The note off that happens immediately after is dropped and on the second push of the button it blocks the note on but the note off turns off the light and returns the variable to it's default state of 0. ready for the next button press.
The issue is there are 87 buttons so the code is becoming very long and unmanageable. I was hoping to use a subroutine to generalize this block of code. I'm getting errors with how I'm trying to use variables this way, so I think I'm missing something important. I would appreciate any direction or thoughts..
Here is what I currently have:
IF LOAD
ASS L0 = 1
END
# Launch clip row: 0, position: 1
IF M0 == 90 30 7F
IF L0 == 0
BLOCK
ASS L0 = 1
SEND 90 30 7F
ELSE
BLOCK
END
END
IF M0 == 80 30 7F
IF L0 == 2
BLOCK
SEND 80 30 7F
ASS L0 = 0
ELSE
BLOCK
ASS L0 = 2
END
END
What I'm trying to get worked out (this is pseudo-code, not a working version to be clear)
IF LOAD
ASS L0 = 0
clipBtnRemap noteNum var_pos
IF M0 == 90 noteNum 7F
IF var_pos == 0
BLOCK
ASS var_pos = 1
SEND 90 noteNum 7F
ELSE
BLOCK
END
END
IF M0 == 80 noteNum 7F
IF var_pos == 2
BLOCK
SEND 80 noteNum 7F
ASS var_pos = 0
ELSE
BLOCK
ASS var_pos = 2
END
END
END
END
IF M0 == 90 30 7F
clipBtnRemap 30 L0