From 1b8ec15f473ce870790425148d7c73255bbe4433 Mon Sep 17 00:00:00 2001 From: Toby Segaran Date: Tue, 13 Aug 2013 22:06:53 -0700 Subject: [PATCH] SoundCubes pattern kind of cool, maybe a bit epileptic --- TobySegaran.pde | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/TobySegaran.pde b/TobySegaran.pde index 2eba4cf..a46ef4a 100644 --- a/TobySegaran.pde +++ b/TobySegaran.pde @@ -135,10 +135,13 @@ class SoundCubes extends SCPattern { private FFT fft = null; private LinearEnvelope[] bandVals = null; + private float[] lightVals = null; private int avgSize; - + SawLFO pos = new SawLFO(0, 9, 8000); + public SoundCubes(GLucose glucose) { super(glucose); + addModulator(pos).trigger(); } protected void onActive() { @@ -151,18 +154,31 @@ class SoundCubes extends SCPattern { for (int i = 0; i < this.bandVals.length; ++i) { this.addModulator(this.bandVals[i] = (new LinearEnvelope(0, 0, 700+i*4))).trigger(); } + lightVals = new float[avgSize]; } } public void run(int deltaMs) { this.fft.forward(this.lx.audioInput().mix); - for (int i = 0; i < avgSize; ++i) { float value = this.fft.getAvg(i); this.bandVals[i].setEndVal(value,40).trigger(); + float lv = min(value*25,100); + if (lv>lightVals[i]-6) { + lightVals[i]=lv; + } else { + lightVals[i]=lightVals[i]-6; + } } - for (Point p : model.points) { - colors[p.index] = color(100,0,bandVals[1].getValuef()*25 ); + for (int i=0; i