From: Mark Slee Date: Sun, 26 May 2013 21:32:38 +0000 (-0700) Subject: Implement pattern knobs here X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=809f35189181488d1b0c7586b88c6fc2e910f0ab;p=SugarCubes.git Implement pattern knobs here --- diff --git a/_Internals.pde b/_Internals.pde index c93129f..05336ec 100644 --- a/_Internals.pde +++ b/_Internals.pde @@ -61,7 +61,7 @@ void setup() { logTime("Built overlay UI"); // MIDI devices - SCMidiDevices.initializeStandardDevices(glucose); + SCMidiDevices.initializeStandardDevices(glucose, ui.patternKnobs, ui.transitionKnobs, ui.effectKnobs); logTime("Setup MIDI devices"); println("Total setup: " + (millis() - startMillis) + "ms"); diff --git a/_Overlay.pde b/_Overlay.pde index dbf128b..3e661d8 100644 --- a/_Overlay.pde +++ b/_Overlay.pde @@ -41,14 +41,16 @@ class OverlayUI { private Method transitionStateMethod; private Method effectStateMethod; + private final int NUM_PATTERN_KNOBS = 8; private final int NUM_TRANSITION_KNOBS = 4; private final int NUM_EFFECT_KNOBS = 4; private int activeTransitionIndex = 0; private int activeEffectIndex = 0; - private final VirtualTransitionKnob[] transitionKnobs; - private final VirtualEffectKnob[] effectKnobs; + public final VirtualPatternKnob[] patternKnobs; + public final VirtualTransitionKnob[] transitionKnobs; + public final VirtualEffectKnob[] effectKnobs; OverlayUI() { leftPos = width - w; @@ -59,6 +61,11 @@ class OverlayUI { transitionNames = classNameArray(transitions, "Transition"); effectNames = classNameArray(effects, "Effect"); + patternKnobs = new VirtualPatternKnob[NUM_PATTERN_KNOBS]; + for (int i = 0; i < patternKnobs.length; ++i) { + patternKnobs[i] = new VirtualPatternKnob(i); + } + transitionKnobs = new VirtualTransitionKnob[NUM_TRANSITION_KNOBS]; for (int i = 0; i < transitionKnobs.length; ++i) { transitionKnobs[i] = new VirtualTransitionKnob(i); @@ -98,9 +105,9 @@ class OverlayUI { yPos += controlSpacing; firstPatternKnobY = yPos; int xPos = leftTextPos; - for (int i = 0; i < glucose.NUM_PATTERN_KNOBS/2; ++i) { - drawKnob(xPos, yPos, knobSize, glucose.patternKnobs[i]); - drawKnob(xPos, yPos + knobSize + knobSpacing + knobLabelHeight, knobSize, glucose.patternKnobs[glucose.NUM_PATTERN_KNOBS/2 + i]); + for (int i = 0; i < NUM_PATTERN_KNOBS/2; ++i) { + drawKnob(xPos, yPos, knobSize, patternKnobs[i]); + drawKnob(xPos, yPos + knobSize + knobSpacing + knobLabelHeight, knobSize, patternKnobs[NUM_PATTERN_KNOBS/2 + i]); xPos += knobSize + knobSpacing; } yPos += 2*(knobSize + knobLabelHeight) + knobSpacing; @@ -309,6 +316,22 @@ class OverlayUI { return s; } + class VirtualPatternKnob extends LXVirtualParameter { + private final int index; + + VirtualPatternKnob(int index) { + this.index = index; + } + + public LXParameter getRealParameter() { + List parameters = glucose.getPattern().getParameters(); + if (index < parameters.size()) { + return parameters.get(index); + } + return null; + } + } + class VirtualTransitionKnob extends LXVirtualParameter { private final int index; @@ -379,7 +402,7 @@ class OverlayUI { } else if ((mouseY >= firstPatternKnobY) && (mouseY < firstPatternKnobY + 2*(knobSize+knobLabelHeight) + knobSpacing)) { patternKnobIndex = (mouseX - leftTextPos) / (knobSize + knobSpacing); if (mouseY >= firstPatternKnobY + knobSize + knobLabelHeight + knobSpacing) { - patternKnobIndex += glucose.NUM_PATTERN_KNOBS / 2; + patternKnobIndex += NUM_PATTERN_KNOBS / 2; } } else if (mouseY > firstPatternY) { int patternIndex = (mouseY - firstPatternY) / lineHeight; @@ -393,8 +416,8 @@ class OverlayUI { public void mouseDragged() { int dy = lastY - mouseY; lastY = mouseY; - if (patternKnobIndex >= 0 && patternKnobIndex < glucose.NUM_PATTERN_KNOBS) { - LXParameter p = glucose.patternKnobs[patternKnobIndex]; + if (patternKnobIndex >= 0 && patternKnobIndex < NUM_PATTERN_KNOBS) { + LXParameter p = patternKnobs[patternKnobIndex]; p.setValue(constrain(p.getValuef() + dy*.01, 0, 1)); } else if (effectKnobIndex >= 0 && effectKnobIndex < NUM_EFFECT_KNOBS) { LXParameter p = effectKnobs[effectKnobIndex]; diff --git a/code/GLucose.jar b/code/GLucose.jar index 48c8de6..cc16b16 100644 Binary files a/code/GLucose.jar and b/code/GLucose.jar differ