Question

Is it possible to combine two wav files into one as if they've been played simultaneously? I need to do this programatically.

The only way I found till now is to play both simultaneously and record the output using AVAudioRecorder. But this won't work if the user's using headphones.

Can someone please point me to the right direction.

Thanks.

Was it helpful?

Solution

There might be a better way, but if both wavs have same encoding/bitrate, etc, you can just strip the wav header (first 44 bytes according to wav format spec) of the second file and concatenate the rest of 2nd wav to first.

OTHER TIPS

You'll need to read the sample data of each file, average each sample value, and write the result to a new file. You can use ExtAudioFile to read and write files, including the headers and the sample data.

You also need to update the header with the correct length of the file, because there are fields whose value depends on the length of the sample data.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top