From: Mark Slee Date: Sat, 9 Nov 2013 03:17:17 +0000 (-0800) Subject: Merge branch 'master' of https://github.com/sugarcubes/SugarCubes into alexgreen X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=4ad9f85959980d306800ad50636f4fd7c2a5d36b;hp=-c;p=SugarCubes.git Merge branch 'master' of https://github.com/sugarcubes/SugarCubes into alexgreen Conflicts: AlexGreen.pde _Internals.pde --- 4ad9f85959980d306800ad50636f4fd7c2a5d36b diff --combined MarkSlee.pde index 56c0653,4a37206..d3237e1 --- a/MarkSlee.pde +++ b/MarkSlee.pde @@@ -57,10 -57,10 +57,10 @@@ class Cathedrals extends SCPattern if (abs(p.x - cx) < arm) { d = min(abs(p.x - cx), abs(p.y - middle)); } - colors[p.index] = color( + colors[p.index] = lx.hsb( (lx.getBaseHuef() + .2*abs(p.y - model.cy)) % 360, min(100, sf*dist(abs(p.x - cx), p.y, arm, middle)), - max(0, 120 - d*falloff)); + constrain(120 - d*falloff, 0, 100)); } } } @@@ -110,7 -110,7 +110,7 @@@ class MidiMusic extends SCPattern } float posf = position.getValuef(); for (Point p : model.points) { - colors[p.index] = blendColor(colors[p.index], color( + colors[p.index] = blendColor(colors[p.index], lx.hsb( (lx.getBaseHuef() + .2*abs(p.x - model.cx) + .2*abs(p.y - model.cy)) % 360, 100, max(0, bright - posf*100 - falloff*abs(p.y - posf*model.yMax)) @@@ -255,7 -255,7 +255,7 @@@ for (Point p : s.points) { int wavi = (int) constrain(p.x / model.xMax * wval.length, 0, wval.length-1); float wavb = max(0, wave.getValuef()*100. - 8.*abs(p.y - wval[wavi])); - colors[p.index] = color( + colors[p.index] = lx.hsb( (lx.getBaseHuef() + .2*abs(p.x - model.cx) + .2*abs(p.y - model.cy)) % 360, 100, constrain(wavb + max(0, maxBright - 40.*abs(sparklePos - abs(i - (Cube.POINTS_PER_STRIP-1)/2.))), 0, 100) @@@ -684,11 -684,10 +684,11 @@@ class Swarm extends SCPattern colors[p.index] = lx.hsb( (lx.getBaseHuef() + 0.3 * abs(p.x - hOffX.getValuef())) % 360, constrain(80 + 40 * fV, 0, 100), - constrain(100 - (30 - fV * falloff.getValuef()) * modDist(i + (s*63)%61, offset.getValuef() * strip.metrics.numPoints, strip.metrics.numPoints), 0, 100) + constrain(100 - + (30 - fV * falloff.getValuef()) * modDist(i + (s*63)%61, offset.getValuef() * strip.metrics.numPoints, strip.metrics.numPoints), 0, 100) ); ++i; - } + } ++s; } } @@@ -1412,7 -1411,7 +1412,7 @@@ class ColorFuckerEffect extends SCEffec float bMod = level.getValuef(); float sMod = 1 - desat.getValuef(); float hMod = hueShift.getValuef(); - float fSharp = 1/(1.0001-sharp.getValuef()); + float fSharp = sharp.getValuef(); float fSoft = soft.getValuef(); boolean mon = mono.getValuef() > 0.5; boolean ivt = invert.getValuef() > 0.5; @@@ -1426,7 -1425,12 +1426,12 @@@ hsb[2] = 1 - hsb[2]; } if (fSharp > 0) { - hsb[2] = hsb[2] < .5 ? pow(hsb[2],fSharp) : 1-pow(1-hsb[2],fSharp); + fSharp = 1/(1-fSharp); + if (hsb[2] < .5) { + hsb[2] = pow(hsb[2],fSharp); + } else { + hsb[2] = 1-pow(1-hsb[2],fSharp); + } } if (fSoft > 0) { if (hsb[2] > 0.5) { @@@ -1478,7 -1482,7 +1483,7 @@@ class QuantizeEffect extends SCEffect class BlurEffect extends SCEffect { - final LXParameter amount = new BasicParameter("AMT", 0); + final BasicParameter amount = new BasicParameter("AMT", 0); final int[] frame; final LinearEnvelope env = new LinearEnvelope(0, 1, 100); diff --combined _Internals.pde index 0090d18,728e343..fb2a9c7 --- a/_Internals.pde +++ b/_Internals.pde @@@ -40,8 -40,8 +40,8 @@@ final float TRAILER_WIDTH = 240 final float TRAILER_DEPTH = 97; final float TRAILER_HEIGHT = 33; -final int MaxCubeHeight = 5; -final int NumBackTowers = 11; +final int MaxCubeHeight = 7; +final int NumBackTowers = 18; int targetFramerate = 60; int startMillis, lastMillis; @@@ -62,6 -62,7 +62,7 @@@ boolean debugMode = false DebugUI debugUI; boolean uiOn = true; boolean simulationOn = true; + boolean diagnosticsOn = false; LXPattern restoreToPattern = null; PImage logo; float[] hsb = new float[3]; @@@ -216,6 -217,8 +217,8 @@@ void setup() * Core render loop and drawing functionality. */ void draw() { + long drawStart = System.nanoTime(); + // Draws the simulation and the 2D UI overlay background(40); @@@ -233,13 -236,18 +236,18 @@@ debugUI.maskColors(sendColors); } + long simulationStart = System.nanoTime(); if (simulationOn) { drawSimulation(simulationColors); } + long simulationNanos = System.nanoTime() - simulationStart; // 2D Overlay UI + long uiStart = System.nanoTime(); drawUI(); - + long uiNanos = System.nanoTime() - uiStart; + + long gammaStart = System.nanoTime(); // Gamma correction here. Apply a cubic to the brightness // for better representation of dynamic range for (int i = 0; i < sendColors.length; ++i) { @@@ -247,11 -255,76 +255,76 @@@ float b = hsb[2]; sendColors[i] = lx.hsb(360.*hsb[0], 100.*hsb[1], 100.*(b*b*b)); } + long gammaNanos = System.nanoTime() - gammaStart; - // TODO(mcslee): move into GLucose engine + long sendStart = System.nanoTime(); for (PandaDriver p : pandaBoards) { p.send(sendColors); } + long sendNanos = System.nanoTime() - sendStart; + + long drawNanos = System.nanoTime() - drawStart; + + if (diagnosticsOn) { + drawDiagnostics(drawNanos, simulationNanos, uiNanos, gammaNanos, sendNanos); + } + } + + void drawDiagnostics(long drawNanos, long simulationNanos, long uiNanos, long gammaNanos, long sendNanos) { + float ws = 4 / 1000000.; + int thirtyfps = 1000000000 / 30; + int sixtyfps = 1000000000 / 60; + int x = width - 138; + int y = height - 14; + int h = 10; + noFill(); + stroke(#999999); + rect(x, y, thirtyfps * ws, h); + noStroke(); + int xp = x; + float hv = 0; + for (long val : new long[] {lx.timer.drawNanos, simulationNanos, uiNanos, gammaNanos, sendNanos }) { + fill(lx.hsb(hv % 360, 100, 80)); + rect(xp, y, val * ws, h-1); + hv += 140; + xp += val * ws; + } + noFill(); + stroke(#333333); + line(x+sixtyfps*ws, y+1, x+sixtyfps*ws, y+h-1); + + y = y - 14; + xp = x; + float tw = thirtyfps * ws; + noFill(); + stroke(#999999); + rect(x, y, tw, h); + h = 5; + noStroke(); + for (long val : new long[] { + lx.engine.timer.deckNanos, + lx.engine.timer.copyNanos, + lx.engine.timer.fxNanos}) { + float amt = val / (float) lx.timer.drawNanos; + fill(lx.hsb(hv % 360, 100, 80)); + rect(xp, y, amt * tw, h-1); + hv += 140; + xp += amt * tw; + } + + xp = x; + y += h; + hv = 120; + for (long val : new long[] { + lx.engine.getDeck(0).timer.runNanos, + lx.engine.getDeck(1).timer.runNanos, + lx.engine.getDeck(1).getFaderTransition().timer.blendNanos}) { + float amt = val / (float) lx.timer.drawNanos; + fill(lx.hsb(hv % 360, 100, 80)); + rect(xp, y, amt * tw, h-1); + hv += 140; + xp += amt * tw; + } } void drawSimulation(color[] simulationColors) { @@@ -528,6 -601,11 +601,11 @@@ void keyPressed() p.toggle(); } break; + case 'q': + if (!midiEngine.isQwertyEnabled()) { + diagnosticsOn = !diagnosticsOn; + } + break; case 's': if (!midiEngine.isQwertyEnabled()) { simulationOn = !simulationOn;