From fddfba6cfb7006ba77bbe5064922698a709a181b Mon Sep 17 00:00:00 2001 From: njanssen Date: Thu, 24 Sep 2020 21:39:43 +0200 Subject: Added VSCode launch config for debugging the main and renderer process --- .vscode/launch.json | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..0d56ffe --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,35 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Debug Main Process", + "type": "node", + "request": "launch", + "cwd": "${workspaceFolder}/desktop", + "runtimeExecutable": "${workspaceFolder}/desktop/node_modules/.bin/electron", + "windows": { + "runtimeExecutable": "${workspaceFolder}/desktop/node_modules/.bin/electron.cmd" + }, + "args": ["."], + "outputCapture": "std", + "sourceMaps": true + }, + { + "name": "Debug Renderer Process", + "type": "chrome", + "request": "launch", + "runtimeExecutable": "${workspaceRoot}/desktop/node_modules/.bin/electron", + "windows": { + "runtimeExecutable": "${workspaceRoot}/desktop/node_modules/.bin/electron.cmd" + }, + "runtimeArgs": [ + "${workspaceRoot}/desktop/main.js", + "--remote-debugging-port=9222" + ], + "webRoot": "${workspaceRoot}/desktop/" + } + ] +} -- cgit v1.2.3 From dea3c8e325a4262a3141b8c56dac346a041712b6 Mon Sep 17 00:00:00 2001 From: njanssen Date: Thu, 24 Sep 2020 21:44:26 +0200 Subject: Calling selectInput function after manually switching to next MIDI input to correctly refresh MIDI message handler when no MIDI input was selected at startup --- desktop/sources/scripts/core/io/midi.js | 1 + 1 file changed, 1 insertion(+) diff --git a/desktop/sources/scripts/core/io/midi.js b/desktop/sources/scripts/core/io/midi.js index d5fb1d7..a0574dd 100644 --- a/desktop/sources/scripts/core/io/midi.js +++ b/desktop/sources/scripts/core/io/midi.js @@ -177,6 +177,7 @@ function Midi (client) { this.selectNextInput = () => { this.inputIndex = this.inputIndex < this.inputs.length ? this.inputIndex + 1 : 0 + this.selectInput(this.inputIndex) client.update() } -- cgit v1.2.3 From 6fc79035f4440be8b218a0ff91c3e6848a478dc4 Mon Sep 17 00:00:00 2001 From: njanssen Date: Thu, 24 Sep 2020 22:31:07 +0200 Subject: Set input index to -1 (no input device) instead of wrapping to 0 when we've reached the end of the `Midi.inputs` array. Now relying on `midi.selectInput` to do all the work, including setting `Midi.inputIndex` - this make sure an existing MIDI message handler is removed from the previous input device before we switch to the next one (or no input device in case of index -1) --- desktop/sources/scripts/core/io/midi.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/desktop/sources/scripts/core/io/midi.js b/desktop/sources/scripts/core/io/midi.js index a0574dd..0cdb100 100644 --- a/desktop/sources/scripts/core/io/midi.js +++ b/desktop/sources/scripts/core/io/midi.js @@ -176,8 +176,8 @@ function Midi (client) { } this.selectNextInput = () => { - this.inputIndex = this.inputIndex < this.inputs.length ? this.inputIndex + 1 : 0 - this.selectInput(this.inputIndex) + const id = this.inputIndex < this.inputs.length-1 ? this.inputIndex + 1 : -1 + this.selectInput(id) client.update() } -- cgit v1.2.3 From 91aec9177dbc75df174886b7d171130bf6f792f6 Mon Sep 17 00:00:00 2001 From: njanssen Date: Thu, 24 Sep 2020 22:32:44 +0200 Subject: Removed vscode configuration --- .vscode/launch.json | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 0d56ffe..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Debug Main Process", - "type": "node", - "request": "launch", - "cwd": "${workspaceFolder}/desktop", - "runtimeExecutable": "${workspaceFolder}/desktop/node_modules/.bin/electron", - "windows": { - "runtimeExecutable": "${workspaceFolder}/desktop/node_modules/.bin/electron.cmd" - }, - "args": ["."], - "outputCapture": "std", - "sourceMaps": true - }, - { - "name": "Debug Renderer Process", - "type": "chrome", - "request": "launch", - "runtimeExecutable": "${workspaceRoot}/desktop/node_modules/.bin/electron", - "windows": { - "runtimeExecutable": "${workspaceRoot}/desktop/node_modules/.bin/electron.cmd" - }, - "runtimeArgs": [ - "${workspaceRoot}/desktop/main.js", - "--remote-debugging-port=9222" - ], - "webRoot": "${workspaceRoot}/desktop/" - } - ] -} -- cgit v1.2.3 From 47e7107740f9fd4e58deefea309c45ade1034579 Mon Sep 17 00:00:00 2001 From: njanssen Date: Thu, 24 Sep 2020 22:42:36 +0200 Subject: Fixed code style :) --- desktop/sources/scripts/core/io/midi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop/sources/scripts/core/io/midi.js b/desktop/sources/scripts/core/io/midi.js index 0cdb100..285cebd 100644 --- a/desktop/sources/scripts/core/io/midi.js +++ b/desktop/sources/scripts/core/io/midi.js @@ -176,7 +176,7 @@ function Midi (client) { } this.selectNextInput = () => { - const id = this.inputIndex < this.inputs.length-1 ? this.inputIndex + 1 : -1 + const id = this.inputIndex < this.inputs.length - 1 ? this.inputIndex + 1 : -1 this.selectInput(id) client.update() } -- cgit v1.2.3 From a0f12faee513866c22c04b867ef716df48904223 Mon Sep 17 00:00:00 2001 From: njanssen Date: Fri, 25 Sep 2020 10:46:16 +0200 Subject: Allow Midi.play and Midi.stop to update `Midi.isPaused` when running in Puppeteering mode (thanks @unthingable!) --- desktop/sources/scripts/clock.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/desktop/sources/scripts/clock.js b/desktop/sources/scripts/clock.js index 1739dd0..a170e2c 100644 --- a/desktop/sources/scripts/clock.js +++ b/desktop/sources/scripts/clock.js @@ -59,8 +59,8 @@ function Clock (client) { this.play = function (msg = false) { console.log('Clock', 'Play', msg) if (this.isPaused === false) { return } - if (this.isPuppet === true) { console.warn('Clock', 'External Midi control'); return } this.isPaused = false + if (this.isPuppet === true) { console.warn('Clock', 'External Midi control'); return } if (msg === true) { client.io.midi.sendClockStart() } this.setSpeed(this.speed.target, this.speed.target, true) } @@ -68,8 +68,8 @@ function Clock (client) { this.stop = function (msg = false) { console.log('Clock', 'Stop') if (this.isPaused === true) { return } - if (this.isPuppet === true) { console.warn('Clock', 'External Midi control'); return } this.isPaused = true + if (this.isPuppet === true) { console.warn('Clock', 'External Midi control'); return } if (msg === true || client.io.midi.isClock) { client.io.midi.sendClockStop() } client.io.midi.allNotesOff() this.clearTimer() -- cgit v1.2.3 From e06cd58c3509b01a8eb9814ba986a54120d7b876 Mon Sep 17 00:00:00 2001 From: unthingable Date: Mon, 28 Sep 2020 10:48:08 +0200 Subject: MIDI clock slave mode: fix timing and note-off behavior - play() will reset both frame and pulse counts to 0, for alingment - stop() will silence - tap() will update immediately upon play(), not on the next frame --- desktop/sources/scripts/clock.js | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/desktop/sources/scripts/clock.js b/desktop/sources/scripts/clock.js index a170e2c..a30c766 100644 --- a/desktop/sources/scripts/clock.js +++ b/desktop/sources/scripts/clock.js @@ -60,19 +60,27 @@ function Clock (client) { console.log('Clock', 'Play', msg) if (this.isPaused === false) { return } this.isPaused = false - if (this.isPuppet === true) { console.warn('Clock', 'External Midi control'); return } - if (msg === true) { client.io.midi.sendClockStart() } - this.setSpeed(this.speed.target, this.speed.target, true) + if (this.isPuppet === true) { + console.warn('Clock', 'External Midi control') + pulse.count = 0 // works in conjunction with `tap` advancing on 0 + this.setFrame(0) // make sure frame aligns with pulse count for an accurate beat + } else { + if (msg === true) { client.io.midi.sendClockStart() } + this.setSpeed(this.speed.target, this.speed.target, true) + } } this.stop = function (msg = false) { console.log('Clock', 'Stop') if (this.isPaused === true) { return } this.isPaused = true - if (this.isPuppet === true) { console.warn('Clock', 'External Midi control'); return } - if (msg === true || client.io.midi.isClock) { client.io.midi.sendClockStop() } + if (this.isPuppet === true) { + console.warn('Clock', 'External Midi control') + } else { + if (msg === true || client.io.midi.isClock) { client.io.midi.sendClockStop() } + this.clearTimer() + } client.io.midi.allNotesOff() - this.clearTimer() client.io.midi.silence() } @@ -92,11 +100,8 @@ function Clock (client) { }, 2000) } if (this.isPaused) { return } - pulse.count = pulse.count + 1 - if (pulse.count % 6 === 0) { - client.run() - pulse.count = 0 - } + if (pulse.count == 0) { client.run() } + pulse.count = (pulse.count + 1) % 6 } this.untap = function () { -- cgit v1.2.3 From 39f116833d83140da09fa61b1661917a29e92683 Mon Sep 17 00:00:00 2001 From: unthingable Date: Tue, 29 Sep 2020 00:29:27 +0200 Subject: stay synced to MIDI clock while paused --- desktop/sources/scripts/clock.js | 39 +++++++++++++++++++++++---------- desktop/sources/scripts/core/io/midi.js | 2 +- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/desktop/sources/scripts/clock.js b/desktop/sources/scripts/clock.js index a30c766..1cc5efa 100644 --- a/desktop/sources/scripts/clock.js +++ b/desktop/sources/scripts/clock.js @@ -56,14 +56,17 @@ function Clock (client) { client.update() } - this.play = function (msg = false) { - console.log('Clock', 'Play', msg) + this.play = function (msg = false, force = false) { + console.log('Clock', 'Play', msg, force) if (this.isPaused === false) { return } this.isPaused = false - if (this.isPuppet === true) { + if (this.isPuppet === true) { console.warn('Clock', 'External Midi control') - pulse.count = 0 // works in conjunction with `tap` advancing on 0 - this.setFrame(0) // make sure frame aligns with pulse count for an accurate beat + if (!pulse.frame || force) { // no frames counted while paused or restard demanded (via MIDI clock PLAY) + this.setFrame(0) // make sure frame aligns with pulse count for an accurate beat + pulse.frame = 0 + pulse.count = 5 // by MIDI standard next pulse is the beat + } } else { if (msg === true) { client.io.midi.sendClockStart() } this.setSpeed(this.speed.target, this.speed.target, true) @@ -74,7 +77,7 @@ function Clock (client) { console.log('Clock', 'Stop') if (this.isPaused === true) { return } this.isPaused = true - if (this.isPuppet === true) { + if (this.isPuppet === true) { console.warn('Clock', 'External Midi control') } else { if (msg === true || client.io.midi.isClock) { client.io.midi.sendClockStop() } @@ -86,9 +89,15 @@ function Clock (client) { // External Clock - const pulse = { count: 0, last: null, timer: null } + const pulse = { + count: 0, + last: null, + timer: null, + frame: 0 // paused frame counter + } this.tap = function () { + pulse.count = (pulse.count + 1) % 6 pulse.last = performance.now() if (!this.isPuppet) { console.log('Clock', 'Puppeteering starts..') @@ -98,17 +107,25 @@ function Clock (client) { if (performance.now() - pulse.last < 2000) { return } this.untap() }, 2000) + } else { + if (pulse.count == 0) { + if (this.isPaused) { pulse.frame++ } + else { + if (pulse.frame > 0) { + this.setFrame(client.orca.f + pulse.frame) + pulse.frame = 0 + } + client.run() + } + } } - if (this.isPaused) { return } - if (pulse.count == 0) { client.run() } - pulse.count = (pulse.count + 1) % 6 } this.untap = function () { console.log('Clock', 'Puppeteering stops..') clearInterval(pulse.timer) this.isPuppet = false - pulse.count = 1 + pulse.frame = 0 pulse.last = null this.setTimer(this.speed.value) } diff --git a/desktop/sources/scripts/core/io/midi.js b/desktop/sources/scripts/core/io/midi.js index 285cebd..7f4875a 100644 --- a/desktop/sources/scripts/core/io/midi.js +++ b/desktop/sources/scripts/core/io/midi.js @@ -129,7 +129,7 @@ function Midi (client) { break case 0xFA: console.log('MIDI', 'Start Received') - client.clock.play() + client.clock.play(false, true) break case 0xFB: console.log('MIDI', 'Continue Received') -- cgit v1.2.3 From 6cce494cd0a5cd1e69cf266deb6d51c3ddb3ddf3 Mon Sep 17 00:00:00 2001 From: unthingable Date: Tue, 29 Sep 2020 00:46:02 +0200 Subject: re-sync on MIDI clock START while playing --- desktop/sources/scripts/clock.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/desktop/sources/scripts/clock.js b/desktop/sources/scripts/clock.js index 1cc5efa..3a3e1e1 100644 --- a/desktop/sources/scripts/clock.js +++ b/desktop/sources/scripts/clock.js @@ -58,11 +58,11 @@ function Clock (client) { this.play = function (msg = false, force = false) { console.log('Clock', 'Play', msg, force) - if (this.isPaused === false) { return } + if (this.isPaused === false && !force) { return } this.isPaused = false if (this.isPuppet === true) { console.warn('Clock', 'External Midi control') - if (!pulse.frame || force) { // no frames counted while paused or restard demanded (via MIDI clock PLAY) + if (!pulse.frame || force) { // no frames counted while paused or restard demanded (via MIDI clock START) this.setFrame(0) // make sure frame aligns with pulse count for an accurate beat pulse.frame = 0 pulse.count = 5 // by MIDI standard next pulse is the beat -- cgit v1.2.3 From 227cd8d7758697761d06aac962f3d7047ab50e07 Mon Sep 17 00:00:00 2001 From: unthingable Date: Tue, 29 Sep 2020 01:32:28 +0200 Subject: minor cleanup --- desktop/sources/scripts/clock.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/desktop/sources/scripts/clock.js b/desktop/sources/scripts/clock.js index 3a3e1e1..d89a516 100644 --- a/desktop/sources/scripts/clock.js +++ b/desktop/sources/scripts/clock.js @@ -56,13 +56,13 @@ function Clock (client) { client.update() } - this.play = function (msg = false, force = false) { - console.log('Clock', 'Play', msg, force) - if (this.isPaused === false && !force) { return } + this.play = function (msg = false, midiStart = false) { + console.log('Clock', 'Play', msg, midiStart) + if (this.isPaused === false && !midiStart) { return } this.isPaused = false if (this.isPuppet === true) { console.warn('Clock', 'External Midi control') - if (!pulse.frame || force) { // no frames counted while paused or restard demanded (via MIDI clock START) + if (!pulse.frame || midiStart) { // no frames counted while paused (starting from no clock, unlikely) or triggered by MIDI clock START this.setFrame(0) // make sure frame aligns with pulse count for an accurate beat pulse.frame = 0 pulse.count = 5 // by MIDI standard next pulse is the beat -- cgit v1.2.3 From 38223158cc61c17e9f7e3b847d4b6f6d51872f65 Mon Sep 17 00:00:00 2001 From: unthingable Date: Tue, 29 Sep 2020 09:36:54 +0200 Subject: lost clock should not unpause Orca --- desktop/sources/scripts/clock.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/desktop/sources/scripts/clock.js b/desktop/sources/scripts/clock.js index d89a516..66a5448 100644 --- a/desktop/sources/scripts/clock.js +++ b/desktop/sources/scripts/clock.js @@ -127,7 +127,9 @@ function Clock (client) { this.isPuppet = false pulse.frame = 0 pulse.last = null - this.setTimer(this.speed.value) + if (!this.isPaused) { + this.setTimer(this.speed.value) + } } // Timer -- cgit v1.2.3 From 594241c2513564a72721acaea55685103ec31ee8 Mon Sep 17 00:00:00 2001 From: unthingable Date: Tue, 29 Sep 2020 10:08:29 +0200 Subject: minor fix, remove extraneous else --- desktop/sources/scripts/clock.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/desktop/sources/scripts/clock.js b/desktop/sources/scripts/clock.js index 66a5448..95086cf 100644 --- a/desktop/sources/scripts/clock.js +++ b/desktop/sources/scripts/clock.js @@ -107,16 +107,15 @@ function Clock (client) { if (performance.now() - pulse.last < 2000) { return } this.untap() }, 2000) - } else { - if (pulse.count == 0) { - if (this.isPaused) { pulse.frame++ } - else { - if (pulse.frame > 0) { - this.setFrame(client.orca.f + pulse.frame) - pulse.frame = 0 - } - client.run() + } + if (pulse.count == 0) { + if (this.isPaused) { pulse.frame++ } + else { + if (pulse.frame > 0) { + this.setFrame(client.orca.f + pulse.frame) + pulse.frame = 0 } + client.run() } } } -- cgit v1.2.3