view e2gallerypro/e2upload/Backend/Assets/getid3/module.audio.tta.php @ 18:903b91a97990 judyates

updated site to use google analytics
author Robert McIntyre <rlm@mit.edu>
date Mon, 11 Jul 2011 03:06:13 -0400
parents 3f6b44aa6b35
children
line wrap: on
line source
1 <?php
2 // +----------------------------------------------------------------------+
3 // | PHP version 5 |
4 // +----------------------------------------------------------------------+
5 // | Copyright (c) 2002-2006 James Heinrich, Allan Hansen |
6 // +----------------------------------------------------------------------+
7 // | This source file is subject to version 2 of the GPL license, |
8 // | that is bundled with this package in the file license.txt and is |
9 // | available through the world-wide-web at the following url: |
10 // | http://www.gnu.org/copyleft/gpl.html |
11 // +----------------------------------------------------------------------+
12 // | getID3() - http://getid3.sourceforge.net or http://www.getid3.org |
13 // +----------------------------------------------------------------------+
14 // | Authors: James Heinrich <infoØgetid3*org> |
15 // | Allan Hansen <ahØartemis*dk> |
16 // +----------------------------------------------------------------------+
17 // | module.audio.tta.php |
18 // | Module for analyzing TTA Audio files |
19 // | dependencies: NONE |
20 // +----------------------------------------------------------------------+
21 //
22 // $Id: module.audio.tta.php,v 1.2 2006/11/02 10:48:01 ah Exp $
26 class getid3_tta extends getid3_handler
27 {
29 public function Analyze() {
31 $getid3 = $this->getid3;
33 $getid3->info['fileformat'] = 'tta';
34 $getid3->info['audio']['dataformat'] = 'tta';
35 $getid3->info['audio']['lossless'] = true;
36 $getid3->info['audio']['bitrate_mode'] = 'vbr';
38 fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
39 $tta_header = fread($getid3->fp, 26);
41 $getid3->info['tta']['magic'] = 'TTA'; // Magic bytes
43 switch ($tta_header{3}) {
45 case "\x01": // TTA v1.x
46 case "\x02": // TTA v1.x
47 case "\x03": // TTA v1.x
49 // "It was the demo-version of the TTA encoder. There is no released format with such header. TTA encoder v1 is not supported about a year."
50 $getid3->info['tta']['major_version'] = 1;
51 $getid3->info['avdataoffset'] += 16;
53 getid3_lib::ReadSequence('LittleEndian2Int', $getid3->info['tta'], $tta_header, 4,
54 array (
55 'channels' => 2,
56 'bits_per_sample' => 2,
57 'sample_rate' => 4,
58 'samples_per_channel' => 4
59 )
60 );
61 $getid3->info['tta']['compression_level'] = ord($tta_header{3});
63 $getid3->info['audio']['encoder_options'] = '-e'.$getid3->info['tta']['compression_level'];
64 $getid3->info['playtime_seconds'] = $getid3->info['tta']['samples_per_channel'] / $getid3->info['tta']['sample_rate'];
65 break;
67 case '2': // TTA v2.x
68 // "I have hurried to release the TTA 2.0 encoder. Format documentation is removed from our site. This format still in development. Please wait the TTA2 format, encoder v4."
69 $getid3->info['tta']['major_version'] = 2;
70 $getid3->info['avdataoffset'] += 20;
72 getid3_lib::ReadSequence('LittleEndian2Int', $getid3->info['tta'], $tta_header, 4,
73 array (
74 'compression_level' => 2,
75 'audio_format' => 2,
76 'channels' => 2,
77 'bits_per_sample' => 2,
78 'sample_rate' => 4,
79 'data_length' => 4
80 )
81 );
83 $getid3->info['audio']['encoder_options'] = '-e'.$getid3->info['tta']['compression_level'];
84 $getid3->info['playtime_seconds'] = $getid3->info['tta']['data_length'] / $getid3->info['tta']['sample_rate'];
85 break;
87 case '1': // TTA v3.x
88 // "This is a first stable release of the TTA format. It will be supported by the encoders v3 or higher."
89 $getid3->info['tta']['major_version'] = 3;
90 $getid3->info['avdataoffset'] += 26;
92 getid3_lib::ReadSequence('LittleEndian2Int', $getid3->info['tta'], $tta_header, 4,
93 array (
94 'audio_format' => 2,
95 'channels' => 2,
96 'bits_per_sample'=> 2,
97 'sample_rate' => 4,
98 'data_length' => 4,
99 'crc32_footer' => -4, // string
100 'seek_point' => 4
101 )
102 );
104 $getid3->info['playtime_seconds'] = $getid3->info['tta']['data_length'] / $getid3->info['tta']['sample_rate'];
105 break;
107 default:
108 throw new getid3_exception('This version of getID3() only knows how to handle TTA v1, v2 and v3 - it may not work correctly with this file which appears to be TTA v'.$tta_header{3});
109 return false;
110 break;
111 }
113 $getid3->info['audio']['encoder'] = 'TTA v'.$getid3->info['tta']['major_version'];
114 $getid3->info['audio']['bits_per_sample'] = $getid3->info['tta']['bits_per_sample'];
115 $getid3->info['audio']['sample_rate'] = $getid3->info['tta']['sample_rate'];
116 $getid3->info['audio']['channels'] = $getid3->info['tta']['channels'];
117 $getid3->info['audio']['bitrate'] = (($getid3->info['avdataend'] - $getid3->info['avdataoffset']) * 8) / $getid3->info['playtime_seconds'];
119 return true;
120 }
122 }
125 ?>