summaryrefslogtreecommitdiff
path: root/client/lib/organ.js
diff options
context:
space:
mode:
authorjulian laplace <julescarbon@gmail.com>2025-07-14 16:58:49 +0200
committerjulian laplace <julescarbon@gmail.com>2025-07-14 16:58:49 +0200
commit6e53264b8fc0ed94282bcce022f07c551e925547 (patch)
tree32694b45fbe228d5f905615755a56ceb24f87a84 /client/lib/organ.js
parentedaae6d07fa1abb1e3a9ae8e113bddd663c89c5b (diff)
pitched noise mode
Diffstat (limited to 'client/lib/organ.js')
-rw-r--r--client/lib/organ.js67
1 files changed, 0 insertions, 67 deletions
diff --git a/client/lib/organ.js b/client/lib/organ.js
deleted file mode 100644
index e66f89d..0000000
--- a/client/lib/organ.js
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * Sine wave organ
- * @module lib/organ.js;
- */
-
-import Tone from "tone";
-import { roundInterval } from "./util";
-
-let root = 440;
-
-let oscillators = {};
-let output;
-let lastPlayed;
-
-function load(out) {
- output = out;
-}
-function isPlaying(interval) {
- const rounded = roundInterval(interval);
- const osc = oscillators[rounded];
- return osc && osc.playing;
-}
-function play(interval) {
- if (!output) {
- return;
- }
- const rounded = roundInterval(interval);
- const osc = (oscillators[rounded] = oscillators[rounded] || {});
- if (!osc.el) {
- osc.interval = interval;
- osc.el = new Tone.Oscillator(interval * root, "sine");
- osc.el.connect(output);
- }
- osc.el.start();
- osc.playing = true;
- lastPlayed = osc;
- return osc;
-}
-
-function pause(interval) {
- const rounded = roundInterval(interval);
- if (!oscillators[rounded]) return;
- const osc = (oscillators[rounded] = oscillators[rounded] || {});
- if (osc.el) {
- osc.el.stop();
- }
- osc.playing = false;
- return osc;
-}
-
-function setRoot(newRoot) {
- root = newRoot;
- for (const osc of Object.values(oscillators)) {
- osc.el.frequency.value = osc.interval * newRoot;
- }
-}
-function stop() {
- for (const osc of Object.values(oscillators)) {
- osc.el.stop();
- osc.el.disconnect();
- osc.playing = false;
- delete osc.el;
- }
- oscillators = {};
-}
-
-export default { load, isPlaying, play, pause, stop, setRoot };