ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
GetId3\Module\Audio\Au Class Reference

GetId3() by James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g //. More...

+ Inheritance diagram for GetId3\Module\Audio\Au:
+ Collaboration diagram for GetId3\Module\Audio\Au:

Public Member Functions

 analyze ()
 
 AUdataFormatNameLookup ($id)
 @staticvar array $AUdataFormatNameLookup More...
 
 AUdataFormatBitsPerSampleLookup ($id)
 @staticvar array $AUdataFormatBitsPerSampleLookup More...
 
 AUdataFormatUsedBitsPerSampleLookup ($id)
 @staticvar array $AUdataFormatUsedBitsPerSampleLookup More...
 
- Public Member Functions inherited from GetId3\Handler\BaseHandler
 __construct (GetId3Core $getid3, $call_module=null)
 
 analyze ()
 Analyze from file pointer. More...
 
 AnalyzeString (&$string)
 Analyze from string instead. More...
 
 saveAttachment (&$ThisFileInfoIndex, $filename, $offset, $length)
 

Additional Inherited Members

- Protected Member Functions inherited from GetId3\Handler\BaseHandler
 ftell ()
 
 fread ($bytes)
 
 fseek ($bytes, $whence=SEEK_SET)
 
 feof ()
 
 isDependencyFor ($module)
 
 error ($text)
 
 warning ($text)
 
- Protected Attributes inherited from GetId3\Handler\BaseHandler
 $getid3
 
 $data_string_flag = false
 
 $data_string = ''
 
 $data_string_position = 0
 
 $data_string_length = 0
 

Detailed Description

GetId3() by James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g //.

module for analyzing AU files

Author
James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g http://www.getid3.org

Definition at line 29 of file Au.php.

Member Function Documentation

◆ analyze()

GetId3\Module\Audio\Au::analyze ( )
Returns
boolean

Reimplemented from GetId3\Handler\BaseHandler.

Definition at line 36 of file Au.php.

37 {
38 $info = &$this->getid3->info;
39
40 fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
41 $AUheader = fread($this->getid3->fp, 8);
42
43 $magic = '.snd';
44 if (substr($AUheader, 0, 4) != $magic) {
45 $info['error'][] = 'Expecting "'.Helper::PrintHexBytes($magic).'" (".snd") at offset '.$info['avdataoffset'].', found "'.Helper::PrintHexBytes(substr($AUheader, 0, 4)).'"';
46
47 return false;
48 }
49
50 // shortcut
51 $info['au'] = array();
52 $thisfile_au = &$info['au'];
53
54 $info['fileformat'] = 'au';
55 $info['audio']['dataformat'] = 'au';
56 $info['audio']['bitrate_mode'] = 'cbr';
57 $thisfile_au['encoding'] = 'ISO-8859-1';
58
59 $thisfile_au['header_length'] = Helper::BigEndian2Int(substr($AUheader, 4, 4));
60 $AUheader .= fread($this->getid3->fp, $thisfile_au['header_length'] - 8);
61 $info['avdataoffset'] += $thisfile_au['header_length'];
62
63 $thisfile_au['data_size'] = Helper::BigEndian2Int(substr($AUheader, 8, 4));
64 $thisfile_au['data_format_id'] = Helper::BigEndian2Int(substr($AUheader, 12, 4));
65 $thisfile_au['sample_rate'] = Helper::BigEndian2Int(substr($AUheader, 16, 4));
66 $thisfile_au['channels'] = Helper::BigEndian2Int(substr($AUheader, 20, 4));
67 $thisfile_au['comments']['comment'][] = trim(substr($AUheader, 24));
68
69 $thisfile_au['data_format'] = $this->AUdataFormatNameLookup($thisfile_au['data_format_id']);
70 $thisfile_au['used_bits_per_sample'] = $this->AUdataFormatUsedBitsPerSampleLookup($thisfile_au['data_format_id']);
71 if ($thisfile_au['bits_per_sample'] = $this->AUdataFormatBitsPerSampleLookup($thisfile_au['data_format_id'])) {
72 $info['audio']['bits_per_sample'] = $thisfile_au['bits_per_sample'];
73 } else {
74 unset($thisfile_au['bits_per_sample']);
75 }
76
77 $info['audio']['sample_rate'] = $thisfile_au['sample_rate'];
78 $info['audio']['channels'] = $thisfile_au['channels'];
79
80 if (($info['avdataoffset'] + $thisfile_au['data_size']) > $info['avdataend']) {
81 $info['warning'][] = 'Possible truncated file - expecting "'.$thisfile_au['data_size'].'" bytes of audio data, only found '.($info['avdataend'] - $info['avdataoffset']).' bytes"';
82 }
83
84 $info['playtime_seconds'] = $thisfile_au['data_size'] / ($thisfile_au['sample_rate'] * $thisfile_au['channels'] * ($thisfile_au['used_bits_per_sample'] / 8));
85 $info['audio']['bitrate'] = ($thisfile_au['data_size'] * 8) / $info['playtime_seconds'];
86
87 return true;
88 }
fseek($bytes, $whence=SEEK_SET)
static BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: Helper.php:374
static PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8')
Definition: Helper.php:36
AUdataFormatUsedBitsPerSampleLookup($id)
@staticvar array $AUdataFormatUsedBitsPerSampleLookup
Definition: Au.php:174
AUdataFormatNameLookup($id)
@staticvar array $AUdataFormatNameLookup
Definition: Au.php:96
AUdataFormatBitsPerSampleLookup($id)
@staticvar array $AUdataFormatBitsPerSampleLookup
Definition: Au.php:138
$info
Definition: example_052.php:80

References $info, GetId3\Module\Audio\Au\AUdataFormatBitsPerSampleLookup(), GetId3\Module\Audio\Au\AUdataFormatNameLookup(), GetId3\Module\Audio\Au\AUdataFormatUsedBitsPerSampleLookup(), GetId3\Lib\Helper\BigEndian2Int(), GetId3\Handler\BaseHandler\fread(), GetId3\Handler\BaseHandler\fseek(), and GetId3\Lib\Helper\PrintHexBytes().

+ Here is the call graph for this function:

◆ AUdataFormatBitsPerSampleLookup()

GetId3\Module\Audio\Au::AUdataFormatBitsPerSampleLookup (   $id)

@staticvar array $AUdataFormatBitsPerSampleLookup

Parameters
type$id
Returns
type

Definition at line 138 of file Au.php.

139 {
140 static $AUdataFormatBitsPerSampleLookup = array(
141 1 => 8,
142 2 => 8,
143 3 => 16,
144 4 => 24,
145 5 => 32,
146 6 => 32,
147 7 => 64,
148
149 11 => 8,
150 12 => 16,
151 13 => 24,
152 14 => 32,
153
154 18 => 16,
155 19 => 16,
156 20 => 16,
157
158 23 => 16,
159
160 25 => 16,
161 26 => 16,
162 27 => 8
163 );
164
165 return (isset($AUdataFormatBitsPerSampleLookup[$id]) ? $AUdataFormatBitsPerSampleLookup[$id] : false);
166 }

Referenced by GetId3\Module\Audio\Au\analyze().

+ Here is the caller graph for this function:

◆ AUdataFormatNameLookup()

GetId3\Module\Audio\Au::AUdataFormatNameLookup (   $id)

@staticvar array $AUdataFormatNameLookup

Parameters
type$id
Returns
type

Definition at line 96 of file Au.php.

97 {
98 static $AUdataFormatNameLookup = array(
99 0 => 'unspecified format',
100 1 => '8-bit mu-law',
101 2 => '8-bit linear',
102 3 => '16-bit linear',
103 4 => '24-bit linear',
104 5 => '32-bit linear',
105 6 => 'floating-point',
106 7 => 'double-precision float',
107 8 => 'fragmented sampled data',
108 9 => 'SUN_FORMAT_NESTED',
109 10 => 'DSP program',
110 11 => '8-bit fixed-point',
111 12 => '16-bit fixed-point',
112 13 => '24-bit fixed-point',
113 14 => '32-bit fixed-point',
114
115 16 => 'non-audio display data',
116 17 => 'SND_FORMAT_MULAW_SQUELCH',
117 18 => '16-bit linear with emphasis',
118 19 => '16-bit linear with compression',
119 20 => '16-bit linear with emphasis + compression',
120 21 => 'Music Kit DSP commands',
121 22 => 'SND_FORMAT_DSP_COMMANDS_SAMPLES',
122 23 => 'CCITT g.721 4-bit ADPCM',
123 24 => 'CCITT g.722 ADPCM',
124 25 => 'CCITT g.723 3-bit ADPCM',
125 26 => 'CCITT g.723 5-bit ADPCM',
126 27 => 'A-Law 8-bit'
127 );
128
129 return (isset($AUdataFormatNameLookup[$id]) ? $AUdataFormatNameLookup[$id] : false);
130 }

Referenced by GetId3\Module\Audio\Au\analyze().

+ Here is the caller graph for this function:

◆ AUdataFormatUsedBitsPerSampleLookup()

GetId3\Module\Audio\Au::AUdataFormatUsedBitsPerSampleLookup (   $id)

@staticvar array $AUdataFormatUsedBitsPerSampleLookup

Parameters
type$id
Returns
type

Definition at line 174 of file Au.php.

175 {
176 static $AUdataFormatUsedBitsPerSampleLookup = array(
177 1 => 8,
178 2 => 8,
179 3 => 16,
180 4 => 24,
181 5 => 32,
182 6 => 32,
183 7 => 64,
184
185 11 => 8,
186 12 => 16,
187 13 => 24,
188 14 => 32,
189
190 18 => 16,
191 19 => 16,
192 20 => 16,
193
194 23 => 4,
195
196 25 => 3,
197 26 => 5,
198 27 => 8,
199 );
200
201 return (isset($AUdataFormatUsedBitsPerSampleLookup[$id]) ? $AUdataFormatUsedBitsPerSampleLookup[$id] : false);
202 }

Referenced by GetId3\Module\Audio\Au\analyze().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: