22 $info = &$this->getid3->info;
24 $OriginalAVdataOffset =
$info[
'avdataoffset'];
26 $VOCheader = $this->
fread(26);
28 $magic =
'Creative Voice File';
29 if (substr($VOCheader, 0, 19) != $magic) {
35 $thisfile_audio = &
$info[
'audio'];
36 $info[
'voc'] = array();
37 $thisfile_voc = &
$info[
'voc'];
39 $info[
'fileformat'] =
'voc';
40 $thisfile_audio[
'dataformat'] =
'voc';
41 $thisfile_audio[
'bitrate_mode'] =
'cbr';
42 $thisfile_audio[
'lossless'] =
true;
43 $thisfile_audio[
'channels'] = 1;
44 $thisfile_audio[
'bits_per_sample'] = 8;
60 $BlockOffset = $this->
ftell();
61 $BlockData = $this->
fread(4);
62 $BlockType = ord($BlockData{0});
73 $BlockData .= $this->
fread(2);
74 if (
$info[
'avdataoffset'] <= $OriginalAVdataOffset) {
77 $this->
fseek($BlockSize - 2, SEEK_CUR);
83 if ($ThisBlock[
'compression_type'] <= 3) {
84 $thisfile_voc[
'compressed_bits_per_sample'] =
getid3_lib::CastAsInt(str_replace(
'-bit',
'', $ThisBlock[
'compression_name']));
88 if (empty($thisfile_audio[
'sample_rate'])) {
90 $thisfile_audio[
'sample_rate'] =
getid3_lib::trunc((1000000 / (256 - $ThisBlock[
'sample_rate_id'])) / $thisfile_audio[
'channels']);
100 $this->
fseek($BlockSize, SEEK_CUR);
104 $BlockData .= $this->
fread(4);
113 $thisfile_audio[
'channels'] = ($ThisBlock[
'stereo'] ? 2 : 1);
114 $thisfile_audio[
'sample_rate'] =
getid3_lib::trunc((256000000 / (65536 - $ThisBlock[
'time_constant'])) / $thisfile_audio[
'channels']);
118 $BlockData .= $this->
fread(12);
119 if (
$info[
'avdataoffset'] <= $OriginalAVdataOffset) {
122 $this->
fseek($BlockSize - 12, SEEK_CUR);
129 $ThisBlock[
'compression_name'] = $this->
VOCwFormatLookup($ThisBlock[
'wFormat']);
134 $thisfile_audio[
'sample_rate'] = $ThisBlock[
'sample_rate'];
135 $thisfile_audio[
'bits_per_sample'] = $ThisBlock[
'bits_per_sample'];
136 $thisfile_audio[
'channels'] = $ThisBlock[
'channels'];
140 $this->
warning(
'Unhandled block type "'.$BlockType.
'" at offset '.$BlockOffset);
141 $this->
fseek($BlockSize, SEEK_CUR);
145 if (!empty($ThisBlock)) {
146 $ThisBlock[
'block_offset'] = $BlockOffset;
147 $ThisBlock[
'block_size'] = $BlockSize;
148 $ThisBlock[
'block_type_id'] = $BlockType;
149 $thisfile_voc[
'blocks'][] = $ThisBlock;
152 }
while (!
feof($this->getid3->fp) && ($BlockType != 0));
155 $this->
fseek(-3, SEEK_CUR);
157 ksort($thisfile_voc[
'blocktypes']);
159 if (!empty($thisfile_voc[
'compressed_bits_per_sample'])) {
160 $info[
'playtime_seconds'] = ((
$info[
'avdataend'] -
$info[
'avdataoffset']) * 8) / ($thisfile_voc[
'compressed_bits_per_sample'] * $thisfile_audio[
'channels'] * $thisfile_audio[
'sample_rate']);
161 $thisfile_audio[
'bitrate'] = ((
$info[
'avdataend'] -
$info[
'avdataoffset']) * 8) /
$info[
'playtime_seconds'];
168 static $VOCcompressionTypeLookup = array(
174 return (isset($VOCcompressionTypeLookup[
$index]) ? $VOCcompressionTypeLookup[$index] :
'Multi DAC ('.($index - 3).
') channels');
178 static $VOCwFormatLookup = array(
179 0x0000 =>
'8-bit unsigned PCM',
180 0x0001 =>
'Creative 8-bit to 4-bit ADPCM',
181 0x0002 =>
'Creative 8-bit to 3-bit ADPCM',
182 0x0003 =>
'Creative 8-bit to 2-bit ADPCM',
183 0x0004 =>
'16-bit signed PCM',
184 0x0006 =>
'CCITT a-Law',
185 0x0007 =>
'CCITT u-Law',
186 0x2000 =>
'Creative 16-bit to 4-bit ADPCM' 188 return (isset($VOCwFormatLookup[
$index]) ? $VOCwFormatLookup[$index] :
false);
192 static $VOCwFormatLookup = array(
202 return (isset($VOCwFormatLookup[
$index]) ? $VOCwFormatLookup[$index] :
false);
static safe_inc(&$variable, $increment=1)
static LittleEndian2Int($byteword, $signed=false)
VOCcompressionTypeLookup($index)
VOCwFormatActualBitsPerSampleLookup($index)
static trunc($floatnumber)
getID3() by James Heinrich info@getid3.org //
static CastAsInt($floatnum)
static PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8')
fseek($bytes, $whence=SEEK_SET)