summaryrefslogtreecommitdiff
path: root/fig-frontend-client/src/Audio.js
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2024-03-29 00:06:11 -0400
committerLLLL Colonq <llll@colonq>2024-03-29 00:06:11 -0400
commitdec476ab9b8602225964cfa534bb004676ff6419 (patch)
tree6b75b1905b4e2493633f6be7490a37b489dbffb1 /fig-frontend-client/src/Audio.js
parentb679cce8e0c8ca20d53b1032b15f80ebf6072617 (diff)
Update frontend
Diffstat (limited to 'fig-frontend-client/src/Audio.js')
-rw-r--r--fig-frontend-client/src/Audio.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/fig-frontend-client/src/Audio.js b/fig-frontend-client/src/Audio.js
new file mode 100644
index 0000000..2a9ae54
--- /dev/null
+++ b/fig-frontend-client/src/Audio.js
@@ -0,0 +1,30 @@
+let initialized = false;
+let ctx = null;
+let voiceTracks = null;
+
+function initializeCtx() {
+ if (!initialized) {
+ try {
+ initialized = true;
+ ctx = new window.AudioContext();
+ voiceTracks = [
+ document.getElementById("lcolonq-audio-voice-0"),
+ document.getElementById("lcolonq-audio-voice-1"),
+ document.getElementById("lcolonq-audio-voice-2"),
+ document.getElementById("lcolonq-audio-voice-3"),
+ document.getElementById("lcolonq-audio-voice-4"),
+ document.getElementById("lcolonq-audio-voice-5"),
+ document.getElementById("lcolonq-audio-voice-6"),
+ ];
+ } catch (e) {
+ initialized = false;
+ }
+ }
+}
+
+export const _playVoice = (b) => (i) => () => {
+ if (b) initializeCtx();
+ try {
+ if (initialized) voiceTracks[i].play();
+ } catch (e) {}
+};