faiface / beep

A little package that brings sound to any Go application. Suitable for playback and audio-processing.
MIT License
2.07k stars 152 forks source link

Is there a smart way to play overlapping sounds? #161

Open szymonnedzi opened 1 year ago

szymonnedzi commented 1 year ago

I'm developing an application that plays overlapping .wav files, and I want to be able to mute/unmute or pause/start a specific one on a specific input. Should I load the files into the same beep.Streamer and load it into one beep.Speaker or into the same beep.Buffer and then into a beep.Speaker or approach it in a different way? What's the 'correct' way to do so?

MarkKremer commented 1 year ago

If you want to mute/pause specific sounds independently it's not useful to put them into the same beep.Buffer.

I would keep it simple by letting the speaker do the merging:

wav 1 -> buffer -> mute/pause
                        |
                        v
                     speaker
                        ^
                        |
wav 2 -> buffer -> mute/pause

The buffer alleviates the pressure on the speakers internal buffer a bit but I'm not certain it is required.