addParameter(hueParameter);
}
- void run(int deltaMs) {
+ void run(double deltaMs) {
boolean d = direction.getValuef() > 5.0;
for (Point p : model.points) {
colors[p.index] = color((lx.getBaseHuef() + random(hueParameter.getValuef() * 360))%360, random(saturationParameter.getValuef() * 100), random(brightParameter.getValuef() * 100));
img.loadPixels();
}
- void run(int deltaMs) {
+ void run(double deltaMs) {
for (Point p : model.points) {
color c = img.get((int)((p.x / model.xMax) * img.width), img.height - (int)((p.y / model.yMax) * img.height));
colors[p.index] = color(hue(c) + colorMod.getValuef()%360, saturation(c), brightness(c) - ((p.fz - brightMod.getValuef())/p.fz));
}
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
angle += deltaMs * 0.007;
rad += deltaMs * .025 * direction;
float x = model.xMax / 2 + cos(angle) * rad;
return avg;
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
fft.forward(lx.audioInput().mix);
float zeroDBReference = pow(10, 100*(1-level.getValuef())/20.);
float decibelRange = 12 + range.getValuef() * 60;
println("towers "+towerSize);
}
- void run(int deltaMs)
+ void run(double deltaMs)
{
clearALL();
Tower t;
println("towers "+towerrange);
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
if(counter % 10 ==0)
getGraphicByName("myOtherColors").position=100;
}
int counter=0;
- public void run(int deltaMs)
+ public void run(double deltaMs)
{
clearALL();
super.run(deltaMs);
}
int counter=0;
float count=0;
- public void run(int deltaMs)
+ public void run(double deltaMs)
{
clearALL();
super.run(deltaMs);
balls[ballnum].y = msg.get(1).floatValue();
}
- void run(int deltaMs){
+ void run(double deltaMs){
for(Point p: model.points){ colors[p.index]=0; }
for(int i=1; i<balls.length; i++){
if(millis() - balls[i].lastSeen < 1000) {
pret = new PImage(8, 128, ARGB);
ss = new ScreenShot();
}
- void run(int deltaMs){
+ void run(double deltaMs){
int x=(1366/2)+516;
int y=768-516;
int w=8;
while (lx.tempo.bpm() > 40) lx.tempo.setBpm(lx.tempo.bpm()/2);
UpdateLights();
}
- void StartRun(int deltaMs) { }
+ void StartRun(double deltaMs) { }
color CalcPoint(xyz p) { return color(0,0,0); }
float CalcCone (xyz v1, xyz v2, xyz c) {
return degrees( acos ( v1.minus(c).dot(v2.minus(c)) / (sqrt(v1.minus(c).dot(v1.minus(c))) * sqrt(v2.minus(c).dot(v2.minus(c))) ) ));
uiDebugText.setText(DanTextLine1, DanTextLine2);
}
- void run(int deltaMs) {
+ void run(double deltaMs) {
NoiseMove += deltaMs;
xdMax = model.xMax;
ydMax = model.yMax;
cNew = color( (hue(cNew) + modhue + zSpinHue - noizhue) % 360,
saturation(cNew) + 100*s_Saturate(),
- 100 * (s_Trails()==0 ? b : max(b, brightness(cOld)/100. - (1-s_Trails()) * deltaMs/200.))
+ 100 * (s_Trails()==0 ? b : max(b, (float) (brightness(cOld)/100. - (1-s_Trails()) * deltaMs/200.)))
* (s_Dim ()==0 ? 1 : 1-s_Dim())
);
return displayList.get(name);
}
- public void run(int deltaMs)
+ public void run(double deltaMs)
{
drawToPointList();
}
float a = 0, b = 0, g = 0;
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
if (DEBUG_MANUAL_ABG) {
a = aP.getValuef() * (2 * PI);
return f > 0 ? 1 : 0;
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
float a = (millis() / 1000.f) % (2 * PI);
float b = (millis() / 1200.f) % (2 * PI);
float g = (millis() / 1600.f) % (2 * PI);
int beat = 0;
float prevRamp = 0;
- void run(int deltaMs) {
+ void run(double deltaMs) {
// Sync to the beat
float ramp = (float)lx.tempo.ramp();
int beat = 0;
float prevRamp = 0;
- void run(int deltaMs) {
+ void run(double deltaMs) {
// Sync to the beat
float ramp = (float)lx.tempo.ramp();
}
}
- void run(int deltaMs) {
+ void run(double deltaMs) {
angle += deltaMs * 0.0007;
float sVal1 = model.strips.size() * (0.5 + 0.5*sin(angle));
float sVal2 = model.strips.size() * (0.5 + 0.5*cos(angle));
}
}
- void run(int deltaMs) {
+ void run(double deltaMs) {
float s = 0;
for (Strip strip : model.strips ) {
int i = 0;
colors[p.index] = color(
(lx.getBaseHuef() + 0.3 * abs(p.fx - hOffX.getValuef())) % 360,
constrain(80 + 40 * fV, 0, 100),
- constrain(100 - (30 - fV * falloff.getValuef()) * modDist(i + (s*63)%61, (int) (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;
}
}
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
eq.run(deltaMs);
float bassLevel = eq.getAverageLevel(0, 5);
}
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
eq.run(deltaMs);
float edgeConst = 2 + 30*edge.getValuef();
getEnvelope(note.getPitch()).setEndVal(0, getReleaseTime()).start();
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
int i = 0;
float huef = lx.getBaseHuef();
float levelf = level.getValuef();
zv = z.getValuef();
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
updateXYZVals();
float xlv = 100*xl.getValuef();
s.modulateDurationBy(r);
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
float hv = lx.getBaseHuef();
int si = 0;
for (Strip strip : model.strips) {
addModulator(c).trigger();
}
- void run(int deltaMs) {
+ void run(double deltaMs) {
float huev = h.getValuef();
float cv = c.getValuef();
float sv = s.getValuef();
addModulator(c = new SinLFO(-50, 50, 4000 + 1000*i * ((i % 2 == 0) ? 1 : -1))).trigger();
}
- void run(int deltaMs) {
+ void run(double deltaMs) {
av = a.getValuef();
bv = b.getValuef();
cv = c.getValuef();
}
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
float huev = lx.getBaseHuef();
// This is super fucking bizarre. But if this is a for loop, the framerate
addModulator(d).trigger();
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
float hv = lx.getBaseHuef();
float av = a.getValuef();
float bv = b.getValuef();
int counter = 0;
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
eq.run(deltaMs);
int stepThresh = (int) (40 - 39*speed.getValuef());
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
// Access the core master hue via this method call
float hv = lx.getBaseHuef();
for (int i = 0; i < colors.length*5; i=i+27) {
return phase;
}
- void step(int deltaMs) {
+ void step(double deltaMs) {
// Rotate
if (rotationPeriod != 0) {
this.phase = (phase + ((float)deltaMs / (float)rotationPeriod) * TWO_PI);
return color((lx.getBaseHuef() + (360*(phase / TWO_PI)))%360, 80.f, b);
}
- void run(int deltaMs) {
+ void run(double deltaMs) {
boolean h1on = helix1On.getValue() > 0.5;
boolean h2on = helix2On.getValue() > 0.5;
boolean spokesOn = (float)basePairsOn.getValue() > 0.5;
super(glucose);
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
int h = 0;
for (Speaker speaker : model.speakers) {
for (Strip strip : speaker.strips) {
super(glucose);
}
- public void run(int deltaMs) {
+ public void run(double 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) {
super(glucose);
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
int[] strutIndices = {6, 5, 4, 3, 2, 1, 0, 7};
int h = 0;
for (int si : strutIndices) {
addModulator(d).trigger();
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
for (Strip s : model.strips) {
for (Point p : s.points) {
colors[p.index] = color(
super(glucose);
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
// Access the core master hue via this method call
float hv = lx.getBaseHuef();
for (int i = 0; i < colors.length; ++i) {
super(glucose);
addModulator(xPos).trigger();
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
float hv = lx.getBaseHuef();
for (Point p : model.points) {
// This is a common technique for modulating brightness.
super(glucose);
addModulator(yPos).trigger();
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
float hv = lx.getBaseHuef();
for (Point p : model.points) {
float bv = max(0, 100 - abs(p.fy - yPos.getValuef()));
super(glucose);
addModulator(zPos).trigger();
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
float hv = lx.getBaseHuef();
for (Point p : model.points) {
float bv = max(0, 100 - abs(p.fz - zPos.getValuef()));
addModulator(towerIndex).trigger();
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
int ti = 0;
for (Tower t : model.towers) {
for (Point p : t.points) {
addModulator(yPos).trigger();
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
// For the same reasons described above, it may logically feel to you that
// some of these operations are in reverse order. Again, just keep in mind that
// the car itself is what's moving, not the object
addModulator(index).start();
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
for (Cube c : model.cubes) {
int i = 0;
for (Point p : c.points) {
printInfo();
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
color off = color(0, 0, 0);
color c = off;
color r = #FF0000;
spheres[1].radius = 50;
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
// Access the core master hue via this method call
float hv = hueParameter.getValuef();
float lfoValue = lfo.getValuef();
}
// returns TRUE when this should die
- boolean age(int ms) {
- p.add(v, ms / 1000.0);
+ boolean age(double ms) {
+ p.add(v, (float) (ms / 1000.0));
return this.p.y < (0 - this.radius);
}
}
raindrops = new LinkedList<Raindrop>();
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
leftoverMs += deltaMs;
while (leftoverMs > msPerRaindrop) {
leftoverMs -= msPerRaindrop;
}
// returns TRUE if this should die
- boolean age(int ms) {
+ boolean age(double ms) {
if (!hasPeaked) {
- value = value + (ms / 1000.0f * ((attackParameter.getValuef() + 0.01) * 5));
+ value = value + (float) (ms / 1000.0f * ((attackParameter.getValuef() + 0.01) * 5));
if (value >= 1.0) {
value = 1.0;
hasPeaked = true;
}
return false;
} else {
- value = value - (ms / 1000.0f * ((decayParameter.getValuef() + 0.01) * 10));
+ value = value - (float) (ms / 1000.0f * ((decayParameter.getValuef() + 0.01) * 10));
return value <= 0;
}
}
flashes = new LinkedList<CubeFlash>();
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
leftoverMs += deltaMs;
float msPerFlash = 1000 / ((rateParameter.getValuef() + .01) * 100);
while (leftoverMs > msPerFlash) {
float prevRamp = 0;
float[] wobbleSpeeds = { 1.0/8, 1.0/4, 1.0/2, 1.0 };
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
float ramp = (float)lx.tempo.ramp();
if (ramp < prevRamp) {
beat = (beat + 1) % 32;
private float prevRamp = 0;
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
float ramp = lx.tempo.rampf();
float numBeats = (1 + ramp - prevRamp) % 1;
prevRamp = ramp;
// 1 -> 180
float hueSpread = (hueSpreadParameter.getValuef() - 0.5) * 360;
- float fadeAmount = (deltaMs / 1000.0) * pow(sharpnessParameter.getValuef() * 10, 1);
+ float fadeAmount = (float) (deltaMs / 1000.0) * pow(sharpnessParameter.getValuef() * 10, 1);
for (Pinwheel pw : pinwheels) {
pw.age(numBeats);
return m;
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
for (Point p : model.points) {
color c = colors[p.index];
colors[p.index] = color(hue(c), saturation(c), brightness(c) - 3);
}
}
- public void run(int deltaMs) {
+ public void run(double 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)
float br=min(100,sqrt(level)*15);
return color(level/1.7,100,br);
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
for (int x=10;x<xm-10;x++) {
if (x%50>45 || x%50<5) {
intensity[x][ym-1] = random(30,100);
}
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
float[] bright = new float[model.points.size()];
for (Strip strip : model.strips) {
for (int i=0;i<numOsc;i++) {
}
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
this.fft.forward(this.lx.audioInput().mix);
for (int i = 0; i < avgSize; ++i) {
float value = this.fft.getAvg(i);
col2.setValue(model.xMax);
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
int i=0;
for (Strip s : model.strips) {
i++;
}
}
- public void run(int deltaMs) {
+ public void run(double deltaMs) {
this.fft.forward(this.lx.audioInput().mix);
for (int i = 0; i < avgSize; ++i) {
float value = this.fft.getAvg(i);
LXPattern[] patterns;
MappingTool mappingTool;
PandaDriver[] pandaBoards;
+final List<MidiListener> midiListeners = new ArrayList<MidiListener>();
// Display configuration mode
boolean mappingMode = false;
boolean debugMode = false;
DebugUI debugUI;
+boolean uiOn = true;
+LXPattern restoreToPattern = null;
// Handles to UI objects
UIContext[] overlays;
// Camera variables
float eyeR, eyeA, eyeX, eyeY, eyeZ, midX, midY, midZ;
+/**
+ * Engine construction and initialization.
+ */
LXPattern[] _patterns(GLucose glucose) {
LXPattern[] patterns = patterns(glucose);
for (LXPattern p : patterns) {
return patterns;
}
+void logTime(String evt) {
+ int now = millis();
+ println(evt + ": " + (now - lastMillis) + "ms");
+ lastMillis = now;
+}
+
void setup() {
startMillis = lastMillis = millis();
overlays = new UIContext[] {
uiPatternA = new UIPatternDeck(lx.engine.getDeck(0), "PATTERN A", 4, 4, 140, 344),
uiCrossfader = new UICrossfader(4, 352, 140, 212),
+ new UIOutput(4, 568, 140, 106),
new UIPatternDeck(lx.engine.getDeck(1), "PATTERN B", width-144, 4, 140, 344),
new UIEffects(width-144, 352, 140, 144),
new UITempo(width-144, 498, 140, 50),
- new UIOutput(width-144, 552, 140, 106),
+ new UISpeed(width-144, 552, 140, 50),
uiDebugText = new UIDebugText(4, height-64, width-8, 44),
uiMapping = new UIMapping(mappingTool, 4, 4, 140, 344),
logTime("Built overlay UI");
// MIDI devices
+ midiListeners.add(new MidiListener().setEnabled(true));
for (MidiInputDevice d : RWMidi.getInputDevices()) {
- d.createInput(this);
+ midiListeners.add(new MidiListener(d));
}
SCMidiDevices.initializeStandardDevices(glucose);
logTime("Setup MIDI devices");
println("Hit the 'p' key to toggle Panda Board output");
}
-
-void controllerChangeReceived(rwmidi.Controller cc) {
- if (debugMode) {
+public class MidiListener {
+ private boolean enabled = false;
+ private final String name;
+
+ MidiListener(MidiInputDevice d) {
+ d.createInput(this);
+ name = d.getName();
+ }
+
+ MidiListener() {
+ registerKeyEvent(this);
+ name = "Keyboard";
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void keyEvent(KeyEvent e) {
+ if (e.getID() == KeyEvent.KEY_PRESSED) {
+ switch (e.getKeyChar()) {
+ case 'q':
+ noteOnReceived(new Note(60, 127));
+ break;
+ }
+ } else if (e.getID() == KeyEvent.KEY_RELEASED) {
+ switch (e.getKeyChar()) {
+ case 'q':
+ noteOffReceived(new Note(60, 0));
+ break;
+ }
+ }
+ }
+
+ public MidiListener setEnabled(boolean enabled) {
+ if (enabled != this.enabled) {
+ this.enabled = enabled;
+ // notify midi UI to update
+ }
+ return this;
+ }
+
+ void controllerChangeReceived(rwmidi.Controller cc) {
+ if (!enabled) {
+ return;
+ }
println("CC: " + cc.toString());
}
-}
-void noteOnReceived(Note note) {
- if (debugMode) {
+ void noteOnReceived(Note note) {
+ if (!enabled) {
+ return;
+ }
println("Note On: " + note.toString());
}
-}
-void noteOffReceived(Note note) {
- if (debugMode) {
+ void noteOffReceived(Note note) {
+ if (!enabled) {
+ return;
+ }
println("Note Off: " + note.toString());
}
-}
-void logTime(String evt) {
- int now = millis();
- println(evt + ": " + (now - lastMillis) + "ms");
- lastMillis = now;
}
+/**
+ * Core render loop and drawing functionality.
+ */
void draw() {
// Draws the simulation and the 2D UI overlay
background(40);
}
}
-boolean uiOn = true;
-LXPattern restoreToPattern = null;
-
+/**
+ * Top-level keyboard event handling
+ */
void keyPressed() {
if (mappingMode) {
mappingTool.keyPressed(uiMapping);
}
}
+/**
+ * Top-level mouse event handling
+ */
int mx, my;
void mousePressed() {
boolean debugged = false;
for (UIContext context : overlays) {
context.mouseReleased(mouseX, mouseY);
}
-
- // ui.mouseReleased();
}
void mouseWheel(int delta) {
}
private boolean editing = false;
+ private long lastClick = 0;
+ private float doubleClickMode = 0;
+ private float doubleClickX = 0;
protected void onMousePressed(float mx, float my) {
+ long now = millis();
float handleLeft = 4 + parameter.getValuef() * (w-8-handleWidth);
if (mx >= handleLeft && mx < handleLeft + handleWidth) {
editing = true;
+ } else {
+ if ((now - lastClick) < 300 && abs(mx - doubleClickX) < 3) {
+ parameter.setValue(doubleClickMode);
+ }
+ doubleClickX = mx;
+ if (mx < w*.25) {
+ doubleClickMode = 0;
+ } else if (mx > w*.75) {
+ doubleClickMode = 1;
+ } else {
+ doubleClickMode = 0.5;
+ }
}
+ lastClick = now;
}
protected void onMouseReleased(float mx, float my) {
}
}
+class UISpeed extends UIWindow {
+ UISpeed(float x, float y, float w, float h) {
+ super("SPEED", x, y, w, h);
+ new UIParameterSlider(4, titleHeight, w-10, 20)
+ .setParameter(new BasicParameter("SPEED", 0.5).addListener(new LXParameter.Listener() {
+ public void onParameterChanged(LXParameter parameter) {
+ lx.setSpeed(parameter.getValuef() * 2);
+ }
+ })).addToContainer(this);
+ }
+}
+
String className(Object p, String suffix) {
String s = p.getClass().getName();
int li;