-class WarmPlasma extends SCPattern {
+class GlitchPlasma extends SCPattern {
private int pos = 0;
private float satu = 100;
private float speed = 1;
BasicParameter speedParameter = new BasicParameter("SPEED", 0.1);
BasicParameter glitchParameter = new BasicParameter("GLITCH", 0.0);
- public WarmPlasma(GLucose glucose) {
+ public GlitchPlasma(GLucose glucose) {
super(glucose);
addParameter(saturationParameter);
addParameter(speedParameter);
if (parameter == saturationParameter) {
satu = 100*parameter.getValuef();
} else if (parameter == speedParameter) {
- speed = 10*parameter.getValuef();
+ speed = 8*parameter.getValuef();
} else if (parameter == glitchParameter) {
glitch = parameter.getValuef();
}
float bv = 100;
colors[p.index] = color((hv+2)*25, satu, bv);
}
- if (random(1.0)<glitch/10) {
- pos=pos-20;
+ if (random(1.0)<glitch/20) {
+ pos=pos-int(random(10,30));
}
pos+=speed;
if (pos >= MAX_INT-1) pos=0;
for (Strip strip : model.strips) {
for (int i=0;i<numOsc;i++) {
float avgdist=0.0;
- for (Point p : strip.points) {
- avgdist+=dist(p.fx,p.fy,p.fz,fX[i].getValuef(),fY[i].getValuef(),fZ[i].getValuef());
- }
- avgdist/=Strip.POINTS_PER_STRIP;
- //println(avgdist);
+ avgdist = dist(strip.points.get(8).fx,strip.points.get(8).fy,strip.points.get(8).fz,fX[i].getValuef(),fY[i].getValuef(),fZ[i].getValuef());
boolean on = avgdist<30;
float hv = (lx.getBaseHuef()+colorOffset[i])%100;
float br = max(0,100-avgdist*4);
}
}
}
- 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();
}
}
}
+
+ 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();
+ }
+ for (Point p : model.points) {
+ colors[p.index] = color(100,0,bandVals[1].getValuef()*25 );
+ }
+ }
}