From: Mark Slee Date: Wed, 6 Nov 2013 23:40:47 +0000 (-0800) Subject: Update to new GLucose/LX and make knobs show values on rotation X-Git-Url: https://git.piment-noir.org/?p=SugarCubes.git;a=commitdiff_plain;h=d12e46b60d13c73a9eb8182c66352f279895f2e0 Update to new GLucose/LX and make knobs show values on rotation --- diff --git a/Audio.pde b/Audio.pde index def7d0e..1b84957 100644 --- a/Audio.pde +++ b/Audio.pde @@ -4,7 +4,7 @@ */ public static class GraphicEQ { - private final HeronLX lx; + private final LX lx; public final BasicParameter level = new BasicParameter("LVL", 0.5); public final BasicParameter range = new BasicParameter("RNGE", 0.5); @@ -19,7 +19,7 @@ public static class GraphicEQ { public final static int DEFAULT_NUM_BANDS = 16; - public GraphicEQ(HeronLX lx) { + public GraphicEQ(LX lx) { this(lx, DEFAULT_NUM_BANDS); } @@ -27,7 +27,7 @@ public static class GraphicEQ { * Note that the number of bands is a suggestion. Due to the FFT implementation * the actual number may be slightly different. */ - public GraphicEQ(HeronLX lx, int num) { + public GraphicEQ(LX lx, int num) { this.lx = lx; fft = new FFT(lx.audioInput().bufferSize(), lx.audioInput().sampleRate()); fft.window(FFT.HAMMING); diff --git a/DanKaminsky.pde b/DanKaminsky.pde index 5364669..4021d07 100644 --- a/DanKaminsky.pde +++ b/DanKaminsky.pde @@ -79,7 +79,7 @@ class ObjectMuckerEffect extends SCEffect { ObjectMuckerEffect(GLucose glucose) { super(glucose); } - public void doApply(int[] colors){ + public void apply(int[] colors){ /*for(Strip s: model.strips){ for(int i=0; i 0) { float tRamp = (lx.tempo.rampf() % (1./pow(2,floor((1-fQuant) * 4)))); @@ -1502,7 +1502,7 @@ class BlurEffect extends SCEffect { env.setRangeFromHereTo(0, 1000).start(); } - public void doApply(int[] colors) { + public void apply(int[] colors) { float amt = env.getValuef() * amount.getValuef(); if (amt > 0) { amt = (1 - amt); diff --git a/_Internals.pde b/_Internals.pde index 61f6c7d..58187f1 100644 --- a/_Internals.pde +++ b/_Internals.pde @@ -4,7 +4,7 @@ * //\\ //\\ //\\ //\\ * ///\\\ ///\\\ ///\\\ ///\\\ * \\\/// \\\/// \\\/// \\\/// - * \\// \\// \\// \\// + * \\// \\// \\// \\//H * * EXPERTS ONLY!! EXPERTS ONLY!! * @@ -48,7 +48,7 @@ int startMillis, lastMillis; // Core engine variables GLucose glucose; -HeronLX lx; +LX lx; LXPattern[] patterns; Effects effects; MappingTool mappingTool; diff --git a/_UIFramework.pde b/_UIFramework.pde index ca74464..6d80ad6 100644 --- a/_UIFramework.pde +++ b/_UIFramework.pde @@ -538,6 +538,27 @@ public abstract class UIParameterControl extends UIObject implements LXParameter redraw(); } + protected float getNormalized() { + if (parameter != null) { + if (parameter instanceof BasicParameter) { + return ((BasicParameter)parameter).getNormalizedf(); + } + return parameter.getValuef(); + } + return 0; + } + + protected UIParameterControl setNormalized(float value) { + if (parameter != null) { + if (parameter instanceof BasicParameter) { + ((BasicParameter)parameter).setNormalized(value); + } else { + parameter.setValue(value); + } + } + return this; + } + public UIParameterControl setParameter(LXParameter parameter) { if (this.parameter != null) { if (this.parameter instanceof LXListenableParameter) { @@ -559,6 +580,7 @@ public class UIParameterKnob extends UIParameterControl { private int knobSize = 28; private final float knobIndent = .4; private final int knobLabelHeight = 14; + private boolean showValue = false; public UIParameterKnob(float x, float y) { this(x, y, 0, 0); @@ -570,7 +592,7 @@ public class UIParameterKnob extends UIParameterControl { } protected void onDraw(PGraphics pg) { - float knobValue = (parameter != null) ? parameter.getValuef() : 0; + float knobValue = getNormalized(); pg.ellipseMode(CENTER); pg.noStroke(); @@ -590,7 +612,12 @@ public class UIParameterKnob extends UIParameterControl { pg.fill(#333333); pg.ellipse(knobSize/2, knobSize/2, knobSize/2, knobSize/2); - String knobLabel = (parameter != null) ? parameter.getLabel() : null; + String knobLabel; + if (showValue) { + knobLabel = (parameter != null) ? ("" + parameter.getValue()) : null; + } else { + knobLabel = (parameter != null) ? parameter.getLabel() : null; + } if (knobLabel == null) { knobLabel = "-"; } else if (knobLabel.length() > 4) { @@ -614,13 +641,18 @@ public class UIParameterKnob extends UIParameterControl { } else { lastMousePress = now; } + showValue = true; + redraw(); + } + + public void onMouseReleased(float mx, float my) { + showValue = false; + redraw(); } public void onMouseDragged(float mx, float my, float dx, float dy) { - if (parameter != null) { - float value = constrain(parameter.getValuef() - dy / 100., 0, 1); - parameter.setValue(value); - } + float value = constrain(getNormalized() - dy / 100., 0, 1); + setNormalized(value); } } @@ -649,12 +681,12 @@ public class UIParameterSlider extends UIParameterControl { private float doubleClickX = 0; protected void onMousePressed(float mx, float my) { long now = millis(); - float handleLeft = 4 + parameter.getValuef() * (w-8-handleWidth); + float handleLeft = 4 + getNormalized() * (w-8-handleWidth); if (mx >= handleLeft && mx < handleLeft + handleWidth) { editing = true; } else { if ((now - lastClick) < DOUBLE_CLICK_THRESHOLD && abs(mx - doubleClickX) < 3) { - parameter.setValue(doubleClickMode); + setNormalized(doubleClickMode); } doubleClickX = mx; if (mx < w*.25) { @@ -674,7 +706,7 @@ public class UIParameterSlider extends UIParameterControl { protected void onMouseDragged(float mx, float my, float dx, float dy) { if (editing) { - parameter.setValue(constrain((mx - handleWidth/2. - 4) / (w-8-handleWidth), 0, 1)); + setNormalized(constrain((mx - handleWidth/2. - 4) / (w-8-handleWidth), 0, 1)); } } } diff --git a/code/GLucose.jar b/code/GLucose.jar index 358d323..0f0b20e 100755 Binary files a/code/GLucose.jar and b/code/GLucose.jar differ diff --git a/code/HeronLX.jar b/code/HeronLX.jar index 23d0fb8..e6c9335 100755 Binary files a/code/HeronLX.jar and b/code/HeronLX.jar differ