22 $OriginalAVdataOffset = $ThisFileInfo[
'avdataoffset'];
23 fseek($fd, $ThisFileInfo[
'avdataoffset'], SEEK_SET);
24 $VOCheader = fread($fd, 26);
26 if (substr($VOCheader, 0, 19) !=
'Creative Voice File') {
27 $ThisFileInfo[
'error'][] =
'Expecting "Creative Voice File" at offset '.$ThisFileInfo[
'avdataoffset'].
', found "'.substr($VOCheader, 0, 19).
'"';
32 $thisfile_audio = &$ThisFileInfo[
'audio'];
33 $ThisFileInfo[
'voc'] = array();
34 $thisfile_voc = &$ThisFileInfo[
'voc'];
36 $ThisFileInfo[
'fileformat'] =
'voc';
37 $thisfile_audio[
'dataformat'] =
'voc';
38 $thisfile_audio[
'bitrate_mode'] =
'cbr';
39 $thisfile_audio[
'lossless'] =
true;
40 $thisfile_audio[
'channels'] = 1;
41 $thisfile_audio[
'bits_per_sample'] = 8;
57 $BlockOffset = ftell($fd);
58 $BlockData = fread($fd, 4);
59 $BlockType = ord($BlockData{0});
63 @$thisfile_voc[
'blocktypes'][$BlockType]++;
70 $BlockData .= fread($fd, 2);
71 if ($ThisFileInfo[
'avdataoffset'] <= $OriginalAVdataOffset) {
72 $ThisFileInfo[
'avdataoffset'] = ftell($fd);
74 fseek($fd, $BlockSize - 2, SEEK_CUR);
80 if ($ThisBlock[
'compression_type'] <= 3) {
81 $thisfile_voc[
'compressed_bits_per_sample'] =
getid3_lib::CastAsInt(str_replace(
'-bit',
'', $ThisBlock[
'compression_name']));
85 if (empty($thisfile_audio[
'sample_rate'])) {
87 $thisfile_audio[
'sample_rate'] =
getid3_lib::trunc((1000000 / (256 - $ThisBlock[
'sample_rate_id'])) / $thisfile_audio[
'channels']);
97 fseek($fd, $BlockSize, SEEK_CUR);
101 $BlockData .= fread($fd, 4);
110 $thisfile_audio[
'channels'] = ($ThisBlock[
'stereo'] ? 2 : 1);
111 $thisfile_audio[
'sample_rate'] =
getid3_lib::trunc((256000000 / (65536 - $ThisBlock[
'time_constant'])) / $thisfile_audio[
'channels']);
115 $BlockData .= fread($fd, 12);
116 if ($ThisFileInfo[
'avdataoffset'] <= $OriginalAVdataOffset) {
117 $ThisFileInfo[
'avdataoffset'] = ftell($fd);
119 fseek($fd, $BlockSize - 12, SEEK_CUR);
126 $ThisBlock[
'compression_name'] = $this->
VOCwFormatLookup($ThisBlock[
'wFormat']);
131 $thisfile_audio[
'sample_rate'] = $ThisBlock[
'sample_rate'];
132 $thisfile_audio[
'bits_per_sample'] = $ThisBlock[
'bits_per_sample'];
133 $thisfile_audio[
'channels'] = $ThisBlock[
'channels'];
137 $ThisFileInfo[
'warning'][] =
'Unhandled block type "'.$BlockType.
'" at offset '.$BlockOffset;
138 fseek($fd, $BlockSize, SEEK_CUR);
142 if (!empty($ThisBlock)) {
143 $ThisBlock[
'block_offset'] = $BlockOffset;
144 $ThisBlock[
'block_size'] = $BlockSize;
145 $ThisBlock[
'block_type_id'] = $BlockType;
146 $thisfile_voc[
'blocks'][] = $ThisBlock;
149 }
while (!feof($fd) && ($BlockType != 0));
152 fseek($fd, -3, SEEK_CUR);
154 ksort($thisfile_voc[
'blocktypes']);
156 if (!empty($thisfile_voc[
'compressed_bits_per_sample'])) {
157 $ThisFileInfo[
'playtime_seconds'] = (($ThisFileInfo[
'avdataend'] - $ThisFileInfo[
'avdataoffset']) * 8) / ($thisfile_voc[
'compressed_bits_per_sample'] * $thisfile_audio[
'channels'] * $thisfile_audio[
'sample_rate']);
158 $thisfile_audio[
'bitrate'] = (($ThisFileInfo[
'avdataend'] - $ThisFileInfo[
'avdataoffset']) * 8) / $ThisFileInfo[
'playtime_seconds'];
165 static $VOCcompressionTypeLookup = array(
171 return (isset($VOCcompressionTypeLookup[$index]) ? $VOCcompressionTypeLookup[$index] :
'Multi DAC ('.($index - 3).
') channels');
175 static $VOCwFormatLookup = array(
176 0x0000 =>
'8-bit unsigned PCM',
177 0x0001 =>
'Creative 8-bit to 4-bit ADPCM',
178 0x0002 =>
'Creative 8-bit to 3-bit ADPCM',
179 0x0003 =>
'Creative 8-bit to 2-bit ADPCM',
180 0x0004 =>
'16-bit signed PCM',
181 0x0006 =>
'CCITT a-Law',
182 0x0007 =>
'CCITT u-Law',
183 0x2000 =>
'Creative 16-bit to 4-bit ADPCM'
185 return (isset($VOCwFormatLookup[$index]) ? $VOCwFormatLookup[$index] :
false);
189 static $VOCwFormatLookup = array(
199 return (isset($VOCwFormatLookup[$index]) ? $VOCwFormatLookup[$index] :
false);