From: Toby Segaran Date: Wed, 14 Aug 2013 05:06:53 +0000 (-0700) Subject: SoundCubes pattern kind of cool, maybe a bit epileptic X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=1b8ec15f473ce870790425148d7c73255bbe4433;p=SugarCubes.git SoundCubes pattern kind of cool, maybe a bit epileptic --- 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