Hi Guys
I need a php script which will merge two wave files as i have already done a script which will will join the two wave files and play one after the other, can anyone advice me how to merge the two wave file and the two files has to play simultaneously. i have placed my script here
<?php
$content = joinwavs(array('1.wav','2.wav'));
header('Content-Type: audio/x-wav');
//echo $content;
function joinwavs($wavs){
$fields = join('/',array( 'H8ChunkID', 'VChunkSize', 'H8Format',
'H8Subchunk1ID', 'VSubchunk1Size',
'vAudioFormat', 'vNumChannels', 'VSampleRate',
'VByteRate', 'vBlockAlign', 'vBitsPerSample' ));
$data = '';
foreach($wavs as $wav){
$fp = fopen($wav,'rb');
$header = fread($fp,36);
$info = unpack($fields,$header);
// Destination file to be writed
$destfile = "destination.wav";
// read optional extra stuff
if($info['Subchunk1Size'] > 16){
$header .= fread($fp,($info['Subchunk1Size']-16));
}
// read SubChunk2ID
$header .= fread($fp,4);
// read Subchunk2Size
$size = unpack('vsize',fread($fp,4));
$size = $size['size'];
// read data
$data .= fread($fp,$size);
$filecontent = $header.pack('V',strlen($data)).$data;
// Write the output data in a seperate file
$fp1 = fopen($destfile,"wb");
fwrite($fp1,$filecontent);
fclose($fp1);
}
}
?>
Regards
Karthik