aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDevine Lu Linvega <[email protected]>2019-04-17 13:16:38 +0900
committerDevine Lu Linvega <[email protected]>2019-04-17 13:16:38 +0900
commit72b74ac18debb62d65f551ba16f9c9feb4a864be (patch)
treee8a176669aeb033802f1e0024c97bee40f1819df
parent5570ab3ea4ac002a7d46011d040a606baa08f0fd (diff)
downloadOrca-72b74ac18debb62d65f551ba16f9c9feb4a864be.tar.gz
Orca-72b74ac18debb62d65f551ba16f9c9feb4a864be.zip
Reverted clock
-rw-r--r--desktop/core/io/midi.js4
-rw-r--r--desktop/sources/scripts/clock.js10
2 files changed, 7 insertions, 7 deletions
diff --git a/desktop/core/io/midi.js b/desktop/core/io/midi.js
index 86b2e2d..5e815c9 100644
--- a/desktop/core/io/midi.js
+++ b/desktop/core/io/midi.js
@@ -117,10 +117,8 @@ function Midi (terminal) {
switch (msg.data[0]) {
case 0xF8:
this.count = (this.count + 1) % 6
- if (this.count % 8 === 0) {
- terminal.clock.stop()
+ if (this.count % 4 === 0) {
terminal.clock.tap()
- terminal.run()
}
break
case 0xFA:
diff --git a/desktop/sources/scripts/clock.js b/desktop/sources/scripts/clock.js
index 41d44de..ae231ba 100644
--- a/desktop/sources/scripts/clock.js
+++ b/desktop/sources/scripts/clock.js
@@ -44,14 +44,14 @@ function Clock (terminal) {
}
this.play = function () {
- if (!this.isPaused) { return }
+ if (!this.isPaused) { console.warn('Already playing'); return }
console.log('Clock', 'Play')
this.isPaused = false
this.set(this.speed.target, this.speed.target, true)
}
this.stop = function () {
- if (this.isPaused) { return }
+ if (this.isPaused) { console.warn('Already stopped'); return }
console.log('Clock', 'Stop')
terminal.io.midi.silence()
this.isPaused = true
@@ -69,8 +69,10 @@ function Clock (terminal) {
}
if (this.intervals.length === 8) {
const sum = this.intervals.reduce((sum, interval) => { return sum + interval })
- const bpm = Math.floor((1000 / sum) * 60) * 2
- this.set(bpm, bpm)
+ const bpm = parseInt((1000 / sum) * 60)
+ if (Math.abs(bpm - this.speed.target) > 1) {
+ this.set(null, bpm)
+ }
}
const now = performance.now()