/* This class extends the Beads class, which is a abstract class with a few basic methods. Most importantly, the Beads class has a messageReceived() method that may be overridden. Every time the clock ticks, it will send a message to an instance of Trigger and the messageReceived function is executed. In the following code, we ask the clock what tick number it is on and we compute the modulus 4 of that number. That gives us the oscillator number that should be turned on (along with its corresponding led). All the others are turned off. */ class Trigger extends Bead { void messageReceived(Bead message) { long b = cl.getCount() % 4; for (int i=0; i<4; i++) { if (b == i) { switches[i].on = true; wp[i].pause(false); } else { switches[i].on = false; wp[i].pause(true); } } } }