Skip to content

Commit

Permalink
Audio mod detections: .it, .s3m & .xm
Browse files Browse the repository at this point in the history
Implements #254
  • Loading branch information
Borewit committed Jan 13, 2020
1 parent 949acee commit e8e0669
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 5 deletions.
10 changes: 8 additions & 2 deletions core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ declare namespace core {
| 'arrow'
| 'shp'
| 'aac'
| 'mp1';
| 'mp1'
| 'it'
| 's3m'
| 'xm';

type MimeType =
| 'image/jpeg'
Expand Down Expand Up @@ -239,7 +242,10 @@ declare namespace core {
| 'video/x-m4v'
| 'video/3gpp2'
| 'application/x-esri-shape'
| 'audio/aac';
| 'audio/aac'
| 'audio/x-it'
| 'audio/x-s3m'
| 'audio/x-xm';

interface FileTypeResult {
/**
Expand Down
21 changes: 21 additions & 0 deletions core.js
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,13 @@ async function fromTokenizer(tokenizer) {
};
}

if (checkString('IMPM')) {
return {
ext: 'it',
mime: 'audio/x-it'
};
}

// -- 6-byte signatures --

if (check([0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00])) {
Expand Down Expand Up @@ -1050,6 +1057,13 @@ async function fromTokenizer(tokenizer) {
};
}

if (checkString('Extended Module:')) {
return {
ext: 'xm',
mime: 'audio/x-xm'
};
}

if (checkString('Creative Voice File')) {
return {
ext: 'voc',
Expand Down Expand Up @@ -1081,6 +1095,13 @@ async function fromTokenizer(tokenizer) {
};
}

if (checkString('SCRM', {offset: 44})) {
return {
ext: 's3m',
mime: 'audio/x-s3m'
};
}

if (check([0x47], {offset: 4}) && (check([0x47], {offset: 192}) || check([0x47], {offset: 196}))) {
return {
ext: 'mts',
Expand Down
Binary file added fixture/fixture.it
Binary file not shown.
Binary file added fixture/fixture.s3m
Binary file not shown.
Binary file added fixture/fixture.xm
Binary file not shown.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@
"arrow",
"shp",
"aac",
"mp1"
"mp1",
"it",
"s3m",
"xm"
],
"devDependencies": {
"@types/node": "^13.1.4",
Expand Down
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,9 @@ Returns a set of supported MIME types.
- [`shp`](https://en.wikipedia.org/wiki/Shapefile) - Geospatial vector data format
- [`arrow`](https://arrow.apache.org) - Columnar format for tables of data
- [`aac`](https://en.wikipedia.org/wiki/Advanced_Audio_Coding) - Advanced Audio Coding
- [`it`](https://wiki.openmpt.org/Manual:_Module_formats#The_Impulse_Tracker_format_.28.it.29) - Audio module format: Impulse Tracker
- [`s3m`](https://wiki.openmpt.org/Manual:_Module_formats#The_ScreamTracker_3_format_.28.s3m.29) - Audio module format: ScreamTracker 3
- [`xm`](https://wiki.openmpt.org/Manual:_Module_formats#The_FastTracker_2_format_.28.xm.29) - Audio module format: FastTracker 2



Expand Down
10 changes: 8 additions & 2 deletions supported.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ module.exports = {
'arrow',
'shp',
'aac',
'mp1'
'mp1',
'it',
's3m',
'xm'
],
mimeTypes: [
'image/jpeg',
Expand Down Expand Up @@ -237,6 +240,9 @@ module.exports = {
'video/x-m4v',
'video/3gpp2',
'application/x-esri-shape',
'audio/aac'
'audio/aac',
'audio/x-it',
'audio/x-s3m',
'audio/x-xm'
]
};

0 comments on commit e8e0669

Please sign in to comment.