go-sox icon indicating copy to clipboard operation
go-sox copied to clipboard

Play 2 files stimulatingly

Open quangbuule opened this issue 7 years ago • 6 comments

Hi, I tried played the second file while the first file was playing but failed, the second file can only be play when being triggered after the first file finished playing. Is there any solution for this?

Thanks so much!

quangbuule avatar Apr 04 '17 11:04 quangbuule

I think this is simply how sox works: if you want to play two files at once, you need a software mixer. To do that with sox, you need to chain two streams together with a mixer, like the remix effect.

krig avatar Apr 04 '17 13:04 krig

I can't imaging how I could do that, since the second file is playing in the middle of first file (trigger from keyboard event). I would really appreciate if you could hint more by a tiny example.

quangbuule avatar Apr 04 '17 13:04 quangbuule

Unfortunately as far as I understand how sox works, this is not possible :( The effect chain has to be pre-built, it isn't possible to change it later. But maybe I am wrong. I have not looked too deeply into that use case myself.

krig avatar Apr 04 '17 15:04 krig

Yeah, from what I see in the sox manual (http://sox.sourceforge.net/sox.html):

"Note that applying multiple effects in real-time (i.e. when playing audio) is likely to require a high performance computer"

But I don't know how they would do the real-time.

quangbuule avatar Apr 04 '17 15:04 quangbuule

@krig Is it possible to get the same functionality as this command with libsox? /usr/bin/sox -m file1.wav file2.wav NewFile.wav I'm trying to overlay 2 files together that I'm reading into a byte[]. Is there an example of recommendation on how I can set file1 and file2 as 2 separate channels and then output as 1 channel?

jonpastore avatar Jan 31 '21 09:01 jonpastore

Hi @jonpastore , most likely this would need a new API, but at least in theory anything that is possible using the sox command line should be possible to do with the library as well.

krig avatar Mar 05 '21 18:03 krig