3 /////////////////////////////////////////////////////////////////
4 /// getID3() by James Heinrich <info@getid3.org> //
5 // available at https://github.com/JamesHeinrich/getID3 //
6 // or https://www.getid3.org //
7 // or http://getid3.sourceforge.net //
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
23 public function Analyze() {
24 $info = &$this->getid3
->info
;
25 $this->fseek($info['avdataoffset']);
26 $fileheader = $this->fread(1088);
27 if (preg_match('#^IMPM#', $fileheader)) {
28 return $this->getITheaderFilepointer();
29 } elseif (preg_match('#^Extended Module#', $fileheader)) {
30 return $this->getXMheaderFilepointer();
31 } elseif (preg_match('#^.{44}SCRM#', $fileheader)) {
32 return $this->getS3MheaderFilepointer();
33 } elseif (preg_match('#^.{1080}(M\\.K\\.|M!K!|FLT4|FLT8|[5-9]CHN|[1-3][0-9]CH)#', $fileheader)) {
34 return $this->getMODheaderFilepointer();
36 $this->error('This is not a known type of MOD file');
43 public function getMODheaderFilepointer() {
44 $info = &$this->getid3
->info
;
45 $this->fseek($info['avdataoffset'] +
1080);
46 $FormatID = $this->fread(4);
47 if (!preg_match('#^(M.K.|[5-9]CHN|[1-3][0-9]CH)$#', $FormatID)) {
48 $this->error('This is not a known type of MOD file');
52 $info['fileformat'] = 'mod';
54 $this->error('MOD parsing not enabled in this version of getID3() ['.$this->getid3
->version().']');
61 public function getXMheaderFilepointer() {
62 $info = &$this->getid3
->info
;
63 $this->fseek($info['avdataoffset']);
64 $FormatID = $this->fread(15);
65 if (!preg_match('#^Extended Module$#', $FormatID)) {
66 $this->error('This is not a known type of XM-MOD file');
70 $info['fileformat'] = 'xm';
72 $this->error('XM-MOD parsing not enabled in this version of getID3() ['.$this->getid3
->version().']');
79 public function getS3MheaderFilepointer() {
80 $info = &$this->getid3
->info
;
81 $this->fseek($info['avdataoffset'] +
44);
82 $FormatID = $this->fread(4);
83 if (!preg_match('#^SCRM$#', $FormatID)) {
84 $this->error('This is not a ScreamTracker MOD file');
88 $info['fileformat'] = 's3m';
90 $this->error('ScreamTracker parsing not enabled in this version of getID3() ['.$this->getid3
->version().']');
97 public function getITheaderFilepointer() {
98 $info = &$this->getid3
->info
;
99 $this->fseek($info['avdataoffset']);
100 $FormatID = $this->fread(4);
101 if (!preg_match('#^IMPM$#', $FormatID)) {
102 $this->error('This is not an ImpulseTracker MOD file');
106 $info['fileformat'] = 'it';
108 $this->error('ImpulseTracker parsing not enabled in this version of getID3() ['.$this->getid3
->version().']');