Skip to content

Commit 49d57f3

Browse files
committed
added "app mode"; yet not helpful due to missing API zooming/transport features
1 parent 2623e42 commit 49d57f3

File tree

1 file changed

+46
-5
lines changed

1 file changed

+46
-5
lines changed

src/CMD-DC-1.control.js

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ lep.DC1 = function() {
3838
BANK_MODE: NOTE.FIRST_TOP_BUTTON + 4,
3939
PRESET_MODE: NOTE.FIRST_TOP_BUTTON + 5,
4040
SNAPSHOT_MODE: NOTE.FIRST_TOP_BUTTON + 6,
41+
APP_MODE: NOTE.FIRST_TOP_BUTTON + 1,
4142
SHIFT: NOTE.FIRST_TOP_BUTTON + 7
4243
},
4344
/**
@@ -54,13 +55,17 @@ lep.DC1 = function() {
5455
resetPresetOnBankChange: true,
5556
midiChannelForProgramChange: 0
5657
},
58+
application = host.createApplication(),
5759
isShiftButtonPressed = false,
5860
eventDispatcher = lep.MidiEventDispatcher.getInstance(),
5961
noteInput = eventDispatcher.createNoteInput('DC-1', 0, true),
6062
pushEncoderTarget = ko.observable(),
63+
isPushEncoderPressed = false,
6164
savedSnapshots = ko.observableArray(),
6265
currentSnapshot = ko.observable(0).extend({notify: 'always'}),
6366
lastClickedSnapshotIndex = 0,
67+
appModeButton,
68+
transport = host.createTransport(),
6469
currentBank = ko.computed({
6570
read: ko.computed(function() {
6671
return currentSnapshot() >> 8;
@@ -88,6 +93,9 @@ lep.DC1 = function() {
8893
isSnapshotMode = ko.computed(function() {
8994
return (pushEncoderTarget() === savedSnapshots);
9095
}),
96+
isAppMode = ko.computed(function() {
97+
return (pushEncoderTarget() === application);
98+
}),
9199

92100
displayedBankPage = ko.observable(0),
93101
computedBankPage = ko.computed(function() {
@@ -283,6 +291,19 @@ lep.DC1 = function() {
283291
})
284292
});
285293

294+
appModeButton = new lep.Button({
295+
name: 'AppModeButton',
296+
clickNote: NOTE_ACTION.APP_MODE,
297+
midiChannel: MIDI_CHANNEL,
298+
valueToAttach: new lep.KnockoutSyncedValue({
299+
name: 'AppModeValue',
300+
ownValue: application,
301+
refObservable: pushEncoderTarget,
302+
restoreRefAfterLongClick: true,
303+
velocityValueOn: COLOR.BLUE,
304+
velocityValueOff: COLOR.ORANGE
305+
})
306+
});
286307

287308
eventDispatcher.onNote(NOTE_ACTION.SHIFT, function(note, value, channel) {
288309
isShiftButtonPressed = !!value;
@@ -321,11 +342,17 @@ lep.DC1 = function() {
321342

322343
function initPushEncoder() {
323344
// 'clicking' the push encoder resets the bank and/or preset..
324-
eventDispatcher.onNotePressed(NOTE.PUSH_ENCODER_CLICK, function(note, value, channel) {
325-
if (isBankMode()) {
326-
currentBank(0);
327-
} else if (isPresetMode()) {
328-
currentPreset(0);
345+
eventDispatcher.onNote(NOTE.PUSH_ENCODER_CLICK, function(note, value, channel) {
346+
isPushEncoderPressed = !!value;
347+
348+
if (isPushEncoderPressed) {
349+
if (isBankMode()) {
350+
currentBank(0);
351+
} else if (isPresetMode()) {
352+
currentPreset(0);
353+
} else if (isAppMode()) {
354+
application.zoomToFit();
355+
}
329356
}
330357
});
331358

@@ -339,6 +366,20 @@ lep.DC1 = function() {
339366
targetObservable(newBankOrPreset);
340367
} else if (isSnapshotMode() && diff) {
341368
loadNextOrPrevSnapshot(diff);
369+
} else if (isAppMode()) {
370+
if (diff < 0) {
371+
if (appModeButton.isClicked) {
372+
application.zoomOut();
373+
} else {
374+
transport.incPosition(-1, true);
375+
}
376+
} else if (diff > 0) {
377+
if (appModeButton.isClicked) {
378+
application.zoomIn();
379+
} else {
380+
transport.incPosition(1, true);
381+
}
382+
}
342383
}
343384
});
344385

0 commit comments

Comments
 (0)