summaryrefslogtreecommitdiff
path: root/client/lib/organ.js
diff options
context:
space:
mode:
authorjulian laplace <julescarbon@gmail.com>2025-07-05 13:46:12 +0200
committerjulian laplace <julescarbon@gmail.com>2025-07-05 13:46:12 +0200
commita7f55141d2270fcadfb218bef0a06c114636722c (patch)
tree52c5dd1dedcc3e9e09f12d75452b101106f13b01 /client/lib/organ.js
parent07dafb284ac799032fc0beefbcb562623ff8c2e6 (diff)
tuned triangle
Diffstat (limited to 'client/lib/organ.js')
-rw-r--r--client/lib/organ.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/client/lib/organ.js b/client/lib/organ.js
index b1aa1c2..f67a3e8 100644
--- a/client/lib/organ.js
+++ b/client/lib/organ.js
@@ -12,7 +12,8 @@ function play(freq) {
if (!output) {
return;
}
- const osc = (oscillators[freq] = oscillators[freq] || {});
+ const rounded = Math.floor(freq);
+ const osc = (oscillators[rounded] = oscillators[rounded] || {});
if (!osc.el) {
osc.el = new Tone.Oscillator(freq, "sine");
osc.el.connect(output);
@@ -24,8 +25,9 @@ function play(freq) {
}
function pause(freq) {
- if (!oscillators[freq]) return;
- const osc = (oscillators[freq] = oscillators[freq] || {});
+ const rounded = Math.floor(freq);
+ if (!oscillators[rounded]) return;
+ const osc = (oscillators[rounded] = oscillators[rounded] || {});
if (osc.el) osc.el.stop();
osc.playing = false;
return osc;