summaryrefslogtreecommitdiff
path: root/client/lib/kalimba.js
diff options
context:
space:
mode:
authorJules <jules@asdf.us>2018-02-23 22:21:09 -0500
committerJules <jules@asdf.us>2018-02-23 22:21:09 -0500
commitbb5d129729bab5cfdcc44fcfaa295b1c7e6d4c19 (patch)
treea30de6acbfdf361772bea5bda6c25eab5ffa083f /client/lib/kalimba.js
parent2fada280f6cbe93831573f354192ce8014526d4b (diff)
parentafe0263215ec7cfd256716997deb77eee9c4d6c8 (diff)
Merge branch 'master' of ghghgh.us:triangle
Diffstat (limited to 'client/lib/kalimba.js')
-rw-r--r--client/lib/kalimba.js19
1 files changed, 15 insertions, 4 deletions
diff --git a/client/lib/kalimba.js b/client/lib/kalimba.js
index d3cafbb..249560f 100644
--- a/client/lib/kalimba.js
+++ b/client/lib/kalimba.js
@@ -1,10 +1,9 @@
import Tone from 'tone'
import { choice } from './util'
+import output from './output'
const player_count = 4
-const compressor = new Tone.Compressor(-30, 3).toMaster()
-
const samples = [
{ root: 226, fn: 'samples/380737__cabled-mess__sansula-01-a-raw.wav', },
{ root: 267, fn: 'samples/380736__cabled-mess__sansula-02-c-raw.wav', },
@@ -28,12 +27,21 @@ samples.forEach((sample) => {
retrigger: true,
playbackRate: 1,
})
- player.connect(compressor)
+ player.connect(output)
sample.players.push(player)
}
})
function play (freq) {
+/*
+ while (freq < 440) {
+ freq *= 2
+ }
+ while (freq > 880) {
+ freq /= 2
+ }
+ freq /= 2
+*/
const best = { sample: choice(samples) }
best.sample.index = (best.sample.index + 1) % player_count
@@ -41,6 +49,9 @@ function play (freq) {
player.playbackRate = freq / best.sample.root
player.start()
}
+function pause () {
+ // no-op
+}
-export default { play }
+export default { play, pause }