ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
getid3_au Class Reference

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

+ Inheritance diagram for getid3_au:
+ Collaboration diagram for getid3_au:

Public Member Functions

 getid3_au (&$fd, &$ThisFileInfo)
 
 AUdataFormatNameLookup ($id)
 
 AUdataFormatBitsPerSampleLookup ($id)
 
 AUdataFormatUsedBitsPerSampleLookup ($id)
 
 Analyze ()
 
 AUdataFormatNameLookup ($id)
 
 AUdataFormatBitsPerSampleLookup ($id)
 
 AUdataFormatUsedBitsPerSampleLookup ($id)
 
- Public Member Functions inherited from getid3_handler
 __construct (getID3 $getid3, $call_module=null)
 
 Analyze ()
 
 AnalyzeString ($string)
 
 setStringMode ($string)
 
 saveAttachment ($name, $offset, $length, $image_mime=null)
 

Additional Inherited Members

- Protected Member Functions inherited from getid3_handler
 ftell ()
 
 fread ($bytes)
 
 fseek ($bytes, $whence=SEEK_SET)
 
 feof ()
 
 isDependencyFor ($module)
 
 error ($text)
 
 warning ($text)
 
 notice ($text)
 
- Protected Attributes inherited from getid3_handler
 $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 //

Definition at line 17 of file module.audio.au.php.

Member Function Documentation

◆ Analyze()

getid3_au::Analyze ( )

Definition at line 21 of file module.audio.au.php.

References $info, AUdataFormatBitsPerSampleLookup(), AUdataFormatNameLookup(), AUdataFormatUsedBitsPerSampleLookup(), getid3_lib\BigEndian2Int(), getid3_handler\fread(), getid3_handler\fseek(), and getid3_lib\PrintHexBytes().

21  {
22  $info = &$this->getid3->info;
23 
24  $this->fseek($info['avdataoffset']);
25  $AUheader = $this->fread(8);
26 
27  $magic = '.snd';
28  if (substr($AUheader, 0, 4) != $magic) {
29  $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes($magic).'" (".snd") at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes(substr($AUheader, 0, 4)).'"';
30  return false;
31  }
32 
33  // shortcut
34  $info['au'] = array();
35  $thisfile_au = &$info['au'];
36 
37  $info['fileformat'] = 'au';
38  $info['audio']['dataformat'] = 'au';
39  $info['audio']['bitrate_mode'] = 'cbr';
40  $thisfile_au['encoding'] = 'ISO-8859-1';
41 
42  $thisfile_au['header_length'] = getid3_lib::BigEndian2Int(substr($AUheader, 4, 4));
43  $AUheader .= $this->fread($thisfile_au['header_length'] - 8);
44  $info['avdataoffset'] += $thisfile_au['header_length'];
45 
46  $thisfile_au['data_size'] = getid3_lib::BigEndian2Int(substr($AUheader, 8, 4));
47  $thisfile_au['data_format_id'] = getid3_lib::BigEndian2Int(substr($AUheader, 12, 4));
48  $thisfile_au['sample_rate'] = getid3_lib::BigEndian2Int(substr($AUheader, 16, 4));
49  $thisfile_au['channels'] = getid3_lib::BigEndian2Int(substr($AUheader, 20, 4));
50  $thisfile_au['comments']['comment'][] = trim(substr($AUheader, 24));
51 
52  $thisfile_au['data_format'] = $this->AUdataFormatNameLookup($thisfile_au['data_format_id']);
53  $thisfile_au['used_bits_per_sample'] = $this->AUdataFormatUsedBitsPerSampleLookup($thisfile_au['data_format_id']);
54  if ($thisfile_au['bits_per_sample'] = $this->AUdataFormatBitsPerSampleLookup($thisfile_au['data_format_id'])) {
55  $info['audio']['bits_per_sample'] = $thisfile_au['bits_per_sample'];
56  } else {
57  unset($thisfile_au['bits_per_sample']);
58  }
59 
60  $info['audio']['sample_rate'] = $thisfile_au['sample_rate'];
61  $info['audio']['channels'] = $thisfile_au['channels'];
62 
63  if (($info['avdataoffset'] + $thisfile_au['data_size']) > $info['avdataend']) {
64  $info['warning'][] = 'Possible truncated file - expecting "'.$thisfile_au['data_size'].'" bytes of audio data, only found '.($info['avdataend'] - $info['avdataoffset']).' bytes"';
65  }
66 
67  $info['playtime_seconds'] = $thisfile_au['data_size'] / ($thisfile_au['sample_rate'] * $thisfile_au['channels'] * ($thisfile_au['used_bits_per_sample'] / 8));
68  $info['audio']['bitrate'] = ($thisfile_au['data_size'] * 8) / $info['playtime_seconds'];
69 
70  return true;
71  }
AUdataFormatBitsPerSampleLookup($id)
AUdataFormatNameLookup($id)
$info
Definition: example_052.php:80
fread($bytes)
Definition: getid3.php:1685
BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: getid3.lib.php:234
AUdataFormatUsedBitsPerSampleLookup($id)
fseek($bytes, $whence=SEEK_SET)
Definition: getid3.php:1697
PrintHexBytes($string, $hex=true, $spaces=true, $htmlsafe=true)
Definition: getid3.lib.php:17
+ Here is the call graph for this function:

◆ AUdataFormatBitsPerSampleLookup() [1/2]

getid3_au::AUdataFormatBitsPerSampleLookup (   $id)

Definition at line 104 of file module.audio.au.php.

Referenced by Analyze(), and getid3_au().

104  {
105  static $AUdataFormatBitsPerSampleLookup = array(
106  1 => 8,
107  2 => 8,
108  3 => 16,
109  4 => 24,
110  5 => 32,
111  6 => 32,
112  7 => 64,
113 
114  11 => 8,
115  12 => 16,
116  13 => 24,
117  14 => 32,
118 
119  18 => 16,
120  19 => 16,
121  20 => 16,
122 
123  23 => 16,
124 
125  25 => 16,
126  26 => 16,
127  27 => 8
128  );
129  return (isset($AUdataFormatBitsPerSampleLookup[$id]) ? $AUdataFormatBitsPerSampleLookup[$id] : false);
130  }
+ Here is the caller graph for this function:

◆ AUdataFormatBitsPerSampleLookup() [2/2]

getid3_au::AUdataFormatBitsPerSampleLookup (   $id)

Definition at line 107 of file module.audio.au.php.

107  {
108  static $AUdataFormatBitsPerSampleLookup = array(
109  1 => 8,
110  2 => 8,
111  3 => 16,
112  4 => 24,
113  5 => 32,
114  6 => 32,
115  7 => 64,
116 
117  11 => 8,
118  12 => 16,
119  13 => 24,
120  14 => 32,
121 
122  18 => 16,
123  19 => 16,
124  20 => 16,
125 
126  23 => 16,
127 
128  25 => 16,
129  26 => 16,
130  27 => 8
131  );
132  return (isset($AUdataFormatBitsPerSampleLookup[$id]) ? $AUdataFormatBitsPerSampleLookup[$id] : false);
133  }

◆ AUdataFormatNameLookup() [1/2]

getid3_au::AUdataFormatNameLookup (   $id)

Definition at line 70 of file module.audio.au.php.

Referenced by Analyze(), and getid3_au().

70  {
71  static $AUdataFormatNameLookup = array(
72  0 => 'unspecified format',
73  1 => '8-bit mu-law',
74  2 => '8-bit linear',
75  3 => '16-bit linear',
76  4 => '24-bit linear',
77  5 => '32-bit linear',
78  6 => 'floating-point',
79  7 => 'double-precision float',
80  8 => 'fragmented sampled data',
81  9 => 'SUN_FORMAT_NESTED',
82  10 => 'DSP program',
83  11 => '8-bit fixed-point',
84  12 => '16-bit fixed-point',
85  13 => '24-bit fixed-point',
86  14 => '32-bit fixed-point',
87 
88  16 => 'non-audio display data',
89  17 => 'SND_FORMAT_MULAW_SQUELCH',
90  18 => '16-bit linear with emphasis',
91  19 => '16-bit linear with compression',
92  20 => '16-bit linear with emphasis + compression',
93  21 => 'Music Kit DSP commands',
94  22 => 'SND_FORMAT_DSP_COMMANDS_SAMPLES',
95  23 => 'CCITT g.721 4-bit ADPCM',
96  24 => 'CCITT g.722 ADPCM',
97  25 => 'CCITT g.723 3-bit ADPCM',
98  26 => 'CCITT g.723 5-bit ADPCM',
99  27 => 'A-Law 8-bit'
100  );
101  return (isset($AUdataFormatNameLookup[$id]) ? $AUdataFormatNameLookup[$id] : false);
102  }
+ Here is the caller graph for this function:

◆ AUdataFormatNameLookup() [2/2]

getid3_au::AUdataFormatNameLookup (   $id)

Definition at line 73 of file module.audio.au.php.

73  {
74  static $AUdataFormatNameLookup = array(
75  0 => 'unspecified format',
76  1 => '8-bit mu-law',
77  2 => '8-bit linear',
78  3 => '16-bit linear',
79  4 => '24-bit linear',
80  5 => '32-bit linear',
81  6 => 'floating-point',
82  7 => 'double-precision float',
83  8 => 'fragmented sampled data',
84  9 => 'SUN_FORMAT_NESTED',
85  10 => 'DSP program',
86  11 => '8-bit fixed-point',
87  12 => '16-bit fixed-point',
88  13 => '24-bit fixed-point',
89  14 => '32-bit fixed-point',
90 
91  16 => 'non-audio display data',
92  17 => 'SND_FORMAT_MULAW_SQUELCH',
93  18 => '16-bit linear with emphasis',
94  19 => '16-bit linear with compression',
95  20 => '16-bit linear with emphasis + compression',
96  21 => 'Music Kit DSP commands',
97  22 => 'SND_FORMAT_DSP_COMMANDS_SAMPLES',
98  23 => 'CCITT g.721 4-bit ADPCM',
99  24 => 'CCITT g.722 ADPCM',
100  25 => 'CCITT g.723 3-bit ADPCM',
101  26 => 'CCITT g.723 5-bit ADPCM',
102  27 => 'A-Law 8-bit'
103  );
104  return (isset($AUdataFormatNameLookup[$id]) ? $AUdataFormatNameLookup[$id] : false);
105  }

◆ AUdataFormatUsedBitsPerSampleLookup() [1/2]

getid3_au::AUdataFormatUsedBitsPerSampleLookup (   $id)

Definition at line 132 of file module.audio.au.php.

Referenced by Analyze(), and getid3_au().

132  {
133  static $AUdataFormatUsedBitsPerSampleLookup = array(
134  1 => 8,
135  2 => 8,
136  3 => 16,
137  4 => 24,
138  5 => 32,
139  6 => 32,
140  7 => 64,
141 
142  11 => 8,
143  12 => 16,
144  13 => 24,
145  14 => 32,
146 
147  18 => 16,
148  19 => 16,
149  20 => 16,
150 
151  23 => 4,
152 
153  25 => 3,
154  26 => 5,
155  27 => 8,
156  );
157  return (isset($AUdataFormatUsedBitsPerSampleLookup[$id]) ? $AUdataFormatUsedBitsPerSampleLookup[$id] : false);
158  }
+ Here is the caller graph for this function:

◆ AUdataFormatUsedBitsPerSampleLookup() [2/2]

getid3_au::AUdataFormatUsedBitsPerSampleLookup (   $id)

Definition at line 135 of file module.audio.au.php.

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

◆ getid3_au()

getid3_au::getid3_au ( $fd,
$ThisFileInfo 
)

Definition at line 20 of file module.audio.au.php.

References AUdataFormatBitsPerSampleLookup(), AUdataFormatNameLookup(), AUdataFormatUsedBitsPerSampleLookup(), getid3_lib\BigEndian2Int(), getid3_handler\fread(), and getid3_handler\fseek().

20  {
21 
22  fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
23  $AUheader = fread($fd, 8);
24 
25  if (substr($AUheader, 0, 4) != '.snd') {
26  $ThisFileInfo['error'][] = 'Expecting ".snd" at offset '.$ThisFileInfo['avdataoffset'].', found "'.substr($AUheader, 0, 4).'"';
27  return false;
28  }
29 
30  // shortcut
31  $ThisFileInfo['au'] = array();
32  $thisfile_au = &$ThisFileInfo['au'];
33 
34  $ThisFileInfo['fileformat'] = 'au';
35  $ThisFileInfo['audio']['dataformat'] = 'au';
36  $ThisFileInfo['audio']['bitrate_mode'] = 'cbr';
37  $thisfile_au['encoding'] = 'ISO-8859-1';
38 
39  $thisfile_au['header_length'] = getid3_lib::BigEndian2Int(substr($AUheader, 4, 4));
40  $AUheader .= fread($fd, $thisfile_au['header_length'] - 8);
41  $ThisFileInfo['avdataoffset'] += $thisfile_au['header_length'];
42 
43  $thisfile_au['data_size'] = getid3_lib::BigEndian2Int(substr($AUheader, 8, 4));
44  $thisfile_au['data_format_id'] = getid3_lib::BigEndian2Int(substr($AUheader, 12, 4));
45  $thisfile_au['sample_rate'] = getid3_lib::BigEndian2Int(substr($AUheader, 16, 4));
46  $thisfile_au['channels'] = getid3_lib::BigEndian2Int(substr($AUheader, 20, 4));
47  $thisfile_au['comments']['comment'][] = trim(substr($AUheader, 24));
48 
49  $thisfile_au['data_format'] = $this->AUdataFormatNameLookup($thisfile_au['data_format_id']);
50  $thisfile_au['used_bits_per_sample'] = $this->AUdataFormatUsedBitsPerSampleLookup($thisfile_au['data_format_id']);
51  if ($thisfile_au['bits_per_sample'] = $this->AUdataFormatBitsPerSampleLookup($thisfile_au['data_format_id'])) {
52  $ThisFileInfo['audio']['bits_per_sample'] = $thisfile_au['bits_per_sample'];
53  } else {
54  unset($thisfile_au['bits_per_sample']);
55  }
56 
57  $ThisFileInfo['audio']['sample_rate'] = $thisfile_au['sample_rate'];
58  $ThisFileInfo['audio']['channels'] = $thisfile_au['channels'];
59 
60  if (($ThisFileInfo['avdataoffset'] + $thisfile_au['data_size']) > $ThisFileInfo['avdataend']) {
61  $ThisFileInfo['warning'][] = 'Possible truncated file - expecting "'.$thisfile_au['data_size'].'" bytes of audio data, only found '.($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']).' bytes"';
62  }
63 
64  $ThisFileInfo['playtime_seconds'] = $thisfile_au['data_size'] / ($thisfile_au['sample_rate'] * $thisfile_au['channels'] * ($thisfile_au['used_bits_per_sample'] / 8));
65  $ThisFileInfo['audio']['bitrate'] = ($thisfile_au['data_size'] * 8) / $ThisFileInfo['playtime_seconds'];
66 
67  return true;
68  }
AUdataFormatBitsPerSampleLookup($id)
AUdataFormatNameLookup($id)
fread($bytes)
Definition: getid3.php:1685
BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: getid3.lib.php:234
AUdataFormatUsedBitsPerSampleLookup($id)
fseek($bytes, $whence=SEEK_SET)
Definition: getid3.php:1697
+ Here is the call graph for this function:

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