For a long time, I wanted a way to control Sonic Pi with hardware, to get some performance aspect.
The idea behind this system is to use the pads on the APC as ‘mute switches’ for instruments.
This code allows me to toggle things with the APC and get visual feedback.
The pad matrix is represented as an array of integers, corresponding to the colors.
When programming it, I put together the synthesis part like I normally would, then add if-statements looking at the array.
The single array approach allows me to program the pad matrix by changing a single value.
0 means no light, the pad does nothing.
1 is green, ‘active’.
3 is red, ‘muted’.
5 is yellow, I use that for toggles.
The if-statements in the synthesis part look like this:
do_stuff if states[‘pad-number’] == 1
Here is the code:
Here is a little demo I put together: