diff --git a/src/App/Plant/TrafficLight/TrafficLight.tsx b/src/App/Plant/TrafficLight/TrafficLight.tsx index b014573..8ffd4da 100644 --- a/src/App/Plant/TrafficLight/TrafficLight.tsx +++ b/src/App/Plant/TrafficLight/TrafficLight.tsx @@ -40,23 +40,21 @@ export const TrafficLight = memo(function TrafficLight({state, speed, raiseUIEve // preloadAudio(sndAtmosphere); - // play wind + // the traffic light makes sound too: useEffect(() => { const stopPlaying = playURL(sndAtmosphere, true); return () => stopPlaying(); }, []); - // for added realism, every light color has its own buzzing noise volume - for (const [color, gain] of [[redOn, 0.5], [yellowOn, 1], [greenOn, 0.3]] as [boolean, number][]) { - useEffect(() => { - if (color) { - const stopPlaying = playURL(sndBuzz, true, gain); - return () => { - stopPlaying(); - }; - } - }, [color]); - } + useEffect(() => { + if (redOn || yellowOn || greenOn) { + const stopPlaying = playURL(sndBuzz, true); + return () => { + stopPlaying(); + }; + } + else return () => {}; + }, [redOn || yellowOn || greenOn]) return <>