class GlitchPlasma extends SCPattern { private int pos = 0; private float satu = 100; private float speed = 1; private float glitch = 0; BasicParameter saturationParameter = new BasicParameter("SATU", 1.0); BasicParameter speedParameter = new BasicParameter("SPEED", 0.1); BasicParameter glitchParameter = new BasicParameter("GLITCH", 0.0); public GlitchPlasma(GLucose glucose) { super(glucose); addParameter(saturationParameter); addParameter(speedParameter); addParameter(glitchParameter); } public void onParameterChanged(LXParameter parameter) { if (parameter == saturationParameter) { satu = 100*parameter.getValuef(); } else if (parameter == speedParameter) { speed = 8*parameter.getValuef(); } else if (parameter == glitchParameter) { glitch = parameter.getValuef(); } } public void run(int deltaMs) { for (Point p : model.points) { float hv = sin(dist(p.fx + pos, p.fy, 128.0, 128.0) / 8.0) + sin(dist(p.fx, p.fy, 64.0, 64.0) / 8.0) + sin(dist(p.fx, p.fy + pos / 7, 192.0, 64.0) / 7.0) + sin(dist(p.fx, p.fz + pos, 192.0, 100.0) / 8.0); float bv = 100; colors[p.index] = color((hv+2)*50, satu, bv); } if (random(1.0)= MAX_INT-1) pos=0; } } // This is very much a work in progress. Trying to get a flame effect. class FireEffect extends SCPattern { private float[][] intensity; private float hotspot; private float decay = 0.3; private int xm; private int ym; BasicParameter decayParameter = new BasicParameter("DECAY", 0.3); public FireEffect(GLucose glucose) { super(glucose); xm = int(model.xMax); ym = int(model.yMax); intensity = new float[xm][ym]; addParameter(decayParameter); } public void onParameterChanged(LXParameter parameter) { if (parameter == decayParameter) { decay = parameter.getValuef(); } } private color flameColor(float level) { if (level<=0) return color(0,0,0); float br=min(100,sqrt(level)*15); return color(level/1.7,100,br); } public void run(int deltaMs) { for (int x=10;x45 || x%50<5) { intensity[x][ym-1] = random(30,100); } else { intensity[x][ym-1] = random(0,50); } } for (int x=1;xbright[p.index]) { colors[p.index] = color(hv,sat[i].getValuef(),br); bright[p.index] = br; } } } } } } class SoundRain extends SCPattern { private FFT fft = null; private LinearEnvelope[] bandVals = null; private float[] lightVals = null; private int avgSize; SawLFO pos = new SawLFO(0, 9, 8000); SinLFO col1 = new SinLFO(0, model.xMax, 5000); public SoundRain(GLucose glucose) { super(glucose); addModulator(pos).trigger(); addModulator(col1).trigger(); } 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(); } 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]) { lightVals[i]=min(lightVals[i]+10,lv,100); } else { lightVals[i]=max(lv,lightVals[i]-5,0); } } for (Cube c : model.cubes) { for (int j=0; j