From 77461646caabcd4527d4e7c2d23d9fab1e96fdcd Mon Sep 17 00:00:00 2001 From: Leighton Wallace Date: Sun, 30 Jul 2017 00:58:56 +0200 Subject: [PATCH] Add DomeEQ pattern `DomeEQ` turns the dome into an equalizer for the input which should encourage people inside to make noise! Also add debug output and make the audio belts blurrier. --- L8on.pde | 66 +++++++++++++++++++++++++++++++++++++++++++++--- L8onUtil.pde | 2 +- TestPatterns.pde | 38 +++++++++++++++++++++++----- dome.pde | 9 ++++--- 4 files changed, 99 insertions(+), 16 deletions(-) diff --git a/L8on.pde b/L8on.pde index 105353b..f486db3 100644 --- a/L8on.pde +++ b/L8on.pde @@ -188,7 +188,7 @@ public class HeartsBeat extends LEDomePattern { public void resetHeartSaturation(int i) { this.heartSaturations[i].setPeriod(getRate()); this.heartSaturations[i].setBasis(random(0.02, 0.15)); - this.heartSaturations[i].start(); //<>// //<>// + this.heartSaturations[i].start(); //<>// } public void run(double deltaMs) { @@ -521,8 +521,8 @@ public class Explosions extends LEDomePattern { private BoundedParameter brightnessParameter = new BoundedParameter("BRGT", 50, 10, 80); private LEDomeAudioParameterFull rateParameter = new LEDomeAudioParameterFull("RATE", 8000.0, 8000.0, 750.0); + private BoundedParameter blurParameter = new BoundedParameter("BLUR", 0.69); - private BlurLayer blurLayer = new BlurLayer(lx, this, blurParameter); private LEDomeAudioBeatGate beatGate = new LEDomeAudioBeatGate("XBEAT", lx); @@ -1859,7 +1859,7 @@ public class AudioBelts extends LEDomePattern { private float midBeltY = 23.26; private float trebleBeltY = model.yMax - (1.25 * FEET); - private BoundedParameter blurParameter = new BoundedParameter("BLUR", 0.4); + private BoundedParameter blurParameter = new BoundedParameter("BLUR", 0.5); private BlurLayer blurLayer = new BlurLayer(lx, this, blurParameter); private BoundedParameter maxBrightnessParameter = new BoundedParameter("BRIG", 70, 0, 100); @@ -1923,5 +1923,63 @@ public class AudioBelts extends LEDomePattern { setColor(p.index, 0); } } - } + } +} + +public class DomeEQ extends LEDomePattern { + private GraphicMeter meter; + private BandGate bandGate = new BandGate(lx); + private final int ORIGIN_POINT_INDEX = 8; + private final int MAX_POINT_INDEX = 544; + private double originAzimuth = model.points[ORIGIN_POINT_INDEX].azimuth; + private double projectedMaxAzimuth; + + private BoundedParameter brightnessParam = new BoundedParameter("BRIG", 60, 10, 100); + + private BoundedParameter blurParameter = new BoundedParameter("BLUR", 0.69); + private BlurLayer blurLayer = new BlurLayer(lx, this, blurParameter); + private LXModulator huePeriod = new SinLFO(10000, 20000, 60000); + private LXModulator hueModulator = new SinLFO(0, 360, huePeriod); + + private final double GAIN = 6; + + public DomeEQ(LX lx) { + super(lx); + this.meter = bandGate.meter; + this.originAzimuth = model.points[ORIGIN_POINT_INDEX].azimuth; + this.projectedMaxAzimuth = this.projectAzimuth(model.points[MAX_POINT_INDEX].azimuth); + + addParameter(brightnessParam); + + addParameter(blurParameter); + addLayer(blurLayer); + + addModulator(huePeriod).start(); + addModulator(hueModulator).start(); + + bandGate.gain.setValue(GAIN); + addModulator(bandGate).start(); + } + + public void run(double deltaMs) { + for (LXPoint p : model.points) { + if (p.yn <= this.bandGate.getBand(this.getBandIndex(p))) { + float hue = (hueModulator.getValuef() + (p.yn * 360.0)) % 360.0; + setColor(p.index, LX.hsb(hue, 100, brightnessParam.getValuef())); + } else { + setColor(p.index, 0); + } + } + } + + private int getBandIndex(LXPoint p) { + double projectedAzimuth = this.projectAzimuth(p.azimuth); + double normalizedPosition = LXUtils.constrain(projectedAzimuth / projectedMaxAzimuth, 0.0, 1); + double bandIndex = LXUtils.constrain(normalizedPosition * this.meter.numBands, 0.0, this.meter.numBands - 1); + return (int)bandIndex; + } + + private double projectAzimuth(double azimuth) { + return (azimuth - originAzimuth + LX.TWO_PI) % LX.TWO_PI; + } } \ No newline at end of file diff --git a/L8onUtil.pde b/L8onUtil.pde index 0772257..0c34478 100644 --- a/L8onUtil.pde +++ b/L8onUtil.pde @@ -239,7 +239,7 @@ public class SnakeLayer extends LXLayer { float distToTravel = dist(firstHeadPoint.x, firstHeadPoint.y, firstHeadPoint.z, secondHeadPoint.x, secondHeadPoint.y, secondHeadPoint.z); return max(distToTravel / (snakeSpeed.getValuef() / SECONDS), 0.0); } -} //<>// //<>// +} //<>// /* * A container to keep state of the different 3d waves in the color remix. diff --git a/TestPatterns.pde b/TestPatterns.pde index 0dd72a7..73fd9ee 100644 --- a/TestPatterns.pde +++ b/TestPatterns.pde @@ -23,15 +23,15 @@ public class HueTestPattern extends LXPattern { } } -public class FaceIteratorTest extends LEDomePattern { +public class FaceIteratorTest extends LEDomePattern implements LXParameterListener { private final SawLFO currIndex = new SawLFO(0, ((LEDome)model).faces.size(), ((LEDome)model).faces.size() * 300); private final BoundedParameter selectedFace = new BoundedParameter("SEL", 0, 0, ((LEDome)model).faces.size() - 1); public FaceIteratorTest(LX lx) { super(lx); - - addParameter(selectedFace); - addModulator(currIndex).start(); + + addParameter(selectedFace); + addModulator(currIndex).start(); } public void run(double deltaMs) { @@ -40,9 +40,7 @@ public class FaceIteratorTest extends LEDomePattern { for(int i = 0; i < model.faces.size(); i++) { LEDomeFace face = model.faces.get(i); - if(!face.hasLights()) { - continue; - } + if(!face.hasLights()) { continue; } float bv = (i == index || i == selectedIndex) ? 100.0 : 0.0; @@ -51,6 +49,32 @@ public class FaceIteratorTest extends LEDomePattern { } } } + + public void onParameterChanged(LXParameter parameter) { + if (parameter != this.selectedFace) { return; } + + int selectedIndex = (int) selectedFace.getValuef(); + LEDomeFace face = model.faces.get(selectedIndex); + if(!face.hasLights()) { return; } + + println("Face stats for " + selectedIndex); + println("Center x: " + face.xf()); + println("Center y: " + face.yf()); + println("Center z: " + face.zf()); + + for(LXPoint p: face.points) { + println("Point index: " + p.index); + println(" x: " + p.x); + println(" y: " + p.y); + println(" z: " + p.z); + println(" theta: " + p.theta); + println(" azimuth: " + p.azimuth); + } + + println(); + } + + } class EdgeIteratorTest extends LEDomePattern { diff --git a/dome.pde b/dome.pde index 605ac67..7365e30 100644 --- a/dome.pde +++ b/dome.pde @@ -59,7 +59,7 @@ LEDome model; LXStudio lx; LXPattern[] patterns(P3LX lx) { - return new LXPattern[] { + return new LXPattern[] { // Create New Pattern Instances Below HERE new ShadyWaffle(lx), @@ -80,6 +80,7 @@ LXPattern[] patterns(P3LX lx) { new SpotLights(lx), new JumpRopes(lx), new Explosions(lx), + new DomeEQ(lx), new SnakeApple(lx), new Snakes(lx), new HeartsBeat(lx), @@ -91,14 +92,14 @@ LXPattern[] patterns(P3LX lx) { new Stargaze(lx), // Kristján - new Disco(lx), + new Disco(lx), // pld new Spiral(lx), // rohan - new Sunshine(lx), - new SunshineHalf(lx), + //new Sunshine(lx), + //new SunshineHalf(lx), // Test Patterns new LayerDemoPattern(lx),