Advertisement

Please help

Started by July 19, 2004 01:37 PM
-1 comments, last by Already_in_use 20 years, 6 months ago
I have been trying really hard to learn some simple audio programming, but there might not be such a thing. I have 3 wav files, they are all the same length, same format recorded on Win98's sndRec32.exe. I want to fread them in to perform two things: Either a) Fwrite and save to a fourth file that plays back the three sounds together, so the playing time will be the same, the file length I guess will have grown, and you'll hear the three sounds simultaneously. and b) fwrite again to a fourth file, but concatenating the three wavs, so the playing time has tripled, and also the file length will have grown too I guess, and you hear them back one after the other. My problem is I'm doing this in PHP and no-one anywhere seems to have done this for me to either learn from or copy. I have a dozen articles from all over the web about the Wave/Riff file format, including C++ source code from here actually, and I have a similar file in PHP that freads a Wave file and converts the little-endian data into what php likes along the lines of: //Extract Format and subchunk1 size $this->fmt = substr($fileinfo,0,4); $this->subchunk1 = hexdec(bin2hex(strrev(substr($fileinfo,4,4)))); //Extract wave file info $this->audioformat = hexdec(bin2hex(strrev(substr($fileinfo,8,2)))); $this->channels = hexdec(bin2hex(strrev(substr($fileinfo,10,2)))); $this->samplerate = hexdec(bin2hex(strrev(substr($fileinfo,12,4)))); I am assuming that the above is okay. So I can open the files and separate out the chunks, but I just dont get how I concatenate two or three of them, and certainly just don't get how to mix them into one sound (mux/merge?) Something about interleaving too, but very little (well, no) examples of this in code, in any language, least of all PHP, but at least in C I would have something to go on. Can anyone help? Thanks, Gregg

This topic is closed to new replies.

Advertisement