From: Mark Slee Date: Thu, 22 Aug 2013 07:31:52 +0000 (-0700) Subject: Update mappings for all objects, assuming wiring in Alex's brain X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=1d75c8a91217d2e9ff9d8b877a5e04f2f63afb00;p=SugarCubes.git Update mappings for all objects, assuming wiring in Alex's brain --- diff --git a/SugarCubes.pde b/SugarCubes.pde index ab81e30..637f7c6 100644 --- a/SugarCubes.pde +++ b/SugarCubes.pde @@ -25,7 +25,7 @@ LXPattern[] patterns(GLucose glucose) { return new LXPattern[] { - + // Slee new Swarm(glucose), new SpaceTime(glucose), @@ -82,6 +82,9 @@ LXPattern[] patterns(GLucose glucose) { new TestTowerPattern(glucose), new TestProjectionPattern(glucose), new TestStripPattern(glucose), + new TestBassMapping(glucose), + new TestFloorMapping(glucose), + new TestSpeakerMapping(glucose), // new TestHuePattern(glucose), // new TestXPattern(glucose), // new TestYPattern(glucose), diff --git a/TestPatterns.pde b/TestPatterns.pde index e47651a..706626d 100644 --- a/TestPatterns.pde +++ b/TestPatterns.pde @@ -5,6 +5,75 @@ abstract class TestPattern extends SCPattern { } } +class TestSpeakerMapping extends TestPattern { + TestSpeakerMapping(GLucose glucose) { + super(glucose); + } + + public void run(int deltaMs) { + int h = 0; + for (Speaker speaker : model.speakers) { + for (Strip strip : speaker.strips) { + float b = 100; + for (Point p : strip.points) { + colors[p.index] = color(h % 360, 100, b); + b = max(0, b - 10); + } + h += 70; + } + } + } + +} + +class TestBassMapping extends TestPattern { + TestBassMapping(GLucose glucose) { + super(glucose); + } + + public void run(int deltaMs) { + int[] strips = { 2, 1, 0, 3, 13, 12, 15, 14, 9, 8, 11, 10, 5, 4, 7, 6 }; + int h = 0; + for (int si : strips) { + float b = 100; + for (Point p : model.bassBox.strips.get(si).points) { + colors[p.index] = color(h % 360, 100, b); + b = max(0, b - 10); + } + h += 70; + } + } +} + +class TestFloorMapping extends TestPattern { + TestFloorMapping(GLucose glucose) { + super(glucose); + } + + public void run(int deltaMs) { + int[] strutIndices = {6, 5, 4, 3, 2, 1, 0, 7}; + int h = 0; + for (int si : strutIndices) { + float b = 100; + for (Point p : model.bassBox.struts.get(si).points) { + colors[p.index] = color(h % 360, 100, b); + b = max(0, b - 10); + } + h += 50; + } + int[] floorIndices = {0, 1, 2, 3}; + h = 0; + for (int fi : floorIndices) { + float b = 100; + for (Point p : model.boothFloor.strips.get(fi).points) { + colors[p.index] = color(h, 100, b); + b = max(0, b - 3); + } + h += 90; + } + } +} + class TestStripPattern extends TestPattern { SinLFO d = new SinLFO(4, 40, 4000); diff --git a/_Mappings.pde b/_Mappings.pde index 73e1fe2..91bd543 100644 --- a/_Mappings.pde +++ b/_Mappings.pde @@ -107,33 +107,43 @@ public Model buildModel() { } public PandaMapping[] buildPandaList() { + final int LEFT_SPEAKER = 0; + final int RIGHT_SPEAKER = 1; + return new PandaMapping[] { new PandaMapping( "10.200.1.29", new ChannelMapping[] { - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }), - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }), - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }), - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }), - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }), - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }), - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }), - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }), - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }), - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }), - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }), - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }), - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }), - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }), - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }), - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 5, 6, 4, 3 }), + new ChannelMapping(), + new ChannelMapping(), + new ChannelMapping(), + new ChannelMapping(), + new ChannelMapping(), + new ChannelMapping(), + new ChannelMapping(), + new ChannelMapping(ChannelMapping.MODE_BASS), + new ChannelMapping(ChannelMapping.MODE_STRUTS_AND_FLOOR), + new ChannelMapping(ChannelMapping.MODE_SPEAKER, LEFT_SPEAKER), + new ChannelMapping(ChannelMapping.MODE_SPEAKER, RIGHT_SPEAKER), }), new PandaMapping( "10.200.1.28", new ChannelMapping[] { - new ChannelMapping(ChannelMapping.MODE_BASS), - new ChannelMapping(ChannelMapping.MODE_FLOOR), - new ChannelMapping(ChannelMapping.MODE_SPEAKER, 0), - new ChannelMapping(ChannelMapping.MODE_SPEAKER, 1), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }), }), }; } @@ -221,7 +231,7 @@ class ChannelMapping { public static final int MODE_CUBES = 1; public static final int MODE_BASS = 2; public static final int MODE_SPEAKER = 3; - public static final int MODE_FLOOR = 4; + public static final int MODE_STRUTS_AND_FLOOR = 4; public static final int MODE_INVALID = 5; public static final int NO_OBJECT = -1; @@ -253,7 +263,7 @@ class ChannelMapping { if (speakerIndex < 0 || speakerIndex >= glucose.model.speakers.size()) { throw new RuntimeException("Invalid speaker channel mapping: " + speakerIndex); } - } else if ((mode == MODE_FLOOR) || (mode == MODE_BASS) || (mode == MODE_NULL)) { + } else if ((mode == MODE_STRUTS_AND_FLOOR) || (mode == MODE_BASS) || (mode == MODE_NULL)) { if (rawObjectIndices.length > 0) { throw new RuntimeException("Bass/floor/null mappings cannot specify object indices"); } diff --git a/_Overlay.pde b/_Overlay.pde index 50c037c..b071128 100644 --- a/_Overlay.pde +++ b/_Overlay.pde @@ -824,7 +824,7 @@ class DebugUI { case ChannelMapping.MODE_SPEAKER: drawNumBox(xPos, yPos, "S" + channel.objectIndices[0], debugState[channelNum][1]); break; - case ChannelMapping.MODE_FLOOR: + case ChannelMapping.MODE_STRUTS_AND_FLOOR: drawNumBox(xPos, yPos, "F", debugState[channelNum][1]); break; case ChannelMapping.MODE_NULL: @@ -903,19 +903,26 @@ class DebugUI { state = debugState[channelIndex][1]; if (state != DEBUG_STATE_ANIM) { color debugColor = (state == DEBUG_STATE_WHITE) ? white : off; - for (Point p : glucose.model.bassBox.points) { - colors[p.index] = debugColor; + for (Strip s : glucose.model.bassBox.boxStrips) { + for (Point p : s.points) { + colors[p.index] = debugColor; + } } } break; - case ChannelMapping.MODE_FLOOR: + case ChannelMapping.MODE_STRUTS_AND_FLOOR: state = debugState[channelIndex][1]; if (state != DEBUG_STATE_ANIM) { color debugColor = (state == DEBUG_STATE_WHITE) ? white : off; for (Point p : glucose.model.boothFloor.points) { colors[p.index] = debugColor; } + for (Strip s : glucose.model.bassBox.struts) { + for (Point p : s.points) { + colors[p.index] = debugColor; + } + } } break; diff --git a/_PandaDriver.pde b/_PandaDriver.pde index cd85e9b..d6cd995 100644 --- a/_PandaDriver.pde +++ b/_PandaDriver.pde @@ -66,55 +66,73 @@ public static class PandaDriver { }; private final static int[][] BASS_STRIP_ORDERING = { - {0, FORWARD }, - {1, FORWARD }, - {2, FORWARD }, - {3, FORWARD }, - {4, FORWARD }, - {5, FORWARD }, - {6, FORWARD }, - {7, FORWARD }, - {8, FORWARD }, - {9, FORWARD }, - {10, FORWARD }, - {11, FORWARD }, - {12, FORWARD }, - {13, FORWARD }, - {14, FORWARD }, - {15, FORWARD }, - {16, FORWARD }, - {17, FORWARD }, - {18, FORWARD }, - {19, FORWARD }, - {20, FORWARD }, - {21, FORWARD }, - {22, FORWARD }, + // front face, counterclockwise from bottom front left + {2, BACKWARD }, + {1, BACKWARD }, + {0, BACKWARD }, + {3, BACKWARD }, + + // left face, counterclockwise from bottom front left + {13, BACKWARD }, + {12, BACKWARD }, + {15, BACKWARD }, + {14, BACKWARD }, + + // back face, counterclockwise from bottom rear left + {9, BACKWARD }, + {8, BACKWARD }, + {11, BACKWARD }, + {10, BACKWARD }, + + // right face, counterclockwise from bottom rear right + {5, BACKWARD }, + {4, BACKWARD }, + {7, BACKWARD }, + {6, BACKWARD }, + }; + + private final static int[][] STRUT_STRIP_ORDERING = { + {6, BACKWARD}, + {5, FORWARD}, + {4, BACKWARD}, + {3, FORWARD}, + {2, BACKWARD}, + {1, FORWARD}, + {0, BACKWARD, /* dummy pixels at the end of string, remove when strip is fixed */ 4}, + {7, FORWARD}, }; private final static int[][] FLOOR_STRIP_ORDERING = { {0, FORWARD}, {1, FORWARD}, {2, FORWARD}, - {3, FORWARD}, + {3, BACKWARD}, }; - private final static int[][] SPEAKER_STRIP_ORDERING = { - {0, FORWARD }, - {1, FORWARD }, - {2, FORWARD }, - {3, FORWARD }, - {4, FORWARD }, - {5, FORWARD }, - {6, FORWARD }, - {7, FORWARD }, - {8, FORWARD }, - {9, FORWARD }, - {10, FORWARD }, - {11, FORWARD }, - {12, FORWARD }, - {13, FORWARD }, - {14, FORWARD }, - {15, FORWARD }, + // The speakers are currently configured to be wired the same + // as cubes with Wiring.FRONT_LEFT. If this needs to be changed, + // remove this null assignment and change the below to have mappings + // for the LEFT and RIGHT speaker + private final static int[][][] SPEAKER_STRIP_ORDERING = null; /* { + // Left speaker + { + // Front face, counter-clockwise from bottom left + {2, BACKWARD }, + {1, BACKWARD }, + {0, BACKWARD }, + {3, BACKWARD }, + }, + // Right speaker + { + // Front face, counter-clockwise from bottom left + {2, BACKWARD }, + {1, BACKWARD }, + {0, BACKWARD }, + {3, BACKWARD }, + } + };*/ + + private final static int[][] LEFT_SPEAKER_STRIP_ORDERING = { }; public PandaDriver(String ip, Model model, PandaMapping pm) { @@ -163,19 +181,37 @@ public static class PandaDriver { case ChannelMapping.MODE_BASS: for (int[] config : BASS_STRIP_ORDERING) { pi = mapStrip(model.bassBox.strips.get(config[0]), config[1], points, pi); + if (config.length >= 3) pi += config[2]; } break; - case ChannelMapping.MODE_FLOOR: + case ChannelMapping.MODE_STRUTS_AND_FLOOR: + for (int[] config : STRUT_STRIP_ORDERING) { + pi = mapStrip(model.bassBox.struts.get(config[0]), config[1], points, pi); + if (config.length >= 3) pi += config[2]; + } for (int[] config : FLOOR_STRIP_ORDERING) { pi = mapStrip(model.boothFloor.strips.get(config[0]), config[1], points, pi); + if (config.length >= 3) pi += config[2]; } break; case ChannelMapping.MODE_SPEAKER: - for (int[] config : SPEAKER_STRIP_ORDERING) { + int [][] speakerStripOrdering; + if (SPEAKER_STRIP_ORDERING == null) { + // Copy the cube strip ordering + int[] frontLeftCubeWiring = CUBE_STRIP_ORDERINGS[0]; + speakerStripOrdering = new int[frontLeftCubeWiring.length][]; + for (int i = 0; i < frontLeftCubeWiring.length; ++i) { + speakerStripOrdering[i] = new int[] { frontLeftCubeWiring[0], BACKWARD }; + } + } else { + speakerStripOrdering = SPEAKER_STRIP_ORDERING[channel.objectIndices[0]]; + } + for (int[] config : speakerStripOrdering) { Speaker speaker = model.speakers.get(channel.objectIndices[0]); pi = mapStrip(speaker.strips.get(config[0]), config[1], points, pi); + if (config.length >= 3) pi += config[2]; } break; @@ -205,6 +241,20 @@ public static class PandaDriver { return pi; } + public void disable() { + if (enabled) { + enabled = false; + println("PandaBoard/" + ip + ": OFF"); + } + } + + public void enable() { + if (!enabled) { + enabled = true; + println("PandaBoard/" + ip + ": ON"); + } + } + public void toggle() { enabled = !enabled; println("PandaBoard/" + ip + ": " + (enabled ? "ON" : "OFF")); diff --git a/code/GLucose.jar b/code/GLucose.jar index cda18e5..88f7e08 100644 Binary files a/code/GLucose.jar and b/code/GLucose.jar differ