diff --git a/internals.md b/internals.md
index 5d60019..9e9a678 100644
--- a/internals.md
+++ b/internals.md
@@ -35,11 +35,10 @@ MIDI IN:
if SYSEX_PRESET:
resetExp
updateUI
- updateMeta
- showPreset
- setPresetClean
- add .sel if pc>0
- add .on if communication ok
+ updatePresetSelector
+ setPresetClean
+ add .sel if pc>0
+ add .on if communication ok
updateControls
if SYSEX_GLOBALS:
updateGlobalSettings
@@ -61,10 +60,10 @@ MIDI DEVICE:
connectInputDevice
disconnectInputPort
remove listeners
- showPreset
+ updatePresetSelector
connectInputPort
setMidiInputPort
- showPreset
+ updatePresetSelector
syncIfNoPreset
if preset === 0
requestPreset
@@ -84,11 +83,10 @@ MIDI DEVICE:
initFromBookmark
resetExp
updateUI
- updateMeta
- showPreset
- setPresetClean
- add .sel if pc>0
- add .on if communication ok
+ updatePresetSelector
+ setPresetClean
+ add .sel if pc>0
+ add .on if communication ok
updateControls
on disconnected:
@@ -96,8 +94,8 @@ MIDI DEVICE:
port is input:
disconnectInputPort
remove listeners
- showPreset
+ updatePresetSelector
port is output:
disconnectOutputPort
- showPreset
+ updatePresetSelector
updateSelectDeviceList
diff --git a/src/debug.js b/src/debug.js
index 8cb5d0e..def70f7 100644
--- a/src/debug.js
+++ b/src/debug.js
@@ -1,5 +1,5 @@
-export const TRACE = false;
+export const TRACE = true;
export function log() {
if (TRACE) console.log(...arguments);
diff --git a/src/index.html b/src/index.html
index 19a7274..4cf3398 100644
--- a/src/index.html
+++ b/src/index.html
@@ -374,7 +374,7 @@
toe up
- copy
+ copy
diff --git a/src/main.js b/src/main.js
index dd12550..c83b81c 100644
--- a/src/main.js
+++ b/src/main.js
@@ -19,7 +19,7 @@ import "./css/main.css";
import "./css/zoom.css";
import "./css/grid-default.css";
import "./css/grid-global-settings.css";
-import {setPresetDirty, showPreset} from "./ui_presets";
+import {setPresetDirty, updatePresetSelector} from "./ui_presets";
import * as Utils from "./utils";
import {initZoom} from "./ui_zoom";
@@ -96,7 +96,7 @@ function connectInputPort(input) {
log(`%cconnectInputPort: ${input.name} is now listening on channel ${preferences.midi_channel}`, "color: orange; font-weight: bold");
setCommunicationStatus(true);
- showPreset();
+ updatePresetSelector();
appendMessage(`Input ${input.name} connected on MIDI channel ${preferences.midi_channel}.`);
}
@@ -107,7 +107,7 @@ function disconnectInputPort() {
p.removeListener(); // remove all listeners for all channels
setMidiInputPort(null);
setCommunicationStatus(false);
- showPreset();
+ updatePresetSelector();
appendMessage(`Input disconnected.`);
}
}
@@ -160,7 +160,7 @@ function connectOutputPort(output) {
log("connectOutputPort");
setMidiOutputPort(output);
log(`%cconnectOutputPort: ${output.name} can now be used to send data on channel ${preferences.midi_channel}`, "color: orange; font-weight: bold");
- showPreset();
+ updatePresetSelector();
appendMessage(`Output ${output.name} connected on MIDI channel ${preferences.midi_channel}.`);
}
@@ -170,7 +170,7 @@ function disconnectOutputPort() {
log("disconnectOutputPort()");
setMidiOutputPort(null);
log("disconnectOutputPort: connectOutputPort: midi_output can not be used anymore");
- showPreset();
+ updatePresetSelector();
appendMessage(`Output disconnected.`);
}
}
diff --git a/src/midi_in.js b/src/midi_in.js
index cbfbc38..2261b6a 100644
--- a/src/midi_in.js
+++ b/src/midi_in.js
@@ -1,5 +1,5 @@
import {showMidiInActivity} from "./ui_midi_activity";
-import {showPreset} from "./ui_presets";
+import {updatePresetSelector} from "./ui_presets";
import {logIncomingMidiMessage} from "./ui_midi_window";
import {getLastSendTime} from "./midi_out";
import {updateModelAndUI, updateUI} from "./ui";
@@ -55,7 +55,7 @@ export function handlePC(msg) {
showMidiInActivity();
logIncomingMidiMessage("PC", [msg.value]);
MODEL.setPresetNumber(msg.value);
- showPreset();
+ updatePresetSelector();
}
/**
diff --git a/src/midi_out.js b/src/midi_out.js
index 0466ea4..c869698 100644
--- a/src/midi_out.js
+++ b/src/midi_out.js
@@ -143,7 +143,7 @@ export function fullUpdateDevice() {
log(`fullUpdateDevice done`);
fullUpdateRunning = false;
if (!silent && midi_output) {
- appendMessage("Current settings sent to Enzo.")
+ appendMessage("Current settings sent to the pedal.")
}
} else {
// log(`fullUpdateDevice: send CC ${i}`);
@@ -184,11 +184,11 @@ export function sendPC(pc) {
appendMessage(`Preset ${pc} selected.`);
if (!getMidiInputPort()) {
- appendMessage("Unable to receive the preset from Enzo.");
+ appendMessage("Unable to receive the preset from the pedal.");
}
} else {
- appendMessage(`Unable to send the PC command to Enzo.`);
+ appendMessage(`Unable to send the PC command to the pedal.`);
log(`(send program change ${pc})`);
}
diff --git a/src/ui.js b/src/ui.js
index 0be9132..4f4cc1d 100644
--- a/src/ui.js
+++ b/src/ui.js
@@ -1,5 +1,5 @@
import MODEL from "./model";
-import {showPreset, setPresetDirty, setupPresetSelectors} from "./ui_presets";
+import {updatePresetSelector, setPresetDirty, setupPresetSelectors} from "./ui_presets";
import {knobs, setupKnobs} from "./ui_knobs";
import {
setupMomentarySwitches,
@@ -51,7 +51,7 @@ export function handleUserAction(control_type, control_number, value) {
* @param value
* @param mappedValue
*/
-export function updateControl(control_type, control_number, value, mappedValue) { //TODO: check that control_number is always an int and not a string
+export function updateControl(control_type, control_number, value, mappedValue) {
//FIXME: no need for control_type
@@ -67,6 +67,7 @@ export function updateControl(control_type, control_number, value, mappedValue)
knobs[id].value = value; //TODO: doesn't the knob update its value itself?
} else {
+ //TODO: check that control_number is always an int and not a string
const num = parseInt(control_number, 10);
if (/*control_type === "cc" &&*/ num === 4) { //TODO: replace this hack with better code
@@ -94,7 +95,6 @@ export function updateControl(control_type, control_number, value, mappedValue)
} else if (c.is(".swm")) {
log(`updateControl(${control_type}, ${num}, ${value}) .swm`);
updateMomentaryStompswitch(`${id}-${mappedValue}`, mappedValue);
- // log(typeof mappedValue, mappedValue === 0);
// if (mappedValue !== 0) {
// log("will call updateMomentaryStompswitch in 200ms");
setTimeout(() => updateMomentaryStompswitch(`${id}-${mappedValue}`, 0), 200);
@@ -130,18 +130,11 @@ export function updateControls(onlyTwoValuesControls = false) {
if (TRACE) console.groupEnd();
} // updateControls()
-/**
- * Update the patch number and patch name displayed in the header.
- */
-function updateMeta() {
- showPreset();
-}
-
/**
* Update the UI from the MODEL controls values.
*/
export function updateUI() {
- updateMeta();
+ updatePresetSelector();
updateControls();
log("updateUI done");
}
@@ -243,7 +236,6 @@ export function setupUI(channelSelectionCallback, inputSelectionCallback, output
setupAppPreferences();
setupHelpPanel();
setupMenu();
- // setupExp();
setupSelects(channelSelectionCallback, inputSelectionCallback, outputSelectionCallback);
setupKeyboard();
diff --git a/src/ui_exp.js b/src/ui_exp.js
index d14a855..879ca6e 100644
--- a/src/ui_exp.js
+++ b/src/ui_exp.js
@@ -52,7 +52,7 @@ export function toggleExpEditMode() {
updateDevice("cc", MODEL.control_id.exp_pedal, 0);
showExpValues(false);
- appendMessage("You are now editing the normal values");
+ appendMessage("You are now editing the normal values", true);
} else {
@@ -65,7 +65,7 @@ export function toggleExpEditMode() {
updateDevice("cc", MODEL.control_id.exp_pedal, 127);
showExpValues(true);
- appendMessage("You are now editing the EXP (tow-down) values", true);
+ appendMessage("You are now editing the EXP (toe down) values", true);
}
}
diff --git a/src/ui_presets.js b/src/ui_presets.js
index 76b1166..f8852cc 100644
--- a/src/ui_presets.js
+++ b/src/ui_presets.js
@@ -12,6 +12,18 @@ import {getMidiInputPort} from "./midi_in";
The .dirty flag is cleared when we receive a preset (via sysex) or when we load a preset file.
*/
+/**
+ * Remove all flags and highlight color from the preset selectors.
+ */
+export function resetPresetSelectors() {
+ log("resetPresetSelectors()");
+ $(".preset-id").removeClass("dirty on sel");
+ dirty_cache = false;
+}
+
+/**
+ * Remove any dirty indicator from the preset selectors
+ */
export function setPresetClean() {
log("setPresetClean()");
$(".preset-id").removeClass("dirty");
@@ -20,6 +32,9 @@ export function setPresetClean() {
let dirty_cache = true; // setPresetDirty is called each time a control is modified. This variable is used to minimize the DOM changes.
+/**
+ * Show the dirty indicator on the current preset selector
+ */
export function setPresetDirty() {
if (!dirty_cache) {
log("setPresetDirty()");
@@ -29,13 +44,14 @@ export function setPresetDirty() {
}
}
-export function showPreset() {
- log("showPreset()");
+/**
+ * Update the preset selector to show the current pedal's preset.
+ * Highlight the preset selector if the communication is up with the pedal.
+ */
+export function updatePresetSelector() {
+ log("updatePresetSelector()");
- // const elems = $(".preset-id");
- // elems.removeClass("on sel dirty");
- // dirty_cache = false; // because we removed .dirty
- setPresetClean();
+ resetPresetSelectors();
const n = MODEL.getPresetNumber();
if (n) {
@@ -43,8 +59,6 @@ export function showPreset() {
e.addClass("sel");
if (getMidiInputPort() && getMidiOutputPort()) {
e.addClass("on");
- // } else {
- // elems.removeClass("on");
}
}
}
@@ -56,7 +70,7 @@ export function showPreset() {
export function presetSet(n) {
log(`presetSet(${n})`);
MODEL.setPresetNumber(n);
- showPreset();
+ updatePresetSelector();
sendPC(n);
}