aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDevine Lu Linvega <[email protected]>2019-04-12 09:25:29 +0900
committerDevine Lu Linvega <[email protected]>2019-04-12 09:25:29 +0900
commit0e986c69315fd2e37d70871126f9062fc568aa66 (patch)
tree01586ad01d2dde3f7521da43723c87fdb9526bfd
parenta6262a72aa4fb6f83fd97154bab05865037486e5 (diff)
downloadOrca-0e986c69315fd2e37d70871126f9062fc568aa66.tar.gz
Orca-0e986c69315fd2e37d70871126f9062fc568aa66.zip
Clamp BPM, added `a` to BPM animateTo .
-rw-r--r--desktop/core/io/udp.js2
-rw-r--r--desktop/sources/scripts/clock.js5
2 files changed, 7 insertions, 0 deletions
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