mirror of
https://github.com/remvze/moodist.git
synced 2025-12-18 01:14:17 +00:00
Merge 608e9aa806 into aa2b47ace4
This commit is contained in:
commit
4a64d84e7d
1 changed files with 16 additions and 5 deletions
|
|
@ -100,9 +100,22 @@ export function BinauralModal({ onClose, show }: BinauralProps) {
|
|||
const stopSound = useCallback(() => {
|
||||
if (!isPlaying) return;
|
||||
|
||||
// Stop oscillators
|
||||
leftOscillatorRef.current?.stop();
|
||||
rightOscillatorRef.current?.stop();
|
||||
audioContextRef.current?.close();
|
||||
|
||||
// Unload oscillators
|
||||
leftOscillatorRef.current = null;
|
||||
rightOscillatorRef.current = null;
|
||||
|
||||
// Close and unload AudioContext
|
||||
if (audioContextRef.current) {
|
||||
audioContextRef.current.close();
|
||||
audioContextRef.current = null;
|
||||
}
|
||||
|
||||
// Unload gain node
|
||||
gainNodeRef.current = null;
|
||||
|
||||
setIsPlaying(false);
|
||||
}, [isPlaying]);
|
||||
|
|
@ -127,11 +140,9 @@ export function BinauralModal({ onClose, show }: BinauralProps) {
|
|||
useEffect(() => {
|
||||
// Cleanup when component unmounts
|
||||
return () => {
|
||||
if (isPlaying) {
|
||||
stopSound();
|
||||
}
|
||||
stopSound();
|
||||
};
|
||||
}, [isPlaying, stopSound]);
|
||||
}, [stopSound]);
|
||||
|
||||
useEffect(() => {
|
||||
// Update frequencies when a preset is selected
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue