Re: sndio play multiple wav files ?

Ronald Dahlgren <[email protected]>
Newsgroups gmane.os.openbsd.misc
Message-ID <CAMdPrer51E2esKa4mPi9rEH6EnAwFySkR2144ncPzQP9gfvyTg@mail.gmail.com>
On Fri, Jun 5, 2026 at 5:48 PM Jan Stary <[email protected]> wrote:

> On Jun 05 16:09:53, [email protected] wrote:
> > Hi!,
> >
> > I am working on a curses C sndio app to
> > play samples that are just wav files.
> > I would like to be able to play them
> > "over each other" like not sequentially.
> >
> > (I would like for the wav file to play
> > regardless if another one is already playing.)
> >
> > I can play ONE wav file using sndio.
> >
> > https://codeberg.org/pkw/siotest/src/branch/main/siotest.c#L130
> >
> > What is the easiest and most idiomatic way
> > to play multiples ones ?
>
> If they use the same sample encoding and have the same number of channels
> and use the same sample rate, then make one output sample the average
> of the input samples, obviously. Doing the arithmetics might overflow
> though, so you might want to convert to floats and do the arithmetics
> there and then convert back to the sample encoding you want to play.
>
> And if they do not use the same sample rate, you have resampling to do;
> and if they do not use the same sample encoding, you need to convert;
> and if they have different number of channels, you need to remix somehow.
>
> > Any pointers or places to look?
>
> Look what aucat does with more than one -i
>
>         Jan
>
>
Hi Paul,

I built a simple library to handle this case a couple of years ago to
handle exactly such a case. I used it in a dichotic listening test and in
for audio feedback in a stroop test. You can find the code here ->
https://sw.gy/c-snd/

Ron
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.