38 $info = &$this->getid3->info;
40 $OriginalAVdataOffset =
$info[
'avdataoffset'];
41 fseek($this->getid3->fp,
$info[
'avdataoffset'], SEEK_SET);
42 $VOCheader =
fread($this->getid3->fp, 26);
44 $magic =
'Creative Voice File';
45 if (substr($VOCheader, 0, 19) != $magic) {
46 $info[
'error'][] =
'Expecting "'.Helper::PrintHexBytes($magic).
'" at offset '.
$info[
'avdataoffset'].
', found "'.
Helper::PrintHexBytes(substr($VOCheader, 0, 19)).
'"';
52 $thisfile_audio = &
$info[
'audio'];
54 $thisfile_voc = &
$info[
'voc'];
56 $info[
'fileformat'] =
'voc';
57 $thisfile_audio[
'dataformat'] =
'voc';
58 $thisfile_audio[
'bitrate_mode'] =
'cbr';
59 $thisfile_audio[
'lossless'] =
true;
60 $thisfile_audio[
'channels'] = 1;
61 $thisfile_audio[
'bits_per_sample'] = 8;
77 $BlockOffset =
ftell($this->getid3->fp);
78 $BlockData =
fread($this->getid3->fp, 4);
79 $BlockType = ord($BlockData{0});
90 $BlockData .=
fread($this->getid3->fp, 2);
91 if (
$info[
'avdataoffset'] <= $OriginalAVdataOffset) {
92 $info[
'avdataoffset'] =
ftell($this->getid3->fp);
94 fseek($this->getid3->fp, $BlockSize - 2, SEEK_CUR);
100 if ($ThisBlock[
'compression_type'] <= 3) {
101 $thisfile_voc[
'compressed_bits_per_sample'] =
Helper::CastAsInt(str_replace(
'-bit',
'', $ThisBlock[
'compression_name']));
105 if (empty($thisfile_audio[
'sample_rate'])) {
107 $thisfile_audio[
'sample_rate'] =
Helper::trunc((1000000 / (256 - $ThisBlock[
'sample_rate_id'])) / $thisfile_audio[
'channels']);
117 fseek($this->getid3->fp, $BlockSize, SEEK_CUR);
121 $BlockData .=
fread($this->getid3->fp, 4);
130 $thisfile_audio[
'channels'] = ($ThisBlock[
'stereo'] ? 2 : 1);
131 $thisfile_audio[
'sample_rate'] =
Helper::trunc((256000000 / (65536 - $ThisBlock[
'time_constant'])) / $thisfile_audio[
'channels']);
135 $BlockData .=
fread($this->getid3->fp, 12);
136 if (
$info[
'avdataoffset'] <= $OriginalAVdataOffset) {
137 $info[
'avdataoffset'] =
ftell($this->getid3->fp);
139 fseek($this->getid3->fp, $BlockSize - 12, SEEK_CUR);
146 $ThisBlock[
'compression_name'] = $this->
VOCwFormatLookup($ThisBlock[
'wFormat']);
151 $thisfile_audio[
'sample_rate'] = $ThisBlock[
'sample_rate'];
152 $thisfile_audio[
'bits_per_sample'] = $ThisBlock[
'bits_per_sample'];
153 $thisfile_audio[
'channels'] = $ThisBlock[
'channels'];
157 $info[
'warning'][] =
'Unhandled block type "'.$BlockType.
'" at offset '.$BlockOffset;
158 fseek($this->getid3->fp, $BlockSize, SEEK_CUR);
162 if (!empty($ThisBlock)) {
163 $ThisBlock[
'block_offset'] = $BlockOffset;
164 $ThisBlock[
'block_size'] = $BlockSize;
165 $ThisBlock[
'block_type_id'] = $BlockType;
166 $thisfile_voc[
'blocks'][] = $ThisBlock;
169 }
while (!
feof($this->getid3->fp) && ($BlockType != 0));
172 fseek($this->getid3->fp, -3, SEEK_CUR);
174 ksort($thisfile_voc[
'blocktypes']);
176 if (!empty($thisfile_voc[
'compressed_bits_per_sample'])) {
177 $info[
'playtime_seconds'] = ((
$info[
'avdataend'] -
$info[
'avdataoffset']) * 8) / ($thisfile_voc[
'compressed_bits_per_sample'] * $thisfile_audio[
'channels'] * $thisfile_audio[
'sample_rate']);
178 $thisfile_audio[
'bitrate'] = ((
$info[
'avdataend'] -
$info[
'avdataoffset']) * 8) /
$info[
'playtime_seconds'];
192 static $VOCcompressionTypeLookup =
array(
199 return (isset($VOCcompressionTypeLookup[$index]) ? $VOCcompressionTypeLookup[$index] :
'Multi DAC ('.($index - 3).
') channels');
210 static $VOCwFormatLookup =
array(
211 0x0000 =>
'8-bit unsigned PCM',
212 0x0001 =>
'Creative 8-bit to 4-bit ADPCM',
213 0x0002 =>
'Creative 8-bit to 3-bit ADPCM',
214 0x0003 =>
'Creative 8-bit to 2-bit ADPCM',
215 0x0004 =>
'16-bit signed PCM',
216 0x0006 =>
'CCITT a-Law',
217 0x0007 =>
'CCITT u-Law',
218 0x2000 =>
'Creative 16-bit to 4-bit ADPCM' 221 return (isset($VOCwFormatLookup[$index]) ? $VOCwFormatLookup[$index] :
false);
232 static $VOCwFormatLookup =
array(
243 return (isset($VOCwFormatLookup[$index]) ? $VOCwFormatLookup[$index] :
false);
GetId3() by James Heinrich info@getid3.org //.
static PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8')
GetId3() by James Heinrich info@getid3.org //.
VOCwFormatActualBitsPerSampleLookup($index)
array $VOCwFormatLookup
fseek($bytes, $whence=SEEK_SET)
VOCwFormatLookup($index)
array $VOCwFormatLookup
static trunc($floatnumber)
static CastAsInt($floatnum)
VOCcompressionTypeLookup($index)
array $VOCcompressionTypeLookup
Create styles array
The data for the language used.
static LittleEndian2Int($byteword, $signed=false)
static safe_inc(&$variable, $increment=1)