From 9692dc7b2916817381bae28bf81abc50ef6d8bfa Mon Sep 17 00:00:00 2001 From: Mark Slee Date: Thu, 19 Sep 2013 18:48:44 -0700 Subject: [PATCH] Add midi logging toggle --- _Internals.pde | 21 ++++++++++++++------- _UIFramework.pde | 42 +++++++++++++++++++++++++++++++++++------- _UIImplementation.pde | 10 ++++++++-- 3 files changed, 57 insertions(+), 16 deletions(-) diff --git a/_Internals.pde b/_Internals.pde index e57685d..044d650 100644 --- a/_Internals.pde +++ b/_Internals.pde @@ -141,8 +141,8 @@ void setup() { new UISpeed(4, 624, 140, 50), new UIPatternDeck(lx.engine.getDeck(1), "PATTERN B", width-144, 4, 140, 324), - uiMidi = new UIMidi(midiListeners, width-144, 332, 140, 136), - new UIOutput(width-144, 472, 140, 106), + uiMidi = new UIMidi(midiListeners, width-144, 332, 140, 160), + new UIOutput(width-144, 498, 140, 106), uiCrossfader = new UICrossfader(width/2-90, height-90, 180, 86), @@ -270,14 +270,18 @@ public class MidiListener extends AbstractScrollItem { if (!enabled) { return; } - println("PC: " + pc.toString()); + if (uiMidi.logMidi()) { + println(getLabel() + " :: Program Change :: " + pc.getNumber()); + } } void controllerChangeReceived(rwmidi.Controller cc) { if (!enabled) { return; } - println("CC: " + cc.toString()); + if (uiMidi.logMidi()) { + println(getLabel() + " :: Controller :: " + cc.getCC() + ":" + cc.getValue()); + } getFocusedPattern().controllerChangeReceived(cc); } @@ -285,16 +289,19 @@ public class MidiListener extends AbstractScrollItem { if (!enabled) { return; } - println("Note On: " + note.toString()); + if (uiMidi.logMidi()) { + println(getLabel() + " :: Note On :: " + note.getChannel() + ":" + note.getPitch() + ":" + note.getVelocity()); + } getFocusedPattern().noteOnReceived(note); - } void noteOffReceived(Note note) { if (!enabled) { return; } - println("Note Off: " + note.toString()); + if (uiMidi.logMidi()) { + println(getLabel() + " :: Note Off :: " + note.getChannel() + ":" + note.getPitch() + ":" + note.getVelocity()); + } getFocusedPattern().noteOffReceived(note); } diff --git a/_UIFramework.pde b/_UIFramework.pde index aff72fe..2b3d047 100644 --- a/_UIFramework.pde +++ b/_UIFramework.pde @@ -314,15 +314,39 @@ public class UILabel extends UIObject { } } +public class UICheckbox extends UIButton { + + private boolean firstDraw = true; + + public UICheckbox(float x, float y, float w, float h) { + super(x, y, w, h); + setMomentary(false); + } + + public void onDraw(PGraphics pg) { + pg.stroke(borderColor); + pg.fill(active ? activeColor : inactiveColor); + pg.rect(0, 0, h, h); + if (firstDraw) { + pg.fill(labelColor); + pg.textFont(defaultItemFont); + pg.textAlign(LEFT, CENTER); + pg.text(label, h + 4, h/2); + firstDraw = false; + } + } + +} + public class UIButton extends UIObject { - private boolean active = false; - private boolean isMomentary = false; - private color borderColor = #666666; - private color inactiveColor = #222222; - private color activeColor = #669966; - private color labelColor = #999999; - private String label = ""; + protected boolean active = false; + protected boolean isMomentary = false; + protected color borderColor = #666666; + protected color inactiveColor = #222222; + protected color activeColor = #669966; + protected color labelColor = #999999; + protected String label = ""; public UIButton(float x, float y, float w, float h) { super(x, y, w, h); @@ -359,6 +383,10 @@ public class UIButton extends UIObject { } } + public boolean isActive() { + return active; + } + public UIButton setActive(boolean active) { this.active = active; onToggle(active); diff --git a/_UIImplementation.pde b/_UIImplementation.pde index 226c68a..ae61d30 100644 --- a/_UIImplementation.pde +++ b/_UIImplementation.pde @@ -480,7 +480,8 @@ class UISpeed extends UIWindow { class UIMidi extends UIWindow { - final private UIToggleSet deckMode; + private final UIToggleSet deckMode; + private final UIButton logMode; UIMidi(List midiListeners, float x, float y, float w, float h) { super("MIDI", x, y, w, h); @@ -490,7 +491,12 @@ class UIMidi extends UIWindow { scrollItems.add(ml); } new UIScrollList(1, titleHeight, w-2, 80).setItems(scrollItems).addToContainer(this); - (deckMode = new UIToggleSet(4, 110, w-9, 20)).setOptions(new String[] { "A", "B" }).addToContainer(this); + (deckMode = new UIToggleSet(4, 110, 90, 20)).setOptions(new String[] { "A", "B" }).addToContainer(this); + (logMode = new UIButton(98, 110, w-103, 20)).setLabel("LOG").addToContainer(this); + } + + public boolean logMidi() { + return logMode.isActive(); } public Engine.Deck getFocusedDeck() { -- 2.34.1