aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorunthingable <[email protected]>2020-09-28 10:48:08 +0200
committerunthingable <[email protected]>2020-09-28 10:48:08 +0200
commite06cd58c3509b01a8eb9814ba986a54120d7b876 (patch)
tree4130b3611e5ef28b372b6b83f2a1cac95aefeb99
parenta0f12faee513866c22c04b867ef716df48904223 (diff)
downloadOrca-e06cd58c3509b01a8eb9814ba986a54120d7b876.tar.gz
Orca-e06cd58c3509b01a8eb9814ba986a54120d7b876.zip
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
-rw-r--r--desktop/sources/scripts/clock.js27
1 files 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 () {