From 0e986c69315fd2e37d70871126f9062fc568aa66 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Fri, 12 Apr 2019 09:25:29 +0900 Subject: Clamp BPM, added `a` to BPM animateTo . --- desktop/core/io/udp.js | 2 ++ desktop/sources/scripts/clock.js | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/desktop/core/io/udp.js b/desktop/core/io/udp.js index ba64897..494df67 100644 --- a/desktop/core/io/udp.js +++ b/desktop/core/io/udp.js @@ -81,6 +81,8 @@ function Udp (terminal) { } else if (key === 'f' && Number.isInteger(int)) { terminal.orca.f = int } else if (key === 'b' && Number.isInteger(int)) { + terminal.clock.setSpeed(int, false) + } else if (key === 'a' && Number.isInteger(int)) { terminal.clock.setSpeed(int, true) } else if (key === 'w' && val.length >= 4 && val.indexOf(':') > -1) { const pos = val.substr(1).split(':') diff --git a/desktop/sources/scripts/clock.js b/desktop/sources/scripts/clock.js index b2b826f..e563ea2 100644 --- a/desktop/sources/scripts/clock.js +++ b/desktop/sources/scripts/clock.js @@ -18,6 +18,9 @@ function Clock (terminal) { if (this.speed.value < this.speed.target) { this.speed.value++ } if (this.speed.value > this.speed.target) { this.speed.value-- } + + this.speed.value = clamp(this.speed.value, 60, 300) + this.speed.target = clamp(this.speed.target, 60, 300) } this.togglePlay = function () { @@ -83,6 +86,8 @@ function Clock (terminal) { const _beat = diff === 0 && terminal.orca.f % 4 === 0 ? '*' : '' return `${this.speed.value}${_offset}${_beat}` } + + function clamp (v, min, max) { return v < min ? min : v > max ? max : v } } module.exports = Clock -- cgit v1.2.3