2 /////////////////////////////////////////////////////////////////
3 /// getID3() by James Heinrich <info@getid3.org> //
4 // available at http://getid3.sourceforge.net //
5 // or http://www.getid3.org //
6 // also https://github.com/JamesHeinrich/getID3 //
7 /////////////////////////////////////////////////////////////////
8 // See readme.txt for more details //
9 /////////////////////////////////////////////////////////////////
11 // module.audio.mod.php //
12 // module for analyzing MOD Audio files //
13 // dependencies: NONE //
15 /////////////////////////////////////////////////////////////////
18 class getid3_mod
extends getid3_handler
21 public function Analyze() {
22 $info = &$this->getid3
->info
;
23 $this->fseek($info['avdataoffset']);
24 $fileheader = $this->fread(1088);
25 if (preg_match('#^IMPM#', $fileheader)) {
26 return $this->getITheaderFilepointer();
27 } elseif (preg_match('#^Extended Module#', $fileheader)) {
28 return $this->getXMheaderFilepointer();
29 } elseif (preg_match('#^.{44}SCRM#', $fileheader)) {
30 return $this->getS3MheaderFilepointer();
31 } elseif (preg_match('#^.{1080}(M\\.K\\.|M!K!|FLT4|FLT8|[5-9]CHN|[1-3][0-9]CH)#', $fileheader)) {
32 return $this->getMODheaderFilepointer();
34 $this->error('This is not a known type of MOD file');
39 public function getMODheaderFilepointer() {
40 $info = &$this->getid3
->info
;
41 $this->fseek($info['avdataoffset'] +
1080);
42 $FormatID = $this->fread(4);
43 if (!preg_match('#^(M.K.|[5-9]CHN|[1-3][0-9]CH)$#', $FormatID)) {
44 $this->error('This is not a known type of MOD file');
48 $info['fileformat'] = 'mod';
50 $this->error('MOD parsing not enabled in this version of getID3() ['.$this->getid3
->version().']');
54 public function getXMheaderFilepointer() {
55 $info = &$this->getid3
->info
;
56 $this->fseek($info['avdataoffset']);
57 $FormatID = $this->fread(15);
58 if (!preg_match('#^Extended Module$#', $FormatID)) {
59 $this->error('This is not a known type of XM-MOD file');
63 $info['fileformat'] = 'xm';
65 $this->error('XM-MOD parsing not enabled in this version of getID3() ['.$this->getid3
->version().']');
69 public function getS3MheaderFilepointer() {
70 $info = &$this->getid3
->info
;
71 $this->fseek($info['avdataoffset'] +
44);
72 $FormatID = $this->fread(4);
73 if (!preg_match('#^SCRM$#', $FormatID)) {
74 $this->error('This is not a ScreamTracker MOD file');
78 $info['fileformat'] = 's3m';
80 $this->error('ScreamTracker parsing not enabled in this version of getID3() ['.$this->getid3
->version().']');
84 public function getITheaderFilepointer() {
85 $info = &$this->getid3
->info
;
86 $this->fseek($info['avdataoffset']);
87 $FormatID = $this->fread(4);
88 if (!preg_match('#^IMPM$#', $FormatID)) {
89 $this->error('This is not an ImpulseTracker MOD file');
93 $info['fileformat'] = 'it';
95 $this->error('ImpulseTracker parsing not enabled in this version of getID3() ['.$this->getid3
->version().']');