-class Flitters extends SCPattern {
+class BouncyBalls extends SCPattern {
- static final int NUM_FLITTERS = 6;
+ static final int NUM_BALLS = 6;
- class Flitter {
+ class BouncyBall {
Accelerator yPos;
TriangleLFO xPos = new TriangleLFO(0, model.xMax, random(8000, 19000));
+ float zPos;
- Flitter(int i) {
+ BouncyBall(int i) {
addModulator(xPos).setBasis(random(0, TWO_PI)).start();
addModulator(yPos = new Accelerator(0, 0, 0));
+ zPos = lerp(model.zMin, model.zMax, (i+2.) / (NUM_BALLS + 4.));
}
void bounce(float midiVel) {
}
}
float falloff = 130.f / (12 + blobSize.getValuef() * 36);
+ float xv = xPos.getValuef();
+ float yv = yPos.getValuef();
+
for (Point p : model.points) {
- float d = dist(p.x, p.y, xPos.getValuef(), yPos.getValuef());
+ float d = sqrt((p.x-xv)*(p.x-xv) + (p.y-yv)*(p.y-yv) + .1*(p.z-zPos)*(p.z-zPos));
float b = constrain(130 - falloff*d, 0, 100);
if (b > 0) {
colors[p.index] = blendColor(colors[p.index], color(
}
}
- final Flitter[] flitters = new Flitter[NUM_FLITTERS];
+ final BouncyBall[] balls = new BouncyBall[NUM_BALLS];
final BasicParameter bounce = new BasicParameter("BNC", .8);
final BasicParameter flr = new BasicParameter("FLR", 0);
final BasicParameter blobSize = new BasicParameter("SIZE", 0.5);
- Flitters(GLucose glucose) {
+ BouncyBalls(GLucose glucose) {
super(glucose);
- for (int i = 0; i < flitters.length; ++i) {
- flitters[i] = new Flitter(i);
+ for (int i = 0; i < balls.length; ++i) {
+ balls[i] = new BouncyBall(i);
}
addParameter(bounce);
addParameter(flr);
public void run(double deltaMs) {
setColors(#000000);
- for (Flitter f : flitters) {
- f.run(deltaMs);
+ for (BouncyBall b : balls) {
+ b.run(deltaMs);
}
}
public boolean noteOnReceived(Note note) {
- int pitch = (note.getPitch() + note.getChannel()) % NUM_FLITTERS;
- flitters[pitch].bounce(note.getVelocity());
+ int pitch = (note.getPitch() + note.getChannel()) % NUM_BALLS;
+ balls[pitch].bounce(note.getVelocity());
return true;
}
}
/**
* Engine construction and initialization.
*/
-LXPattern[] _patterns(GLucose glucose) {
+
+LXTransition _transition(GLucose glucose) {
+ return new DissolveTransition(glucose.lx).setDuration(1000);
+}
+
+LXPattern[] _leftPatterns(GLucose glucose) {
LXPattern[] patterns = patterns(glucose);
for (LXPattern p : patterns) {
- p.setTransition(new DissolveTransition(glucose.lx).setDuration(1000));
+ p.setTransition(_transition(glucose));
}
return patterns;
}
+LXPattern[] _rightPatterns(GLucose glucose) {
+ LXPattern[] patterns = _leftPatterns(glucose);
+ LXPattern[] rightPatterns = new LXPattern[patterns.length+1];
+ int i = 0;
+ rightPatterns[i++] = new BlankPattern(glucose).setTransition(_transition(glucose));
+ for (LXPattern p : patterns) {
+ rightPatterns[i++] = p;
+ }
+ return rightPatterns;
+}
+
+
void logTime(String evt) {
int now = millis();
println(evt + ": " + (now - lastMillis) + "ms");
// Set the patterns
Engine engine = lx.engine;
- engine.setPatterns(patterns = _patterns(glucose));
- engine.addDeck(_patterns(glucose));
+ engine.setPatterns(patterns = _leftPatterns(glucose));
+ engine.addDeck(_rightPatterns(glucose));
logTime("Built patterns");
glucose.setTransitions(transitions(glucose));
logTime("Built transitions");