Summary
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);
// 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);
}
return $header.pack('V',strlen($data)).$data;
}
Usage
joinwavs(array("1st.wav","2nd.wav","3rd.wav"));
Reference
splitbrain.org - Joining .WAVs with PHP
http://www.splitbrain.org/blog/2006-11/15-joining_wavs_with_php
Index of /audio
http://bartok.wizbit.net/audio/
via
phpspot開発日誌 - 2006-12-01 - PHPでオーディオ読み上げCAPTCHAを実現する方法
http://phpspot.org/blog/archives/2006/12/phpcaptcha_1.html