From 0d1a99deb29b791294b5a9fcbff6571e58ea0552 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Thu, 2 Nov 2023 10:37:38 +0100 Subject: [PATCH] also pull in audio init to prebake --- website/src/docs/MiniRepl.jsx | 6 ++---- website/src/repl/Repl.jsx | 4 +--- website/src/repl/prebake.mjs | 4 +++- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/website/src/docs/MiniRepl.jsx b/website/src/docs/MiniRepl.jsx index 15eb9cb5b..552e1027e 100644 --- a/website/src/docs/MiniRepl.jsx +++ b/website/src/docs/MiniRepl.jsx @@ -1,15 +1,13 @@ -import { evalScope, controls, noteToMidi } from '@strudel.cycles/core'; -import { initAudioOnFirstClick } from '@strudel.cycles/webaudio'; +import { noteToMidi } from '@strudel.cycles/core'; import { useEffect, useState } from 'react'; import { prebake } from '../repl/prebake'; -import { themes, settings } from '../repl/themes.mjs'; +import { themes } from '../repl/themes.mjs'; import './MiniRepl.css'; import { useSettings } from '../settings.mjs'; import Claviature from '@components/Claviature'; let init; if (typeof window !== 'undefined') { - initAudioOnFirstClick(); init = prebake(); } diff --git a/website/src/repl/Repl.jsx b/website/src/repl/Repl.jsx index afdb617c8..5bde3c111 100644 --- a/website/src/repl/Repl.jsx +++ b/website/src/repl/Repl.jsx @@ -6,7 +6,7 @@ This program is free software: you can redistribute it and/or modify it under th import { cleanupDraw, cleanupUi, getDrawContext, logger } from '@strudel.cycles/core'; import { CodeMirror, cx, flash, useHighlighting, useStrudel, useKeydown } from '@strudel.cycles/react'; -import { getAudioContext, initAudioOnFirstClick, resetLoadedSounds, webaudioOutput } from '@strudel.cycles/webaudio'; +import { getAudioContext, resetLoadedSounds, webaudioOutput } from '@strudel.cycles/webaudio'; import { createClient } from '@supabase/supabase-js'; import { nanoid } from 'nanoid'; import React, { createContext, useCallback, useEffect, useState, useMemo } from 'react'; @@ -26,8 +26,6 @@ import { writeText } from '@tauri-apps/api/clipboard'; const { latestCode } = settingsMap.get(); -initAudioOnFirstClick(); - // Create a single supabase client for interacting with your database const supabase = createClient( 'https://pidxdsxphlhzjnzmifth.supabase.co', diff --git a/website/src/repl/prebake.mjs b/website/src/repl/prebake.mjs index 61b124a1b..ba15418af 100644 --- a/website/src/repl/prebake.mjs +++ b/website/src/repl/prebake.mjs @@ -1,11 +1,12 @@ import { Pattern, noteToMidi, valueToMidi, controls, evalScope } from '@strudel.cycles/core'; -import { registerSynthSounds, registerZZFXSounds, samples } from '@strudel.cycles/webaudio'; +import { initAudioOnFirstClick, registerSynthSounds, registerZZFXSounds, samples } from '@strudel.cycles/webaudio'; import './piano.mjs'; import './files.mjs'; import { isTauri } from '../tauri.mjs'; import { settingPatterns } from '../settings.mjs'; export async function prebake() { + const initAudio = initAudioOnFirstClick(); // lazy load modules let modules = [ import('@strudel.cycles/core'), @@ -36,6 +37,7 @@ export async function prebake() { ); // register sounds and samples return Promise.all([ + initAudio, modulesLoading, registerSynthSounds(), registerZZFXSounds(),