Mercurial > judyates
diff e2gallerypro/e2upload/Backend/Assets/getid3/module.audio.avr.php @ 3:3f6b44aa6b35 judyates
[svn r4] added ability to buy stuff, from a Prints page, but it doesn't work well with the css, and it also has not been fitted into the perl make system.
author | rlm |
---|---|
date | Mon, 22 Feb 2010 08:02:39 -0500 |
parents | |
children |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/e2gallerypro/e2upload/Backend/Assets/getid3/module.audio.avr.php Mon Feb 22 08:02:39 2010 -0500 1.3 @@ -0,0 +1,135 @@ 1.4 +<?php 1.5 +// +----------------------------------------------------------------------+ 1.6 +// | PHP version 5 | 1.7 +// +----------------------------------------------------------------------+ 1.8 +// | Copyright (c) 2002-2006 James Heinrich, Allan Hansen | 1.9 +// +----------------------------------------------------------------------+ 1.10 +// | This source file is subject to version 2 of the GPL license, | 1.11 +// | that is bundled with this package in the file license.txt and is | 1.12 +// | available through the world-wide-web at the following url: | 1.13 +// | http://www.gnu.org/copyleft/gpl.html | 1.14 +// +----------------------------------------------------------------------+ 1.15 +// | getID3() - http://getid3.sourceforge.net or http://www.getid3.org | 1.16 +// +----------------------------------------------------------------------+ 1.17 +// | Authors: James Heinrich <infoØgetid3*org> | 1.18 +// | Allan Hansen <ahØartemis*dk> | 1.19 +// +----------------------------------------------------------------------+ 1.20 +// | module.audio.avr.php | 1.21 +// | Module for analyzing AVR audio files | 1.22 +// | dependencies: NONE | 1.23 +// +----------------------------------------------------------------------+ 1.24 +// 1.25 +// $Id: module.audio.avr.php,v 1.2 2006/11/02 10:48:01 ah Exp $ 1.26 + 1.27 + 1.28 + 1.29 +class getid3_avr extends getid3_handler 1.30 +{ 1.31 + 1.32 + public function Analyze() { 1.33 + 1.34 + $getid3 = $this->getid3; 1.35 + 1.36 + // http://cui.unige.ch/OSG/info/AudioFormats/ap11.html 1.37 + // http://www.btinternet.com/~AnthonyJ/Atari/programming/avr_format.html 1.38 + // offset type length name comments 1.39 + // --------------------------------------------------------------------- 1.40 + // 0 char 4 ID format ID == "2BIT" 1.41 + // 4 char 8 name sample name (unused space filled with 0) 1.42 + // 12 short 1 mono/stereo 0=mono, -1 (0xFFFF)=stereo 1.43 + // With stereo, samples are alternated, 1.44 + // the first voice is the left : 1.45 + // (LRLRLRLRLRLRLRLRLR...) 1.46 + // 14 short 1 resolution 8, 12 or 16 (bits) 1.47 + // 16 short 1 signed or not 0=unsigned, -1 (0xFFFF)=signed 1.48 + // 18 short 1 loop or not 0=no loop, -1 (0xFFFF)=loop on 1.49 + // 20 short 1 MIDI note 0xFFnn, where 0 <= nn <= 127 1.50 + // 0xFFFF means "no MIDI note defined" 1.51 + // 22 byte 1 Replay speed Frequence in the Replay software 1.52 + // 0=5.485 Khz, 1=8.084 Khz, 2=10.971 Khz, 1.53 + // 3=16.168 Khz, 4=21.942 Khz, 5=32.336 Khz 1.54 + // 6=43.885 Khz, 7=47.261 Khz 1.55 + // -1 (0xFF)=no defined Frequence 1.56 + // 23 byte 3 sample rate in Hertz 1.57 + // 26 long 1 size in bytes (2 * bytes in stereo) 1.58 + // 30 long 1 loop begin 0 for no loop 1.59 + // 34 long 1 loop size equal to 'size' for no loop 1.60 + // 38 short 2 Reserved, MIDI keyboard split */ 1.61 + // 40 short 2 Reserved, sample compression */ 1.62 + // 42 short 2 Reserved */ 1.63 + // 44 char 20; Additional filename space, used if (name[7] != 0) 1.64 + // 64 byte 64 user data 1.65 + // 128 bytes ? sample data (12 bits samples are coded on 16 bits: 1.66 + // 0000 xxxx xxxx xxxx) 1.67 + // --------------------------------------------------------------------- 1.68 + 1.69 + // Note that all values are in motorola (big-endian) format, and that long is 1.70 + // assumed to be 4 bytes, and short 2 bytes. 1.71 + // When reading the samples, you should handle both signed and unsigned data, 1.72 + // and be prepared to convert 16->8 bit, or mono->stereo if needed. To convert 1.73 + // 8-bit data between signed/unsigned just add 127 to the sample values. 1.74 + // Simularly for 16-bit data you should add 32769 1.75 + 1.76 + 1.77 + // Magic bytes: '2BIT' 1.78 + 1.79 + $getid3->info['avr'] = array (); 1.80 + $info_avr = &$getid3->info['avr']; 1.81 + 1.82 + $getid3->info['fileformat'] = 'avr'; 1.83 + $info_avr['raw']['magic'] = '2BIT'; 1.84 + 1.85 + fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET); 1.86 + $avr_header = fread($getid3->fp, 128); 1.87 + 1.88 + $getid3->info['avdataoffset'] += 128; 1.89 + 1.90 + $info_avr['sample_name'] = rtrim(substr($avr_header, 4, 8)); 1.91 + 1.92 + $info_avr['raw']['mono'] = getid3_lib::BigEndian2Int(substr($avr_header, 12, 2)); 1.93 + $info_avr['bits_per_sample'] = getid3_lib::BigEndian2Int(substr($avr_header, 14, 2)); 1.94 + $info_avr['raw']['signed'] = getid3_lib::BigEndian2Int(substr($avr_header, 16, 2)); 1.95 + $info_avr['raw']['loop'] = getid3_lib::BigEndian2Int(substr($avr_header, 18, 2)); 1.96 + $info_avr['raw']['midi'] = getid3_lib::BigEndian2Int(substr($avr_header, 20, 2)); 1.97 + $info_avr['raw']['replay_freq'] = getid3_lib::BigEndian2Int(substr($avr_header, 22, 1)); 1.98 + $info_avr['sample_rate'] = getid3_lib::BigEndian2Int(substr($avr_header, 23, 3)); 1.99 + $info_avr['sample_length'] = getid3_lib::BigEndian2Int(substr($avr_header, 26, 4)); 1.100 + $info_avr['loop_start'] = getid3_lib::BigEndian2Int(substr($avr_header, 30, 4)); 1.101 + $info_avr['loop_end'] = getid3_lib::BigEndian2Int(substr($avr_header, 34, 4)); 1.102 + $info_avr['midi_split'] = getid3_lib::BigEndian2Int(substr($avr_header, 38, 2)); 1.103 + $info_avr['sample_compression'] = getid3_lib::BigEndian2Int(substr($avr_header, 40, 2)); 1.104 + $info_avr['reserved'] = getid3_lib::BigEndian2Int(substr($avr_header, 42, 2)); 1.105 + $info_avr['sample_name_extra'] = rtrim(substr($avr_header, 44, 20)); 1.106 + $info_avr['comment'] = rtrim(substr($avr_header, 64, 64)); 1.107 + 1.108 + $info_avr['flags']['stereo'] = (($info_avr['raw']['mono'] == 0) ? false : true); 1.109 + $info_avr['flags']['signed'] = (($info_avr['raw']['signed'] == 0) ? false : true); 1.110 + $info_avr['flags']['loop'] = (($info_avr['raw']['loop'] == 0) ? false : true); 1.111 + 1.112 + $info_avr['midi_notes'] = array (); 1.113 + if (($info_avr['raw']['midi'] & 0xFF00) != 0xFF00) { 1.114 + $info_avr['midi_notes'][] = ($info_avr['raw']['midi'] & 0xFF00) >> 8; 1.115 + } 1.116 + if (($info_avr['raw']['midi'] & 0x00FF) != 0x00FF) { 1.117 + $info_avr['midi_notes'][] = ($info_avr['raw']['midi'] & 0x00FF); 1.118 + } 1.119 + 1.120 + if (($getid3->info['avdataend'] - $getid3->info['avdataoffset']) != ($info_avr['sample_length'] * (($info_avr['bits_per_sample'] == 8) ? 1 : 2))) { 1.121 + $getid3->warning('Probable truncated file: expecting '.($info_avr['sample_length'] * (($info_avr['bits_per_sample'] == 8) ? 1 : 2)).' bytes of audio data, found '.($getid3->info['avdataend'] - $getid3->info['avdataoffset'])); 1.122 + } 1.123 + 1.124 + $getid3->info['audio']['dataformat'] = 'avr'; 1.125 + $getid3->info['audio']['lossless'] = true; 1.126 + $getid3->info['audio']['bitrate_mode'] = 'cbr'; 1.127 + $getid3->info['audio']['bits_per_sample'] = $info_avr['bits_per_sample']; 1.128 + $getid3->info['audio']['sample_rate'] = $info_avr['sample_rate']; 1.129 + $getid3->info['audio']['channels'] = ($info_avr['flags']['stereo'] ? 2 : 1); 1.130 + $getid3->info['playtime_seconds'] = ($info_avr['sample_length'] / $getid3->info['audio']['channels']) / $info_avr['sample_rate']; 1.131 + $getid3->info['audio']['bitrate'] = ($info_avr['sample_length'] * (($info_avr['bits_per_sample'] == 8) ? 8 : 16)) / $getid3->info['playtime_seconds']; 1.132 + 1.133 + return true; 1.134 + } 1.135 +} 1.136 + 1.137 + 1.138 +?> 1.139 \ No newline at end of file