22 $ThisFileInfo[
'fileformat'] =
'tta';
23 $ThisFileInfo[
'audio'][
'dataformat'] =
'tta';
24 $ThisFileInfo[
'audio'][
'lossless'] =
true;
25 $ThisFileInfo[
'audio'][
'bitrate_mode'] =
'vbr';
27 fseek($fd, $ThisFileInfo[
'avdataoffset'], SEEK_SET);
28 $ttaheader = fread($fd, 26);
30 $ThisFileInfo[
'tta'][
'magic'] = substr($ttaheader, 0, 3);
31 if ($ThisFileInfo[
'tta'][
'magic'] !=
'TTA') {
32 $ThisFileInfo[
'error'][] =
'Expecting "TTA" at offset '.$ThisFileInfo[
'avdataoffset'].
', found "'.$ThisFileInfo[
'tta'][
'magic'].
'"';
33 unset($ThisFileInfo[
'fileformat']);
34 unset($ThisFileInfo[
'audio']);
35 unset($ThisFileInfo[
'tta']);
39 switch ($ttaheader{3}) {
44 $ThisFileInfo[
'tta'][
'major_version'] = 1;
45 $ThisFileInfo[
'avdataoffset'] += 16;
47 $ThisFileInfo[
'tta'][
'compression_level'] = ord($ttaheader{3});
53 $ThisFileInfo[
'audio'][
'encoder_options'] =
'-e'.$ThisFileInfo[
'tta'][
'compression_level'];
54 $ThisFileInfo[
'playtime_seconds'] = $ThisFileInfo[
'tta'][
'samples_per_channel'] / $ThisFileInfo[
'tta'][
'sample_rate'];
59 $ThisFileInfo[
'tta'][
'major_version'] = 2;
60 $ThisFileInfo[
'avdataoffset'] += 20;
69 $ThisFileInfo[
'audio'][
'encoder_options'] =
'-e'.$ThisFileInfo[
'tta'][
'compression_level'];
70 $ThisFileInfo[
'playtime_seconds'] = $ThisFileInfo[
'tta'][
'data_length'] / $ThisFileInfo[
'tta'][
'sample_rate'];
75 $ThisFileInfo[
'tta'][
'major_version'] = 3;
76 $ThisFileInfo[
'avdataoffset'] += 26;
83 $ThisFileInfo[
'tta'][
'crc32_footer'] = substr($ttaheader, 18, 4);
86 $ThisFileInfo[
'playtime_seconds'] = $ThisFileInfo[
'tta'][
'data_length'] / $ThisFileInfo[
'tta'][
'sample_rate'];
90 $ThisFileInfo[
'error'][] =
'This version of getID3() only knows how to handle TTA v1 and v2 - it may not work correctly with this file which appears to be TTA v'.$ttaheader{3};
95 $ThisFileInfo[
'audio'][
'encoder'] =
'TTA v'.$ThisFileInfo[
'tta'][
'major_version'];
96 $ThisFileInfo[
'audio'][
'bits_per_sample'] = $ThisFileInfo[
'tta'][
'bits_per_sample'];
97 $ThisFileInfo[
'audio'][
'sample_rate'] = $ThisFileInfo[
'tta'][
'sample_rate'];
98 $ThisFileInfo[
'audio'][
'channels'] = $ThisFileInfo[
'tta'][
'channels'];
99 $ThisFileInfo[
'audio'][
'bitrate'] = (($ThisFileInfo[
'avdataend'] - $ThisFileInfo[
'avdataoffset']) * 8) / $ThisFileInfo[
'playtime_seconds'];