<Website>

getID3

PHK Home

File: /lib/module.audio.avr.php

Size:3515
Storage flags:strip

<?php
















class getid3_avr extends getid3_handler
{

public function 
Analyze() {
$info = &$this->getid3->info;


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 


 
 
 
 
 

$info['fileformat'] = 'avr';

$this->fseek($info['avdataoffset']);
$AVRheader $this->fread(128);

$info['avr']['raw']['magic'] = substr($AVRheader04);
$magic '2BIT';
if (
$info['avr']['raw']['magic'] != $magic) {
$info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes($magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($info['avr']['raw']['magic']).'"';
unset(
$info['fileformat']);
unset(
$info['avr']);
return 
false;
}
$info['avdataoffset'] += 128;

$info['avr']['sample_name'] = rtrim(substr($AVRheader48));
$info['avr']['raw']['mono'] = getid3_lib::BigEndian2Int(substr($AVRheader122));
$info['avr']['bits_per_sample'] = getid3_lib::BigEndian2Int(substr($AVRheader142));
$info['avr']['raw']['signed'] = getid3_lib::BigEndian2Int(substr($AVRheader162));
$info['avr']['raw']['loop'] = getid3_lib::BigEndian2Int(substr($AVRheader182));
$info['avr']['raw']['midi'] = getid3_lib::BigEndian2Int(substr($AVRheader202));
$info['avr']['raw']['replay_freq'] = getid3_lib::BigEndian2Int(substr($AVRheader221));
$info['avr']['sample_rate'] = getid3_lib::BigEndian2Int(substr($AVRheader233));
$info['avr']['sample_length'] = getid3_lib::BigEndian2Int(substr($AVRheader264));
$info['avr']['loop_start'] = getid3_lib::BigEndian2Int(substr($AVRheader304));
$info['avr']['loop_end'] = getid3_lib::BigEndian2Int(substr($AVRheader344));
$info['avr']['midi_split'] = getid3_lib::BigEndian2Int(substr($AVRheader382));
$info['avr']['sample_compression'] = getid3_lib::BigEndian2Int(substr($AVRheader402));
$info['avr']['reserved'] = getid3_lib::BigEndian2Int(substr($AVRheader422));
$info['avr']['sample_name_extra'] = rtrim(substr($AVRheader4420));
$info['avr']['comment'] = rtrim(substr($AVRheader6464));

$info['avr']['flags']['stereo'] = (($info['avr']['raw']['mono'] == 0) ? false true);
$info['avr']['flags']['signed'] = (($info['avr']['raw']['signed'] == 0) ? false true);
$info['avr']['flags']['loop'] = (($info['avr']['raw']['loop'] == 0) ? false true);

$info['avr']['midi_notes'] = array();
if ((
$info['avr']['raw']['midi'] & 0xFF00) != 0xFF00) {
$info['avr']['midi_notes'][] = ($info['avr']['raw']['midi'] & 0xFF00) >> 8;
}
if ((
$info['avr']['raw']['midi'] & 0x00FF) != 0x00FF) {
$info['avr']['midi_notes'][] = ($info['avr']['raw']['midi'] & 0x00FF);
}

if ((
$info['avdataend'] - $info['avdataoffset']) != ($info['avr']['sample_length'] * (($info['avr']['bits_per_sample'] == 8) ? 2))) {
$info['warning'][] = 'Probable truncated file: expecting '.($info['avr']['sample_length'] * (($info['avr']['bits_per_sample'] == 8) ? 2)).' bytes of audio data, found '.($info['avdataend'] - $info['avdataoffset']);
}

$info['audio']['dataformat'] = 'avr';
$info['audio']['lossless'] = true;
$info['audio']['bitrate_mode'] = 'cbr';
$info['audio']['bits_per_sample'] = $info['avr']['bits_per_sample'];
$info['audio']['sample_rate'] = $info['avr']['sample_rate'];
$info['audio']['channels'] = ($info['avr']['flags']['stereo'] ? 1);
$info['playtime_seconds'] = ($info['avr']['sample_length'] / $info['audio']['channels']) / $info['avr']['sample_rate'];
$info['audio']['bitrate'] = ($info['avr']['sample_length'] * (($info['avr']['bits_per_sample'] == 8) ? 16)) / $info['playtime_seconds'];


return 
true;
}

}

For more information about the PHK package format: http://phk.tekwire.net