This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const audioCtxRef = useRef<AudioContext | null>(null); | |
| const ensureAudio = useCallback(() => { | |
| if (audioCtxRef.current) return audioCtxRef.current; | |
| const Ctx = | |
| (window as any).AudioContext || (window as any).webkitAudioContext; | |
| if (!Ctx) return null; | |
| audioCtxRef.current = new Ctx(); | |
| return audioCtxRef.current; |