diff options
author | neauoire <[email protected]> | 2019-11-14 09:59:06 -0500 |
---|---|---|
committer | neauoire <[email protected]> | 2019-11-14 09:59:06 -0500 |
commit | 88462564aec85f0e1780d488d725daec9fe16028 (patch) | |
tree | 6490e6074e89c61b34cbc91e1addf598a7cf2d17 /desktop/sources/scripts/clock.js | |
parent | f8d02fe8a4c5f8964cd098919037701e1f58930d (diff) | |
download | Orca-88462564aec85f0e1780d488d725daec9fe16028.tar.gz Orca-88462564aec85f0e1780d488d725daec9fe16028.zip |
Store clock speed in localStorage
Diffstat (limited to 'desktop/sources/scripts/clock.js')
-rw-r--r-- | desktop/sources/scripts/clock.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/desktop/sources/scripts/clock.js b/desktop/sources/scripts/clock.js index f947ec4..6ae6eed 100644 --- a/desktop/sources/scripts/clock.js +++ b/desktop/sources/scripts/clock.js @@ -12,7 +12,9 @@ function Clock (client) { this.speed = { value: 120, target: 120 } this.start = function () { - this.setTimer(120) + const memory = parseInt(window.localStorage.getItem('bpm')) + const target = memory >= 60 ? memory : 120 + this.setSpeed(target, target, true) this.play() } @@ -106,10 +108,12 @@ function Clock (client) { // Timer this.setTimer = function (bpm) { + if (bpm < 60) { console.warn('Clock', 'Error ' + bpm); return } console.log('Clock', 'New Timer ' + bpm + 'bpm') this.clearTimer() + window.localStorage.setItem('bpm', bpm) this.timer = new Worker(window.URL.createObjectURL(new Blob([worker], { type: 'text/javascript' }))) - this.timer.postMessage((60000 / bpm) / 4) + this.timer.postMessage((60000 / parseInt(bpm)) / 4) this.timer.onmessage = (event) => { client.io.midi.sendClock() client.run() |