Skip to content

Commit

Permalink
MOD song_length
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHeinrich committed May 1, 2022
1 parent 4582f7c commit aaa7817
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion getid3/getid3.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ class getID3
*/
protected $startup_warning = '';

const VERSION = '1.9.21-202204141319';
const VERSION = '1.9.21-202205011548';
const FREAD_BUFFER_SIZE = 32768;

const ATTACHMENTS_NONE = false;
Expand Down
19 changes: 16 additions & 3 deletions getid3/module.audio.mod.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ public function Analyze() {
return $this->getS3MheaderFilepointer();
//} elseif (preg_match('#^.{1080}(M\\.K\\.|M!K!|FLT4|FLT8|[5-9]CHN|[1-3][0-9]CH)#s', $fileheader)) {
} elseif (preg_match('#^.{1080}(M\\.K\\.)#s', $fileheader)) {
/*
The four letters "M.K." - This is something Mahoney & Kaktus inserted when they
increased the number of samples from 15 to 31. If it's not there, the module/song
uses 15 samples or the text has been removed to make the module harder to rip.
Startrekker puts "FLT4" or "FLT8" there instead.
If there are more than 64 patterns, PT2.3 will insert M!K! here.
*/
return $this->getMODheaderFilepointer();
}
$this->error('This is not a known type of MOD file');
Expand All @@ -61,7 +68,7 @@ public function getMODheaderFilepointer() {

$info['tags']['mod']['title'] = array($info['mod']['title']);

for ($samplenumber = 0; $samplenumber < 31; $samplenumber++) {
for ($samplenumber = 0; $samplenumber <= 30; $samplenumber++) {
$sampledata = array();
$sampledata['name'] = substr($filedata, $offset, 22); $offset += 22;
$sampledata['length'] = getid3_lib::BigEndian2Int(substr($filedata, $offset, 2)); $offset += 2;
Expand All @@ -71,8 +78,14 @@ public function getMODheaderFilepointer() {
$info['mod']['samples'][$samplenumber] = $sampledata;
}

$info['mod']['step_count'] = getid3_lib::BigEndian2Int(substr($filedata, $offset, 1)); $offset += 1;
$info['mod']['bpm'] = getid3_lib::BigEndian2Int(substr($filedata, $offset, 1)); $offset += 1;
$info['mod']['song_length'] = getid3_lib::BigEndian2Int(substr($filedata, $offset++, 1));// Songlength. Range is 1-128.
$info['mod']['bpm'] = getid3_lib::BigEndian2Int(substr($filedata, $offset++, 1));// This byte is set to 127, so that old trackers will search through all patterns when loading. Noisetracker uses this byte for restart, ProTracker doesn't.

for ($songposition = 0; $songposition <= 127; $songposition++) {
// Song positions 0-127. Each hold a number from 0-63 (or 0-127)
// that tells the tracker what pattern to play at that position.
$info['mod']['song_positions'][$songposition] = getid3_lib::BigEndian2Int(substr($filedata, $offset++, 1));
}

} else {
$this->error('unknown MOD ID at offset 1080: '.getid3_lib::PrintHexBytes(substr($filedata, 1080, 4)));
Expand Down

0 comments on commit aaa7817

Please sign in to comment.