62 $ThisFileInfo[
'fileformat'] =
'avr';
64 fseek($fd, $ThisFileInfo[
'avdataoffset'], SEEK_SET);
65 $AVRheader = fread($fd, 128);
67 $ThisFileInfo[
'avr'][
'raw'][
'magic'] = substr($AVRheader, 0, 4);
68 if ($ThisFileInfo[
'avr'][
'raw'][
'magic'] !=
'2BIT') {
69 $ThisFileInfo[
'error'][] =
'Expecting "2BIT" at offset '.$ThisFileInfo[
'avdataoffset'].
', found "'.$ThisFileInfo[
'avr'][
'raw'][
'magic'].
'"';
70 unset($ThisFileInfo[
'fileformat']);
71 unset($ThisFileInfo[
'avr']);
74 $ThisFileInfo[
'avdataoffset'] += 128;
76 $ThisFileInfo[
'avr'][
'sample_name'] = rtrim(substr($AVRheader, 4, 8));
90 $ThisFileInfo[
'avr'][
'sample_name_extra'] = rtrim(substr($AVRheader, 44, 20));
91 $ThisFileInfo[
'avr'][
'comment'] = rtrim(substr($AVRheader, 64, 64));
93 $ThisFileInfo[
'avr'][
'flags'][
'stereo'] = (($ThisFileInfo[
'avr'][
'raw'][
'mono'] == 0) ?
false :
true);
94 $ThisFileInfo[
'avr'][
'flags'][
'signed'] = (($ThisFileInfo[
'avr'][
'raw'][
'signed'] == 0) ?
false :
true);
95 $ThisFileInfo[
'avr'][
'flags'][
'loop'] = (($ThisFileInfo[
'avr'][
'raw'][
'loop'] == 0) ?
false :
true);
97 $ThisFileInfo[
'avr'][
'midi_notes'] = array();
98 if (($ThisFileInfo[
'avr'][
'raw'][
'midi'] & 0xFF00) != 0xFF00) {
99 $ThisFileInfo[
'avr'][
'midi_notes'][] = ($ThisFileInfo[
'avr'][
'raw'][
'midi'] & 0xFF00) >> 8;
101 if (($ThisFileInfo[
'avr'][
'raw'][
'midi'] & 0x00FF) != 0x00FF) {
102 $ThisFileInfo[
'avr'][
'midi_notes'][] = ($ThisFileInfo[
'avr'][
'raw'][
'midi'] & 0x00FF);
105 if (($ThisFileInfo[
'avdataend'] - $ThisFileInfo[
'avdataoffset']) != ($ThisFileInfo[
'avr'][
'sample_length'] * (($ThisFileInfo[
'avr'][
'bits_per_sample'] == 8) ? 1 : 2))) {
106 $ThisFileInfo[
'warning'][] =
'Probable truncated file: expecting '.($ThisFileInfo[
'avr'][
'sample_length'] * (($ThisFileInfo[
'avr'][
'bits_per_sample'] == 8) ? 1 : 2)).
' bytes of audio data, found '.($ThisFileInfo[
'avdataend'] - $ThisFileInfo[
'avdataoffset']);
109 $ThisFileInfo[
'audio'][
'dataformat'] =
'avr';
110 $ThisFileInfo[
'audio'][
'lossless'] =
true;
111 $ThisFileInfo[
'audio'][
'bitrate_mode'] =
'cbr';
112 $ThisFileInfo[
'audio'][
'bits_per_sample'] = $ThisFileInfo[
'avr'][
'bits_per_sample'];
113 $ThisFileInfo[
'audio'][
'sample_rate'] = $ThisFileInfo[
'avr'][
'sample_rate'];
114 $ThisFileInfo[
'audio'][
'channels'] = ($ThisFileInfo[
'avr'][
'flags'][
'stereo'] ? 2 : 1);
115 $ThisFileInfo[
'playtime_seconds'] = ($ThisFileInfo[
'avr'][
'sample_length'] / $ThisFileInfo[
'audio'][
'channels']) / $ThisFileInfo[
'avr'][
'sample_rate'];
116 $ThisFileInfo[
'audio'][
'bitrate'] = ($ThisFileInfo[
'avr'][
'sample_length'] * (($ThisFileInfo[
'avr'][
'bits_per_sample'] == 8) ? 8 : 16)) / $ThisFileInfo[
'playtime_seconds'];