diff options
| author | julian laplace <julescarbon@gmail.com> | 2025-07-05 00:25:43 +0200 |
|---|---|---|
| committer | julian laplace <julescarbon@gmail.com> | 2025-07-05 00:25:43 +0200 |
| commit | 60fd4cf67dfbe3fd223791e77d4e2fe1c67c613f (patch) | |
| tree | 706513f9d7f58b6f0d38886e45f851121061d215 /client | |
| parent | e5ec8893d18aa21f771ab56fc5ded42602125f94 (diff) | |
sine
Diffstat (limited to 'client')
| -rw-r--r-- | client/index.js | 5 | ||||
| -rw-r--r-- | client/lib/kalimba.js | 4 | ||||
| -rw-r--r-- | client/lib/organ.js | 10 |
3 files changed, 14 insertions, 5 deletions
diff --git a/client/index.js b/client/index.js index 527d8db..5de7b91 100644 --- a/client/index.js +++ b/client/index.js @@ -4,6 +4,7 @@ import keys from "./lib/keys"; import color from "./lib/color"; import kalimba from "./lib/kalimba"; import organ from "./lib/organ"; +import { getOutput } from "./lib/output"; import { browser, requestAudioContext, choice } from "./lib/util"; import { PRIMES } from "./lib/primes"; // import life from "./lib/life"; @@ -28,7 +29,9 @@ let base_y = 0; let is_split = false; requestAudioContext(() => { - kalimba.load(); + const output = getOutput(); + kalimba.load(output); + organ.load(output); build(); bind(); }); diff --git a/client/lib/kalimba.js b/client/lib/kalimba.js index e79e5f7..7f9121e 100644 --- a/client/lib/kalimba.js +++ b/client/lib/kalimba.js @@ -1,6 +1,5 @@ import Tone from "tone"; import { choice } from "./util"; -import { getOutput } from "./output"; const player_count = 4; @@ -18,8 +17,7 @@ const samples = [ // { root: 671, fn: 'samples/380732__cabled-mess__sansula-09-e-raw.wav', }, ]; -function load() { - const output = getOutput(); +function load(output) { samples.forEach((sample) => { sample.players = []; sample.index = -1; diff --git a/client/lib/organ.js b/client/lib/organ.js index 1e45e68..30972ba 100644 --- a/client/lib/organ.js +++ b/client/lib/organ.js @@ -1,10 +1,17 @@ import Tone from "tone"; -import output from "./output"; const oscillators = {}; +let output; let lastPlayed; + +function load(out) { + output = out; +} function play(freq) { + if (!output) { + return; + } const osc = (oscillators[freq] = oscillators[freq] || {}); if (!osc.el) { osc.el = new Tone.Oscillator(freq, "sine"); @@ -15,6 +22,7 @@ function play(freq) { lastPlayed = osc; return osc; } + function pause(freq) { if (!oscillators[freq]) return; const osc = (oscillators[freq] = oscillators[freq] || {}); |
