Novation Launchpad – Note number to XY Coordinates and back again.
First thing I did with my new Launchpad? Nope, I didn’t hook it up to Live and jam. I hooked it up, fired up Processing and worked out how to light up the pads and recieve the notes so I could hack it to do anything I wanted to.
One thing I noticed straight off the bat is the note numbers are not incremental. Each row starts 16 higher than the last - I assume to allow for the same firmware to work in a 16 x 16 layout model - and there is a very simple way that reminds me of the technique of bitshifting I used back in the bad old days of DVD authoring to convert from one to the other.
// To go from XY to the note number noteNumber = y * 16 + x; // To go from the note number to the XY x = noteNumber % 16; y = (noteNumber - x) / 16;
Hopefully that will save someone ten minutes of head scratching.