X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=TobySegaran.pde;h=c5e19d25efe1034450cad8a4a38d3fe93d8666d8;hb=efa0f27b8b4f6fbf16b2dc7aadf8164a7a0e3e97;hp=2eba4cfd5f74f324461b1e6dcd3d2c88d292494d;hpb=10692893d2872a618a79ebc58d0d83e3cf7ae420;p=SugarCubes.git diff --git a/TobySegaran.pde b/TobySegaran.pde index 2eba4cf..c5e19d2 100644 --- a/TobySegaran.pde +++ b/TobySegaran.pde @@ -30,7 +30,7 @@ class GlitchPlasma extends SCPattern { + 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)*25, satu, bv); + colors[p.index] = color((hv+2)*50, satu, bv); } if (random(1.0)bright[p.index]) { @@ -131,16 +131,29 @@ class StripBounce extends SCPattern { } } -class SoundCubes extends SCPattern { +class SoundRain extends SCPattern { private FFT fft = null; private LinearEnvelope[] bandVals = null; + private float[] lightVals = null; private int avgSize; - - public SoundCubes(GLucose glucose) { + private float gain = 25; + SawLFO pos = new SawLFO(0, 9, 8000); + SinLFO col1 = new SinLFO(0, model.xMax, 5000); + BasicParameter gainParameter = new BasicParameter("GAIN", 0.5); + + public SoundRain(GLucose glucose) { super(glucose); + addModulator(pos).trigger(); + addModulator(col1).trigger(); + addParameter(gainParameter); } + public void onParameterChanged(LXParameter parameter) { + if (parameter == gainParameter) { + gain = 50*parameter.getValuef(); + } + } protected void onActive() { if (this.fft == null) { this.fft = new FFT(lx.audioInput().bufferSize(), lx.audioInput().sampleRate()); @@ -151,18 +164,139 @@ 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*gain,100); + if (lv>lightVals[i]) { + lightVals[i]=min(lightVals[i]+15,lv,100); + } else { + lightVals[i]=max(lv,lightVals[i]-5,0); + } + } + for (Cube c : model.cubes) { + for (int j=0; jlightVals[i]) { + lightVals[i]=min(lightVals[i]+30,lv,model.yMax+10); + } else { + lightVals[i]=max(lv,lightVals[i]-10,0); + } } - for (Point p : model.points) { - colors[p.index] = color(100,0,bandVals[1].getValuef()*25 ); + int i = 0; + for (Cube c : model.cubes) { + for (int j=0; javgSize) seq=avgSize-seq; + seq=constrain(seq,0,avgSize-1); + float br=max(0, lightVals[seq]-p.fy); + colors[p.index] = color((dis*avgSize*65)/model.xMax,90,br); + } + } + } } } } +