music-metadata 10.6.5 → 10.8.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -2
- package/lib/ParserFactory.js +1 -3
- package/lib/asf/AsfParser.js +1 -1
- package/package.json +7 -7
- package/lib/amr/AmrLoader.d.ts +0 -2
- package/lib/amr/AmrLoader.js +0 -8
- package/lib/amr/AmrParser.d.ts +0 -7
- package/lib/amr/AmrParser.js +0 -58
- package/lib/amr/AmrToken.d.ts +0 -10
- package/lib/amr/AmrToken.js +0 -15
package/README.md
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
[](https://github.com/Borewit/music-metadata/actions?query=branch%3Amaster)
|
|
2
|
-
[](https://ci.appveyor.com/project/Borewit/music-metadata/branch/master)
|
|
3
2
|
[](https://npmjs.org/package/music-metadata)
|
|
4
3
|
[](https://npmcharts.com/compare/music-metadata,jsmediatags,musicmetadata,node-id3,mp3-parser,id3-parser,wav-file-info?start=600&interval=30)
|
|
5
4
|
[](https://coveralls.io/github/Borewit/music-metadata?branch=master)
|
|
@@ -48,7 +47,6 @@ If you find this project useful and would like to support its development, consi
|
|
|
48
47
|
| ------------- |---------------------------------| -------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------:|
|
|
49
48
|
| AIFF / AIFF-C | Audio Interchange File Format | [:link:](https://wikipedia.org/wiki/Audio_Interchange_File_Format) | <img src="https://upload.wikimedia.org/wikipedia/commons/8/84/Apple_Computer_Logo_rainbow.svg" width="40" alt="Apple rainbow logo"> |
|
|
50
49
|
| AAC | ADTS / Advanced Audio Coding | [:link:](https://en.wikipedia.org/wiki/Advanced_Audio_Coding) | <img src="https://svgshare.com/i/UT8.svg" width="40" alt="AAC logo"> |
|
|
51
|
-
| AMR | Adaptive Multi-Rate audio codec | [:link:](https://en.wikipedia.org/wiki/Adaptive_Multi-Rate_audio_codec) | <img src="https://foreverhits.files.wordpress.com/2015/05/ape_audio.jpg" width="40" alt="Monkey's Audio logo"> |
|
|
52
50
|
| APE | Monkey's Audio | [:link:](https://wikipedia.org/wiki/Monkey's_Audio) | <img src="https://foreverhits.files.wordpress.com/2015/05/ape_audio.jpg" width="40" alt="Monkey's Audio logo"> |
|
|
53
51
|
| ASF | Advanced Systems Format | [:link:](https://wikipedia.org/wiki/Advanced_Systems_Format) | |
|
|
54
52
|
| BWF | Broadcast Wave Format | [:link:](https://en.wikipedia.org/wiki/Broadcast_Wave_Format) | |
|
package/lib/ParserFactory.js
CHANGED
|
@@ -17,7 +17,6 @@ import { musepackParserLoader } from './musepack/MusepackLoader.js';
|
|
|
17
17
|
import { oggParserLoader } from './ogg/OggLoader.js';
|
|
18
18
|
import { wavpackParserLoader } from './wavpack/WavPackLoader.js';
|
|
19
19
|
import { riffParserLoader } from './wav/WaveLoader.js';
|
|
20
|
-
import { amrParserLoader } from './amr/AmrLoader.js';
|
|
21
20
|
import { scanAppendingHeaders } from './core.js';
|
|
22
21
|
const debug = initDebug('music-metadata:parser:factory');
|
|
23
22
|
export function parseHttpContentType(contentType) {
|
|
@@ -46,8 +45,7 @@ export class ParserFactory {
|
|
|
46
45
|
wavpackParserLoader,
|
|
47
46
|
musepackParserLoader,
|
|
48
47
|
dsfParserLoader,
|
|
49
|
-
dsdiffParserLoader
|
|
50
|
-
amrParserLoader
|
|
48
|
+
dsdiffParserLoader
|
|
51
49
|
].forEach(parser => this.registerParser(parser));
|
|
52
50
|
}
|
|
53
51
|
registerParser(parser) {
|
package/lib/asf/AsfParser.js
CHANGED
|
@@ -119,7 +119,7 @@ export class AsfParser extends BasicParser {
|
|
|
119
119
|
await this.tokenizer.ignore(remaining);
|
|
120
120
|
break;
|
|
121
121
|
case GUID.CompatibilityObject.str:
|
|
122
|
-
this.tokenizer.ignore(remaining);
|
|
122
|
+
await this.tokenizer.ignore(remaining);
|
|
123
123
|
break;
|
|
124
124
|
case GUID.ASF_Index_Placeholder_Object.str:
|
|
125
125
|
await this.tokenizer.ignore(remaining);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "music-metadata",
|
|
3
3
|
"description": "Music metadata parser for Node.js, supporting virtual any audio and tag format.",
|
|
4
|
-
"version": "10.
|
|
4
|
+
"version": "10.8.0-beta.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Borewit",
|
|
7
7
|
"url": "https://github.com/Borewit"
|
|
@@ -90,11 +90,11 @@
|
|
|
90
90
|
"lyrics"
|
|
91
91
|
],
|
|
92
92
|
"scripts": {
|
|
93
|
-
"clean": "del-cli 'lib/**/*.js' 'lib/**/*.js.map' 'lib/**/*.d.ts' '
|
|
93
|
+
"clean": "del-cli 'lib/**/*.js' 'lib/**/*.js.map' 'lib/**/*.d.ts' 'test/**/*.js' 'test/**/*.js.map' 'test/**/*.js' 'test/**/*.js.map' 'doc-gen/**/*.js' 'doc-gen/**/*.js.map'",
|
|
94
94
|
"compile-src": "tsc -p lib",
|
|
95
95
|
"compile-test": "tsc -p test",
|
|
96
96
|
"compile-doc": "tsc -p doc-gen",
|
|
97
|
-
"compile": "yarn run
|
|
97
|
+
"compile": "yarn run compile-src && yarn compile-test && yarn compile-doc",
|
|
98
98
|
"lint-ts": "biome check",
|
|
99
99
|
"lint-md": "yarn run remark -u remark-preset-lint-consistent .",
|
|
100
100
|
"lint": "yarn run lint-ts && yarn run lint-md",
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"file-type": "^19.6.0",
|
|
112
112
|
"link": "^2.1.1",
|
|
113
113
|
"media-typer": "^1.1.0",
|
|
114
|
-
"strtok3": "
|
|
114
|
+
"strtok3": "10.1.0-beta.2",
|
|
115
115
|
"token-types": "^6.0.0",
|
|
116
116
|
"uint8array-extras": "^1.4.0"
|
|
117
117
|
},
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
"@types/debug": "^4.1.12",
|
|
124
124
|
"@types/media-typer": "^1.1.3",
|
|
125
125
|
"@types/mocha": "^10.0.10",
|
|
126
|
-
"@types/node": "^22.10.
|
|
126
|
+
"@types/node": "^22.10.7",
|
|
127
127
|
"c8": "^10.1.3",
|
|
128
128
|
"chai": "^5.1.2",
|
|
129
129
|
"chai-as-promised": "^8.0.1",
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
"remark-cli": "^12.0.1",
|
|
134
134
|
"remark-preset-lint-consistent": "^6.0.0",
|
|
135
135
|
"ts-node": "^10.9.2",
|
|
136
|
-
"typescript": "^5.7.
|
|
136
|
+
"typescript": "^5.7.3"
|
|
137
137
|
},
|
|
138
138
|
"engines": {
|
|
139
139
|
"node": ">=16.0.0"
|
|
@@ -146,5 +146,5 @@
|
|
|
146
146
|
"bugs": {
|
|
147
147
|
"url": "https://github.com/Borewit/music-metadata/issues"
|
|
148
148
|
},
|
|
149
|
-
"packageManager": "yarn@4.
|
|
149
|
+
"packageManager": "yarn@4.6.0"
|
|
150
150
|
}
|
package/lib/amr/AmrLoader.d.ts
DELETED
package/lib/amr/AmrLoader.js
DELETED
package/lib/amr/AmrParser.d.ts
DELETED
package/lib/amr/AmrParser.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { BasicParser } from '../common/BasicParser.js';
|
|
2
|
-
import { AnsiStringType } from 'token-types';
|
|
3
|
-
import initDebug from 'debug';
|
|
4
|
-
import { FrameHeader } from './AmrToken.js';
|
|
5
|
-
import { EndOfStreamError } from 'strtok3';
|
|
6
|
-
const debug = initDebug('music-metadata:parser:AMR');
|
|
7
|
-
/**
|
|
8
|
-
* There are 8 varying levels of compression. First byte of the frame specifies CMR
|
|
9
|
-
* (codec mode request), values 0-7 are valid for AMR. Each mode have different frame size.
|
|
10
|
-
* This table reflects that fact.
|
|
11
|
-
*/
|
|
12
|
-
const m_block_size = [12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0];
|
|
13
|
-
/**
|
|
14
|
-
* Adaptive Multi-Rate audio codec
|
|
15
|
-
*/
|
|
16
|
-
export class AmrParser extends BasicParser {
|
|
17
|
-
async parse() {
|
|
18
|
-
const magicNr = await this.tokenizer.readToken(new AnsiStringType(5));
|
|
19
|
-
if (magicNr !== '#!AMR') {
|
|
20
|
-
throw new Error('Invalid AMR file: invalid MAGIC number');
|
|
21
|
-
}
|
|
22
|
-
this.metadata.setFormat('container', 'AMR');
|
|
23
|
-
this.metadata.setFormat('codec', 'AMR');
|
|
24
|
-
this.metadata.setFormat('sampleRate', 8000);
|
|
25
|
-
this.metadata.setFormat('bitrate', 64000);
|
|
26
|
-
this.metadata.setFormat('numberOfChannels', 1);
|
|
27
|
-
let total_size = 0;
|
|
28
|
-
let frames = 0;
|
|
29
|
-
const assumedFileLength = this.tokenizer.fileInfo?.size ?? Number.MAX_SAFE_INTEGER;
|
|
30
|
-
if (this.options.duration) {
|
|
31
|
-
let header;
|
|
32
|
-
while (this.tokenizer.position < assumedFileLength) {
|
|
33
|
-
try {
|
|
34
|
-
header = await this.tokenizer.readToken(FrameHeader);
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
if (error instanceof EndOfStreamError)
|
|
38
|
-
break;
|
|
39
|
-
throw error;
|
|
40
|
-
}
|
|
41
|
-
/* first byte is rate mode. each rate mode has frame of given length. look it up. */
|
|
42
|
-
const size = m_block_size[header.frameType];
|
|
43
|
-
if (size > 0) {
|
|
44
|
-
total_size += size + 1;
|
|
45
|
-
if (total_size > assumedFileLength)
|
|
46
|
-
break;
|
|
47
|
-
await this.tokenizer.ignore(size);
|
|
48
|
-
++frames;
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
debug(`Found no-data frame, frame-type: ${header.frameType}. Skipping`);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
this.metadata.setFormat('duration', frames * 0.02);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=AmrParser.js.map
|
package/lib/amr/AmrToken.d.ts
DELETED
package/lib/amr/AmrToken.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { getBitAllignedNumber } from '../common/Util.js';
|
|
2
|
-
/**
|
|
3
|
-
* ID3v2 header
|
|
4
|
-
* Ref: http://id3.org/id3v2.3.0#ID3v2_header
|
|
5
|
-
* ToDo
|
|
6
|
-
*/
|
|
7
|
-
export const FrameHeader = {
|
|
8
|
-
len: 1,
|
|
9
|
-
get: (buf, off) => {
|
|
10
|
-
return {
|
|
11
|
-
frameType: getBitAllignedNumber(buf, off, 1, 4)
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=AmrToken.js.map
|