function WaveHeader(&$f, $sampleRate) { $fmt = pack('v', 1) . pack('v', 1) . pack('V', $sampleRate) . pack('V', $sampleRate * 2) . pack('v', 2) . pack('v', 16); $head = WaveChunk('fmt', $fmt); $org = ftell($f); if ($org != 0) { $ptr = $org - 8; fseek($f, 0, SEEK_SET); } $head = "RIFF" . pack('V', $ptr) . 'WAVE' . $head . 'data' . pack('V', $org - 44); fwrite($f, $head); }
function WaveHeader(&$f, $sampleRate) { $fmt = pack('v', 1) . pack('v', 1) . pack('V', $sampleRate) . pack('V', $sampleRate * 2) . pack('v', 2) . pack('v', 16); // Bits x sample $head = WaveChunk('fmt', $fmt); $org = ftell($f); if ($org != 0) { $ptr = $org - 8; fseek($f, 0, SEEK_SET); } $head = "RIFF" . pack('V', $ptr) . 'WAVE' . $head . 'data' . pack('V', $org - 44); /* * RIFF / WAVE { * fmt { format } * data { PCM Wave audio } * } * * */ fwrite($f, $head); }
function WaveHeader(&$f, $sampleRate) { // Inizializza e finalizza un file wave. $fmt = pack('v', 1) . pack('v', 1) . pack('V', $sampleRate) . pack('V', $sampleRate * 2) . pack('v', 2) . pack('v', 16); // Bit x sample. $head = WaveChunk('fmt', $fmt); $org = ftell($f); if ($org != 0) { // Se il puntatore del file non è a 0, lo porto a zero e chiudo gli elementi RIFF/WAVE, e data. $ptr = $org - 8; fseek($f, 0, SEEK_SET); } $head = "RIFF" . pack('V', $ptr) . 'WAVE' . $head . 'data' . pack('V', $org - 44); /* * Struttura dei fiel wave: * * RIFF / WAVE { * fmt { formato } * data { PCM Wave audio } * } * * */ fwrite($f, $head); }