view e2gallerypro/e2upload/Backend/Assets/getid3/module.audio.au.php @ 28:118cb614cf18 judyates tip

judy bio.
author Robert McIntyre <rlm@mit.edu>
date Tue, 29 Dec 2015 16:26:18 -0800
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.au.php |
18 // | module for analyzing AU files |
19 // | dependencies: NONE |
20 // +----------------------------------------------------------------------+
21 //
22 // $Id: module.audio.au.php,v 1.2 2006/11/02 10:48:01 ah Exp $
26 class getid3_au extends getid3_handler
27 {
29 public function Analyze() {
31 $getid3 = $this->getid3;
33 fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
34 $au_header = fread($getid3->fp, 8);
36 // Magic bytes: .snd
38 $getid3->info['au'] = array ();
39 $info_au = &$getid3->info['au'];
41 $getid3->info['fileformat'] = 'au';
42 $getid3->info['audio']['dataformat'] = 'au';
43 $getid3->info['audio']['bitrate_mode'] = 'cbr';
44 $info_au['encoding'] = 'ISO-8859-1';
46 $info_au['header_length'] = getid3_lib::BigEndian2Int(substr($au_header, 4, 4));
47 $au_header .= fread($getid3->fp, $info_au['header_length'] - 8);
48 $getid3->info['avdataoffset'] += $info_au['header_length'];
50 getid3_lib::ReadSequence('BigEndian2Int', $info_au, $au_header, 8,
51 array (
52 'data_size' => 4,
53 'data_format_id'=> 4,
54 'sample_rate' => 4,
55 'channels' => 4
56 )
57 );
58 $info_au['comments']['comment'][] = trim(substr($au_header, 24));
60 $info_au['data_format'] = getid3_au::AUdataFormatNameLookup($info_au['data_format_id']);
61 $info_au['used_bits_per_sample'] = getid3_au::AUdataFormatUsedBitsPerSampleLookup($info_au['data_format_id']);
62 if ($info_au['bits_per_sample'] = getid3_au::AUdataFormatBitsPerSampleLookup($info_au['data_format_id'])) {
63 $getid3->info['audio']['bits_per_sample'] = $info_au['bits_per_sample'];
64 } else {
65 unset($info_au['bits_per_sample']);
66 }
68 $getid3->info['audio']['sample_rate'] = $info_au['sample_rate'];
69 $getid3->info['audio']['channels'] = $info_au['channels'];
71 if (($getid3->info['avdataoffset'] + $info_au['data_size']) > $getid3->info['avdataend']) {
72 $getid3->warning('Possible truncated file - expecting "'.$info_au['data_size'].'" bytes of audio data, only found '.($getid3->info['avdataend'] - $getid3->info['avdataoffset']).' bytes"');
73 }
75 $getid3->info['playtime_seconds'] = $info_au['data_size'] / ($info_au['sample_rate'] * $info_au['channels'] * ($info_au['used_bits_per_sample'] / 8));
76 $getid3->info['audio']['bitrate'] = ($info_au['data_size'] * 8) / $getid3->info['playtime_seconds'];
78 return true;
79 }
83 public static function AUdataFormatNameLookup($id) {
85 static $lookup = array (
86 0 => 'unspecified format',
87 1 => '8-bit mu-law',
88 2 => '8-bit linear',
89 3 => '16-bit linear',
90 4 => '24-bit linear',
91 5 => '32-bit linear',
92 6 => 'floating-point',
93 7 => 'double-precision float',
94 8 => 'fragmented sampled data',
95 9 => 'SUN_FORMAT_NESTED',
96 10 => 'DSP program',
97 11 => '8-bit fixed-point',
98 12 => '16-bit fixed-point',
99 13 => '24-bit fixed-point',
100 14 => '32-bit fixed-point',
102 16 => 'non-audio display data',
103 17 => 'SND_FORMAT_MULAW_SQUELCH',
104 18 => '16-bit linear with emphasis',
105 19 => '16-bit linear with compression',
106 20 => '16-bit linear with emphasis + compression',
107 21 => 'Music Kit DSP commands',
108 22 => 'SND_FORMAT_DSP_COMMANDS_SAMPLES',
109 23 => 'CCITT g.721 4-bit ADPCM',
110 24 => 'CCITT g.722 ADPCM',
111 25 => 'CCITT g.723 3-bit ADPCM',
112 26 => 'CCITT g.723 5-bit ADPCM',
113 27 => 'A-Law 8-bit'
114 );
116 return (isset($lookup[$id]) ? $lookup[$id] : false);
117 }
121 public static function AUdataFormatBitsPerSampleLookup($id) {
123 static $lookup = array (
124 1 => 8,
125 2 => 8,
126 3 => 16,
127 4 => 24,
128 5 => 32,
129 6 => 32,
130 7 => 64,
132 11 => 8,
133 12 => 16,
134 13 => 24,
135 14 => 32,
137 18 => 16,
138 19 => 16,
139 20 => 16,
141 23 => 16,
143 25 => 16,
144 26 => 16,
145 27 => 8
146 );
147 return (isset($lookup[$id]) ? $lookup[$id] : false);
148 }
152 public static function AUdataFormatUsedBitsPerSampleLookup($id) {
154 static $lookup = array (
155 1 => 8,
156 2 => 8,
157 3 => 16,
158 4 => 24,
159 5 => 32,
160 6 => 32,
161 7 => 64,
163 11 => 8,
164 12 => 16,
165 13 => 24,
166 14 => 32,
168 18 => 16,
169 19 => 16,
170 20 => 16,
172 23 => 4,
174 25 => 3,
175 26 => 5,
176 27 => 8,
177 );
178 return (isset($lookup[$id]) ? $lookup[$id] : false);
179 }
181 }
184 ?>