I experimenting combining the first Slipmat prototype (built with the Csound API) with Processing. Getting the two systems working together was fairly straight forward. Here’s the code that generated the video.
The following method from class Disc does two things when a disc collides with a border: change direction of the disc and trigger a slipmat event:
public void moveDisc() { x += xVelocity * SCALE_VELOCITY; y += yVelocity * SCALE_VELOCITY; if (x <= DISC_RADIUS || x >= width - 1 - DISC_RADIUS) { xVelocity *= -1; playNote(); } if (y <= DISC_RADIUS || y >= height - 1 - DISC_RADIUS) { yVelocity *= -1; playNote(); } }
The method playNote() also belongs to class Disc, and is where the actual triggering of the Slipmat event occurs. The instances sp1 and sp2 are part of the Slipmat system. The “sp” is short for “sine percussion.”
public void playNote() { sp1.playNote(0.0, 0.35 * (1 - x / width), frequency); sp2.playNote(0.0, 0.35 * x / width, frequency); }