- for (Point p : model.points) {
- if (bright[p.index]==0) {
- colors[p.index]=color(0,0,0);
+ }
+}
+
+class SoundCubes extends SCPattern {
+
+ private FFT fft = null;
+ private LinearEnvelope[] bandVals = null;
+ private int avgSize;
+
+ public SoundCubes(GLucose glucose) {
+ super(glucose);
+ }
+
+ protected void onActive() {
+ if (this.fft == null) {
+ this.fft = new FFT(lx.audioInput().bufferSize(), lx.audioInput().sampleRate());
+ this.fft.window(FFT.HAMMING);
+ this.fft.logAverages(40, 1);
+ this.avgSize = this.fft.avgSize();
+ this.bandVals = new LinearEnvelope[this.avgSize];
+ for (int i = 0; i < this.bandVals.length; ++i) {
+ this.addModulator(this.bandVals[i] = (new LinearEnvelope(0, 0, 700+i*4))).trigger();