music-metadata 7.12.5 → 8.0.1
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 +47 -31
- package/lib/ParserFactory.d.ts +3 -3
- package/lib/ParserFactory.js +37 -41
- package/lib/aiff/AiffParser.d.ts +2 -2
- package/lib/aiff/AiffParser.js +25 -17
- package/lib/aiff/AiffToken.d.ts +3 -2
- package/lib/aiff/AiffToken.js +13 -12
- package/lib/apev2/APEv2Parser.d.ts +5 -5
- package/lib/apev2/APEv2Parser.js +29 -32
- package/lib/apev2/APEv2TagMapper.d.ts +1 -1
- package/lib/apev2/APEv2TagMapper.js +2 -6
- package/lib/apev2/APEv2Token.d.ts +1 -1
- package/lib/apev2/APEv2Token.js +13 -19
- package/lib/asf/AsfObject.d.ts +5 -4
- package/lib/asf/AsfObject.js +42 -56
- package/lib/asf/AsfParser.d.ts +1 -1
- package/lib/asf/AsfParser.js +15 -19
- package/lib/asf/AsfTagMapper.d.ts +2 -2
- package/lib/asf/AsfTagMapper.js +2 -6
- package/lib/asf/AsfUtil.d.ts +3 -2
- package/lib/asf/AsfUtil.js +4 -7
- package/lib/asf/GUID.d.ts +1 -1
- package/lib/asf/GUID.js +1 -4
- package/lib/browser.js +99 -0
- package/lib/common/BasicParser.d.ts +4 -4
- package/lib/common/BasicParser.js +1 -5
- package/lib/common/CaseInsensitiveTagMap.d.ts +3 -3
- package/lib/common/CaseInsensitiveTagMap.js +2 -6
- package/lib/common/CombinedTagMapper.d.ts +4 -4
- package/lib/common/CombinedTagMapper.js +20 -24
- package/lib/common/FourCC.d.ts +1 -1
- package/lib/common/FourCC.js +3 -6
- package/lib/common/GenericTagMapper.d.ts +4 -4
- package/lib/common/GenericTagMapper.js +2 -6
- package/lib/common/GenericTagTypes.js +5 -10
- package/lib/common/MetadataCollector.d.ts +2 -2
- package/lib/common/MetadataCollector.js +20 -25
- package/lib/common/RandomFileReader.d.ts +2 -2
- package/lib/common/RandomFileReader.js +2 -6
- package/lib/common/RandomUint8ArrayReader.d.ts +1 -1
- package/lib/common/RandomUint8ArrayReader.js +1 -5
- package/lib/common/Util.d.ts +1 -1
- package/lib/common/Util.js +11 -25
- package/lib/core.d.ts +4 -4
- package/lib/core.js +18 -28
- package/lib/dsdiff/DsdiffParser.d.ts +1 -1
- package/lib/dsdiff/DsdiffParser.js +24 -28
- package/lib/dsdiff/DsdiffToken.d.ts +3 -3
- package/lib/dsdiff/DsdiffToken.js +4 -7
- package/lib/dsf/DsfChunk.d.ts +1 -1
- package/lib/dsf/DsfChunk.js +8 -11
- package/lib/dsf/DsfParser.d.ts +1 -1
- package/lib/dsf/DsfParser.js +13 -17
- package/lib/flac/FlacParser.d.ts +5 -5
- package/lib/flac/FlacParser.js +22 -26
- package/lib/id3v1/ID3v1Parser.d.ts +2 -2
- package/lib/id3v1/ID3v1Parser.js +16 -21
- package/lib/id3v1/ID3v1TagMap.d.ts +1 -1
- package/lib/id3v1/ID3v1TagMap.js +2 -6
- package/lib/id3v2/AbstractID3Parser.d.ts +2 -2
- package/lib/id3v2/AbstractID3Parser.js +13 -17
- package/lib/id3v2/FrameParser.d.ts +2 -2
- package/lib/id3v2/FrameParser.js +12 -17
- package/lib/id3v2/ID3v22TagMapper.d.ts +2 -2
- package/lib/id3v2/ID3v22TagMapper.js +4 -8
- package/lib/id3v2/ID3v24TagMapper.d.ts +3 -3
- package/lib/id3v2/ID3v24TagMapper.js +5 -9
- package/lib/id3v2/ID3v2Parser.d.ts +3 -3
- package/lib/id3v2/ID3v2Parser.js +10 -14
- package/lib/id3v2/ID3v2Token.d.ts +2 -2
- package/lib/id3v2/ID3v2Token.js +9 -12
- package/lib/iff/index.d.ts +1 -1
- package/lib/iff/index.js +4 -7
- package/lib/index.d.ts +4 -28
- package/lib/index.js +14 -44
- package/lib/lyrics3/Lyrics3.d.ts +1 -1
- package/lib/lyrics3/Lyrics3.js +3 -7
- package/lib/matroska/MatroskaDtd.d.ts +1 -1
- package/lib/matroska/MatroskaDtd.js +111 -114
- package/lib/matroska/MatroskaParser.d.ts +5 -5
- package/lib/matroska/MatroskaParser.js +20 -24
- package/lib/matroska/MatroskaTagMapper.d.ts +1 -1
- package/lib/matroska/MatroskaTagMapper.js +2 -6
- package/lib/matroska/types.d.ts +1 -1
- package/lib/matroska/types.js +6 -9
- package/lib/mp4/Atom.d.ts +2 -2
- package/lib/mp4/Atom.js +4 -8
- package/lib/mp4/AtomToken.d.ts +2 -2
- package/lib/mp4/AtomToken.js +29 -44
- package/lib/mp4/MP4Parser.d.ts +2 -2
- package/lib/mp4/MP4Parser.js +12 -16
- package/lib/mp4/MP4TagMapper.d.ts +1 -1
- package/lib/mp4/MP4TagMapper.js +4 -8
- package/lib/mpeg/ExtendedLameHeader.d.ts +2 -2
- package/lib/mpeg/ExtendedLameHeader.js +6 -9
- package/lib/mpeg/MpegParser.d.ts +1 -1
- package/lib/mpeg/MpegParser.js +17 -21
- package/lib/mpeg/ReplayGainDataFormat.d.ts +1 -1
- package/lib/mpeg/ReplayGainDataFormat.js +2 -5
- package/lib/mpeg/XingTag.d.ts +3 -3
- package/lib/mpeg/XingTag.js +9 -13
- package/lib/musepack/index.d.ts +1 -1
- package/lib/musepack/index.js +10 -12
- package/lib/musepack/sv7/BitReader.d.ts +1 -1
- package/lib/musepack/sv7/BitReader.js +2 -6
- package/lib/musepack/sv7/MpcSv7Parser.d.ts +1 -1
- package/lib/musepack/sv7/MpcSv7Parser.js +9 -13
- package/lib/musepack/sv7/StreamVersion7.d.ts +1 -1
- package/lib/musepack/sv7/StreamVersion7.js +3 -6
- package/lib/musepack/sv8/MpcSv8Parser.d.ts +1 -1
- package/lib/musepack/sv8/MpcSv8Parser.js +9 -13
- package/lib/musepack/sv8/StreamVersion8.d.ts +1 -1
- package/lib/musepack/sv8/StreamVersion8.js +5 -9
- package/lib/ogg/Ogg.js +1 -2
- package/lib/ogg/OggParser.d.ts +3 -3
- package/lib/ogg/OggParser.js +19 -24
- package/lib/ogg/opus/Opus.d.ts +1 -1
- package/lib/ogg/opus/Opus.js +2 -6
- package/lib/ogg/opus/OpusParser.d.ts +6 -6
- package/lib/ogg/opus/OpusParser.js +4 -8
- package/lib/ogg/speex/Speex.d.ts +1 -1
- package/lib/ogg/speex/Speex.js +3 -6
- package/lib/ogg/speex/SpeexParser.d.ts +6 -6
- package/lib/ogg/speex/SpeexParser.js +5 -9
- package/lib/ogg/theora/Theora.d.ts +1 -1
- package/lib/ogg/theora/Theora.js +2 -5
- package/lib/ogg/theora/TheoraParser.d.ts +5 -5
- package/lib/ogg/theora/TheoraParser.js +5 -9
- package/lib/ogg/vorbis/Vorbis.d.ts +3 -3
- package/lib/ogg/vorbis/Vorbis.js +6 -10
- package/lib/ogg/vorbis/VorbisDecoder.js +2 -6
- package/lib/ogg/vorbis/VorbisParser.d.ts +11 -11
- package/lib/ogg/vorbis/VorbisParser.js +18 -22
- package/lib/ogg/vorbis/VorbisTagMapper.d.ts +2 -2
- package/lib/ogg/vorbis/VorbisTagMapper.js +3 -7
- package/lib/riff/RiffChunk.d.ts +3 -3
- package/lib/riff/RiffChunk.js +3 -7
- package/lib/riff/RiffInfoTagMap.d.ts +2 -2
- package/lib/riff/RiffInfoTagMap.js +4 -8
- package/lib/type.d.ts +6 -5
- package/lib/type.js +1 -5
- package/lib/wav/BwfChunk.d.ts +1 -1
- package/lib/wav/BwfChunk.js +8 -11
- package/lib/wav/WaveChunk.d.ts +3 -3
- package/lib/wav/WaveChunk.js +4 -9
- package/lib/wav/WaveParser.d.ts +2 -2
- package/lib/wav/WaveParser.js +17 -21
- package/lib/wavpack/WavPackParser.d.ts +1 -1
- package/lib/wavpack/WavPackParser.js +17 -21
- package/lib/wavpack/WavPackToken.d.ts +1 -1
- package/lib/wavpack/WavPackToken.js +4 -8
- package/package.json +29 -41
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.BitReader = void 0;
|
|
4
|
-
const Token = require("token-types");
|
|
5
|
-
class BitReader {
|
|
1
|
+
import * as Token from 'token-types';
|
|
2
|
+
export class BitReader {
|
|
6
3
|
constructor(tokenizer) {
|
|
7
4
|
this.tokenizer = tokenizer;
|
|
8
5
|
this.pos = 0;
|
|
@@ -51,4 +48,3 @@ class BitReader {
|
|
|
51
48
|
return this.read(remainder);
|
|
52
49
|
}
|
|
53
50
|
}
|
|
54
|
-
exports.BitReader = BitReader;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const SV7 = require("./StreamVersion7");
|
|
9
|
-
const debug = (0, debug_1.default)('music-metadata:parser:musepack');
|
|
10
|
-
class MpcSv7Parser extends BasicParser_1.BasicParser {
|
|
1
|
+
import initDebug from 'debug';
|
|
2
|
+
import { BasicParser } from '../../common/BasicParser.js';
|
|
3
|
+
import { APEv2Parser } from '../../apev2/APEv2Parser.js';
|
|
4
|
+
import { BitReader } from './BitReader.js';
|
|
5
|
+
import * as SV7 from './StreamVersion7.js';
|
|
6
|
+
const debug = initDebug('music-metadata:parser:musepack');
|
|
7
|
+
export class MpcSv7Parser extends BasicParser {
|
|
11
8
|
constructor() {
|
|
12
9
|
super(...arguments);
|
|
13
10
|
this.audioLength = 0;
|
|
@@ -23,13 +20,13 @@ class MpcSv7Parser extends BasicParser_1.BasicParser {
|
|
|
23
20
|
this.metadata.setFormat('numberOfSamples', numberOfSamples);
|
|
24
21
|
this.duration = numberOfSamples / header.sampleFrequency;
|
|
25
22
|
this.metadata.setFormat('duration', this.duration);
|
|
26
|
-
this.bitreader = new
|
|
23
|
+
this.bitreader = new BitReader(this.tokenizer);
|
|
27
24
|
this.metadata.setFormat('numberOfChannels', header.midSideStereo || header.intensityStereo ? 2 : 1);
|
|
28
25
|
const version = await this.bitreader.read(8);
|
|
29
26
|
this.metadata.setFormat('codec', (version / 100).toFixed(2));
|
|
30
27
|
await this.skipAudioData(header.frameCount);
|
|
31
28
|
debug(`End of audio stream, switching to APEv2, offset=${this.tokenizer.position}`);
|
|
32
|
-
return
|
|
29
|
+
return APEv2Parser.tryParseApeHeader(this.metadata, this.tokenizer, this.options);
|
|
33
30
|
}
|
|
34
31
|
async skipAudioData(frameCount) {
|
|
35
32
|
while (frameCount-- > 0) {
|
|
@@ -43,4 +40,3 @@ class MpcSv7Parser extends BasicParser_1.BasicParser {
|
|
|
43
40
|
this.metadata.setFormat('bitrate', this.audioLength / this.duration);
|
|
44
41
|
}
|
|
45
42
|
}
|
|
46
|
-
exports.MpcSv7Parser = MpcSv7Parser;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Header = void 0;
|
|
4
|
-
const Token = require("token-types");
|
|
5
|
-
const util = require("../../common/Util");
|
|
1
|
+
import * as Token from 'token-types';
|
|
2
|
+
import * as util from '../../common/Util.js';
|
|
6
3
|
/**
|
|
7
4
|
* BASIC STRUCTURE
|
|
8
5
|
*/
|
|
9
|
-
|
|
6
|
+
export const Header = {
|
|
10
7
|
len: 6 * 4,
|
|
11
8
|
get: (buf, off) => {
|
|
12
9
|
const header = {
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const SV8 = require("./StreamVersion8");
|
|
9
|
-
const debug = (0, debug_1.default)('music-metadata:parser:musepack');
|
|
10
|
-
class MpcSv8Parser extends BasicParser_1.BasicParser {
|
|
1
|
+
import initDebug from 'debug';
|
|
2
|
+
import { BasicParser } from '../../common/BasicParser.js';
|
|
3
|
+
import { APEv2Parser } from '../../apev2/APEv2Parser.js';
|
|
4
|
+
import { FourCcToken } from '../../common/FourCC.js';
|
|
5
|
+
import * as SV8 from './StreamVersion8.js';
|
|
6
|
+
const debug = initDebug('music-metadata:parser:musepack');
|
|
7
|
+
export class MpcSv8Parser extends BasicParser {
|
|
11
8
|
constructor() {
|
|
12
9
|
super(...arguments);
|
|
13
10
|
this.audioLength = 0;
|
|
14
11
|
}
|
|
15
12
|
async parse() {
|
|
16
|
-
const signature = await this.tokenizer.readToken(
|
|
13
|
+
const signature = await this.tokenizer.readToken(FourCcToken);
|
|
17
14
|
if (signature !== 'MPCK')
|
|
18
15
|
throw new Error('Invalid Magic number');
|
|
19
16
|
this.metadata.setFormat('container', 'Musepack, SV8');
|
|
@@ -45,11 +42,10 @@ class MpcSv8Parser extends BasicParser_1.BasicParser {
|
|
|
45
42
|
break;
|
|
46
43
|
case 'SE': // Stream End
|
|
47
44
|
this.metadata.setFormat('bitrate', this.audioLength * 8 / this.metadata.format.duration);
|
|
48
|
-
return
|
|
45
|
+
return APEv2Parser.tryParseApeHeader(this.metadata, this.tokenizer, this.options);
|
|
49
46
|
default:
|
|
50
47
|
throw new Error(`Unexpected header: ${header.key}`);
|
|
51
48
|
}
|
|
52
49
|
} while (true);
|
|
53
50
|
}
|
|
54
51
|
}
|
|
55
|
-
exports.MpcSv8Parser = MpcSv8Parser;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const debug_1 = require("debug");
|
|
6
|
-
const util = require("../../common/Util");
|
|
7
|
-
const debug = (0, debug_1.default)('music-metadata:parser:musepack:sv8');
|
|
1
|
+
import * as Token from 'token-types';
|
|
2
|
+
import initDebug from 'debug';
|
|
3
|
+
import * as util from '../../common/Util.js';
|
|
4
|
+
const debug = initDebug('music-metadata:parser:musepack:sv8');
|
|
8
5
|
const PacketKey = new Token.StringType(2, 'binary');
|
|
9
6
|
/**
|
|
10
7
|
* Stream Header Packet part 1
|
|
@@ -35,7 +32,7 @@ const SH_part3 = {
|
|
|
35
32
|
};
|
|
36
33
|
}
|
|
37
34
|
};
|
|
38
|
-
class StreamReader {
|
|
35
|
+
export class StreamReader {
|
|
39
36
|
constructor(tokenizer) {
|
|
40
37
|
this.tokenizer = tokenizer;
|
|
41
38
|
}
|
|
@@ -77,4 +74,3 @@ class StreamReader {
|
|
|
77
74
|
return this.readVariableSizeField(len + 1, n << 7);
|
|
78
75
|
}
|
|
79
76
|
}
|
|
80
|
-
exports.StreamReader = StreamReader;
|
package/lib/ogg/Ogg.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/lib/ogg/OggParser.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IGetToken } from 'strtok3/
|
|
2
|
-
import { BasicParser } from '../common/BasicParser';
|
|
3
|
-
import * as Ogg from './Ogg';
|
|
1
|
+
import { IGetToken } from 'strtok3/core';
|
|
2
|
+
import { BasicParser } from '../common/BasicParser.js';
|
|
3
|
+
import * as Ogg from './Ogg.js';
|
|
4
4
|
export declare class SegmentTable implements IGetToken<Ogg.ISegmentTable> {
|
|
5
5
|
private static sum;
|
|
6
6
|
len: number;
|
package/lib/ogg/OggParser.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const TheoraParser_1 = require("./theora/TheoraParser");
|
|
14
|
-
const debug = (0, debug_1.default)('music-metadata:parser:ogg');
|
|
15
|
-
class SegmentTable {
|
|
1
|
+
import * as Token from 'token-types';
|
|
2
|
+
import { EndOfStreamError } from 'strtok3/core';
|
|
3
|
+
import initDebug from 'debug';
|
|
4
|
+
import * as util from '../common/Util.js';
|
|
5
|
+
import { FourCcToken } from '../common/FourCC.js';
|
|
6
|
+
import { BasicParser } from '../common/BasicParser.js';
|
|
7
|
+
import { VorbisParser } from './vorbis/VorbisParser.js';
|
|
8
|
+
import { OpusParser } from './opus/OpusParser.js';
|
|
9
|
+
import { SpeexParser } from './speex/SpeexParser.js';
|
|
10
|
+
import { TheoraParser } from './theora/TheoraParser.js';
|
|
11
|
+
const debug = initDebug('music-metadata:parser:ogg');
|
|
12
|
+
export class SegmentTable {
|
|
16
13
|
constructor(header) {
|
|
17
14
|
this.len = header.page_segments;
|
|
18
15
|
}
|
|
@@ -29,11 +26,10 @@ class SegmentTable {
|
|
|
29
26
|
};
|
|
30
27
|
}
|
|
31
28
|
}
|
|
32
|
-
exports.SegmentTable = SegmentTable;
|
|
33
29
|
/**
|
|
34
30
|
* Parser for Ogg logical bitstream framing
|
|
35
31
|
*/
|
|
36
|
-
class OggParser extends
|
|
32
|
+
export class OggParser extends BasicParser {
|
|
37
33
|
/**
|
|
38
34
|
* Parse page
|
|
39
35
|
* @returns {Promise<void>}
|
|
@@ -59,20 +55,20 @@ class OggParser extends BasicParser_1.BasicParser {
|
|
|
59
55
|
switch (id) {
|
|
60
56
|
case '\x01vorbis': // Ogg/Vorbis
|
|
61
57
|
debug('Set page consumer to Ogg/Vorbis');
|
|
62
|
-
this.pageConsumer = new
|
|
58
|
+
this.pageConsumer = new VorbisParser(this.metadata, this.options);
|
|
63
59
|
break;
|
|
64
60
|
case 'OpusHea': // Ogg/Opus
|
|
65
61
|
debug('Set page consumer to Ogg/Opus');
|
|
66
|
-
this.pageConsumer = new
|
|
62
|
+
this.pageConsumer = new OpusParser(this.metadata, this.options, this.tokenizer);
|
|
67
63
|
break;
|
|
68
64
|
case 'Speex ': // Ogg/Speex
|
|
69
65
|
debug('Set page consumer to Ogg/Speex');
|
|
70
|
-
this.pageConsumer = new
|
|
66
|
+
this.pageConsumer = new SpeexParser(this.metadata, this.options, this.tokenizer);
|
|
71
67
|
break;
|
|
72
68
|
case 'fishead':
|
|
73
69
|
case '\x00theora': // Ogg/Theora
|
|
74
70
|
debug('Set page consumer to Ogg/Theora');
|
|
75
|
-
this.pageConsumer = new
|
|
71
|
+
this.pageConsumer = new TheoraParser(this.metadata, this.options, this.tokenizer);
|
|
76
72
|
break;
|
|
77
73
|
default:
|
|
78
74
|
throw new Error('gg audio-codec not recognized (id=' + id + ')');
|
|
@@ -82,7 +78,7 @@ class OggParser extends BasicParser_1.BasicParser {
|
|
|
82
78
|
} while (!header.headerType.lastPage);
|
|
83
79
|
}
|
|
84
80
|
catch (err) {
|
|
85
|
-
if (err instanceof
|
|
81
|
+
if (err instanceof EndOfStreamError) {
|
|
86
82
|
this.metadata.addWarning('Last OGG-page is not marked with last-page flag');
|
|
87
83
|
debug(`End-of-stream`);
|
|
88
84
|
this.metadata.addWarning('Last OGG-page is not marked with last-page flag');
|
|
@@ -103,12 +99,11 @@ class OggParser extends BasicParser_1.BasicParser {
|
|
|
103
99
|
}
|
|
104
100
|
}
|
|
105
101
|
}
|
|
106
|
-
exports.OggParser = OggParser;
|
|
107
102
|
OggParser.Header = {
|
|
108
103
|
len: 27,
|
|
109
104
|
get: (buf, off) => {
|
|
110
105
|
return {
|
|
111
|
-
capturePattern:
|
|
106
|
+
capturePattern: FourCcToken.get(buf, off),
|
|
112
107
|
version: Token.UINT8.get(buf, off + 4),
|
|
113
108
|
headerType: {
|
|
114
109
|
continued: util.getBit(buf, off + 5, 0),
|
package/lib/ogg/opus/Opus.d.ts
CHANGED
package/lib/ogg/opus/Opus.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IdHeader = void 0;
|
|
4
|
-
const Token = require("token-types");
|
|
1
|
+
import * as Token from 'token-types';
|
|
5
2
|
/**
|
|
6
3
|
* Opus ID Header parser
|
|
7
4
|
* Ref: https://wiki.xiph.org/OggOpus#ID_Header
|
|
8
5
|
*/
|
|
9
|
-
class IdHeader {
|
|
6
|
+
export class IdHeader {
|
|
10
7
|
constructor(len) {
|
|
11
8
|
this.len = len;
|
|
12
9
|
if (len < 19) {
|
|
@@ -25,4 +22,3 @@ class IdHeader {
|
|
|
25
22
|
};
|
|
26
23
|
}
|
|
27
24
|
}
|
|
28
|
-
exports.IdHeader = IdHeader;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { ITokenizer } from 'strtok3/
|
|
3
|
-
import { IPageHeader } from '../Ogg';
|
|
4
|
-
import { VorbisParser } from '../vorbis/VorbisParser';
|
|
5
|
-
import { IOptions } from '../../type';
|
|
6
|
-
import { INativeMetadataCollector } from '../../common/MetadataCollector';
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import { ITokenizer } from 'strtok3/core';
|
|
3
|
+
import { IPageHeader } from '../Ogg.js';
|
|
4
|
+
import { VorbisParser } from '../vorbis/VorbisParser.js';
|
|
5
|
+
import { IOptions } from '../../type.js';
|
|
6
|
+
import { INativeMetadataCollector } from '../../common/MetadataCollector.js';
|
|
7
7
|
/**
|
|
8
8
|
* Opus parser
|
|
9
9
|
* Internet Engineering Task Force (IETF) - RFC 6716
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const Token = require("token-types");
|
|
5
|
-
const VorbisParser_1 = require("../vorbis/VorbisParser");
|
|
6
|
-
const Opus = require("./Opus");
|
|
1
|
+
import * as Token from 'token-types';
|
|
2
|
+
import { VorbisParser } from '../vorbis/VorbisParser.js';
|
|
3
|
+
import * as Opus from './Opus.js';
|
|
7
4
|
/**
|
|
8
5
|
* Opus parser
|
|
9
6
|
* Internet Engineering Task Force (IETF) - RFC 6716
|
|
10
7
|
* Used by OggParser
|
|
11
8
|
*/
|
|
12
|
-
class OpusParser extends
|
|
9
|
+
export class OpusParser extends VorbisParser {
|
|
13
10
|
constructor(metadata, options, tokenizer) {
|
|
14
11
|
super(metadata, options);
|
|
15
12
|
this.tokenizer = tokenizer;
|
|
@@ -53,4 +50,3 @@ class OpusParser extends VorbisParser_1.VorbisParser {
|
|
|
53
50
|
}
|
|
54
51
|
}
|
|
55
52
|
}
|
|
56
|
-
exports.OpusParser = OpusParser;
|
package/lib/ogg/speex/Speex.d.ts
CHANGED
package/lib/ogg/speex/Speex.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Header = void 0;
|
|
4
|
-
const Token = require("token-types");
|
|
5
|
-
const util = require("../../common/Util");
|
|
1
|
+
import * as Token from 'token-types';
|
|
2
|
+
import * as util from '../../common/Util.js';
|
|
6
3
|
/**
|
|
7
4
|
* Speex Header Packet
|
|
8
5
|
* Ref: https://www.speex.org/docs/manual/speex-manual/node8.html#SECTION00830000000000000000
|
|
9
6
|
*/
|
|
10
|
-
|
|
7
|
+
export const Header = {
|
|
11
8
|
len: 80,
|
|
12
9
|
get: (buf, off) => {
|
|
13
10
|
return {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { ITokenizer } from 'strtok3/
|
|
3
|
-
import { IPageHeader } from '../Ogg';
|
|
4
|
-
import { VorbisParser } from '../vorbis/VorbisParser';
|
|
5
|
-
import { IOptions } from '../../type';
|
|
6
|
-
import { INativeMetadataCollector } from '../../common/MetadataCollector';
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import { ITokenizer } from 'strtok3/core';
|
|
3
|
+
import { IPageHeader } from '../Ogg.js';
|
|
4
|
+
import { VorbisParser } from '../vorbis/VorbisParser.js';
|
|
5
|
+
import { IOptions } from '../../type.js';
|
|
6
|
+
import { INativeMetadataCollector } from '../../common/MetadataCollector.js';
|
|
7
7
|
/**
|
|
8
8
|
* Speex, RFC 5574
|
|
9
9
|
* Ref:
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const VorbisParser_1 = require("../vorbis/VorbisParser");
|
|
6
|
-
const Speex = require("./Speex");
|
|
7
|
-
const debug = (0, debug_1.default)('music-metadata:parser:ogg:speex');
|
|
1
|
+
import initDebug from 'debug';
|
|
2
|
+
import { VorbisParser } from '../vorbis/VorbisParser.js';
|
|
3
|
+
import * as Speex from './Speex.js';
|
|
4
|
+
const debug = initDebug('music-metadata:parser:ogg:speex');
|
|
8
5
|
/**
|
|
9
6
|
* Speex, RFC 5574
|
|
10
7
|
* Ref:
|
|
11
8
|
* - https://www.speex.org/docs/manual/speex-manual/
|
|
12
9
|
* - https://tools.ietf.org/html/rfc5574
|
|
13
10
|
*/
|
|
14
|
-
class SpeexParser extends
|
|
11
|
+
export class SpeexParser extends VorbisParser {
|
|
15
12
|
constructor(metadata, options, tokenizer) {
|
|
16
13
|
super(metadata, options);
|
|
17
14
|
this.tokenizer = tokenizer;
|
|
@@ -32,4 +29,3 @@ class SpeexParser extends VorbisParser_1.VorbisParser {
|
|
|
32
29
|
}
|
|
33
30
|
}
|
|
34
31
|
}
|
|
35
|
-
exports.SpeexParser = SpeexParser;
|
package/lib/ogg/theora/Theora.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IdentificationHeader = void 0;
|
|
4
|
-
const Token = require("token-types");
|
|
1
|
+
import * as Token from 'token-types';
|
|
5
2
|
/**
|
|
6
3
|
* 6.2 Identification Header
|
|
7
4
|
* Ref: https://theora.org/doc/Theora.pdf: 6.2 Identification Header Decode
|
|
8
5
|
*/
|
|
9
|
-
|
|
6
|
+
export const IdentificationHeader = {
|
|
10
7
|
len: 42,
|
|
11
8
|
get: (buf, off) => {
|
|
12
9
|
return {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { ITokenizer } from 'strtok3/
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import { ITokenizer } from 'strtok3/core';
|
|
3
|
+
import * as Ogg from '../Ogg.js';
|
|
4
|
+
import { IOptions } from '../../type.js';
|
|
5
|
+
import { INativeMetadataCollector } from '../../common/MetadataCollector.js';
|
|
6
6
|
/**
|
|
7
7
|
* Ref:
|
|
8
8
|
* - https://theora.org/doc/Theora.pdf
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const debug_1 = require("debug");
|
|
5
|
-
const Theora_1 = require("./Theora");
|
|
6
|
-
const debug = (0, debug_1.default)('music-metadata:parser:ogg:theora');
|
|
1
|
+
import initDebug from 'debug';
|
|
2
|
+
import { IdentificationHeader } from './Theora.js';
|
|
3
|
+
const debug = initDebug('music-metadata:parser:ogg:theora');
|
|
7
4
|
/**
|
|
8
5
|
* Ref:
|
|
9
6
|
* - https://theora.org/doc/Theora.pdf
|
|
10
7
|
*/
|
|
11
|
-
class TheoraParser {
|
|
8
|
+
export class TheoraParser {
|
|
12
9
|
constructor(metadata, options, tokenizer) {
|
|
13
10
|
this.metadata = metadata;
|
|
14
11
|
this.tokenizer = tokenizer;
|
|
@@ -37,8 +34,7 @@ class TheoraParser {
|
|
|
37
34
|
parseFirstPage(header, pageData) {
|
|
38
35
|
debug('First Ogg/Theora page');
|
|
39
36
|
this.metadata.setFormat('codec', 'Theora');
|
|
40
|
-
const idHeader =
|
|
37
|
+
const idHeader = IdentificationHeader.get(pageData, 0);
|
|
41
38
|
this.metadata.setFormat('bitrate', idHeader.nombr);
|
|
42
39
|
}
|
|
43
40
|
}
|
|
44
|
-
exports.TheoraParser = TheoraParser;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import { IPicture } from '../../type.js';
|
|
3
|
+
import { IGetToken } from 'strtok3/core';
|
|
4
4
|
/**
|
|
5
5
|
* Interface to parsed result of METADATA_BLOCK_PICTURE
|
|
6
6
|
* Ref: https://wiki.xiph.org/VorbisComment#METADATA_BLOCK_PICTURE
|
package/lib/ogg/vorbis/Vorbis.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.IdentificationHeader = exports.CommonHeader = exports.VorbisPictureToken = void 0;
|
|
4
|
-
const Token = require("token-types");
|
|
5
|
-
const ID3v2Token_1 = require("../../id3v2/ID3v2Token");
|
|
1
|
+
import * as Token from 'token-types';
|
|
2
|
+
import { AttachedPictureType } from '../../id3v2/ID3v2Token.js';
|
|
6
3
|
/**
|
|
7
4
|
* Parse the METADATA_BLOCK_PICTURE
|
|
8
5
|
* Ref: https://wiki.xiph.org/VorbisComment#METADATA_BLOCK_PICTURE
|
|
9
6
|
* Ref: https://xiph.org/flac/format.html#metadata_block_picture
|
|
10
7
|
* // ToDo: move to ID3 / APIC?
|
|
11
8
|
*/
|
|
12
|
-
class VorbisPictureToken {
|
|
9
|
+
export class VorbisPictureToken {
|
|
13
10
|
constructor(len) {
|
|
14
11
|
this.len = len;
|
|
15
12
|
}
|
|
@@ -21,7 +18,7 @@ class VorbisPictureToken {
|
|
|
21
18
|
return pic.get(buffer, 0);
|
|
22
19
|
}
|
|
23
20
|
get(buffer, offset) {
|
|
24
|
-
const type =
|
|
21
|
+
const type = AttachedPictureType[Token.UINT32_BE.get(buffer, offset)];
|
|
25
22
|
const mimeLen = Token.UINT32_BE.get(buffer, offset += 4);
|
|
26
23
|
const format = buffer.toString('utf-8', offset += 4, offset + mimeLen);
|
|
27
24
|
const descLen = Token.UINT32_BE.get(buffer, offset += mimeLen);
|
|
@@ -44,12 +41,11 @@ class VorbisPictureToken {
|
|
|
44
41
|
};
|
|
45
42
|
}
|
|
46
43
|
}
|
|
47
|
-
exports.VorbisPictureToken = VorbisPictureToken;
|
|
48
44
|
/**
|
|
49
45
|
* Comment header decoder
|
|
50
46
|
* Ref: https://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-620004.2.1
|
|
51
47
|
*/
|
|
52
|
-
|
|
48
|
+
export const CommonHeader = {
|
|
53
49
|
len: 7,
|
|
54
50
|
get: (buf, off) => {
|
|
55
51
|
return {
|
|
@@ -62,7 +58,7 @@ exports.CommonHeader = {
|
|
|
62
58
|
* Identification header decoder
|
|
63
59
|
* Ref: https://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-630004.2.2
|
|
64
60
|
*/
|
|
65
|
-
|
|
61
|
+
export const IdentificationHeader = {
|
|
66
62
|
len: 23,
|
|
67
63
|
get: (uint8Array, off) => {
|
|
68
64
|
const dataView = new DataView(uint8Array.buffer, uint8Array.byteOffset);
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.VorbisDecoder = void 0;
|
|
4
|
-
const Token = require("token-types");
|
|
5
|
-
class VorbisDecoder {
|
|
1
|
+
import * as Token from 'token-types';
|
|
2
|
+
export class VorbisDecoder {
|
|
6
3
|
constructor(data, offset) {
|
|
7
4
|
this.data = data;
|
|
8
5
|
this.offset = offset;
|
|
@@ -29,4 +26,3 @@ class VorbisDecoder {
|
|
|
29
26
|
};
|
|
30
27
|
}
|
|
31
28
|
}
|
|
32
|
-
exports.VorbisDecoder = VorbisDecoder;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import { IVorbisPicture } from './Vorbis.js';
|
|
3
|
+
import { IPageConsumer, IPageHeader } from '../Ogg.js';
|
|
4
|
+
import { IOptions } from '../../type.js';
|
|
5
|
+
import { INativeMetadataCollector } from '../../common/MetadataCollector.js';
|
|
6
6
|
/**
|
|
7
7
|
* Vorbis 1 Parser.
|
|
8
8
|
* Used by OggParser
|
|
9
9
|
*/
|
|
10
|
-
export declare class VorbisParser implements
|
|
10
|
+
export declare class VorbisParser implements IPageConsumer {
|
|
11
11
|
protected metadata: INativeMetadataCollector;
|
|
12
12
|
protected options: IOptions;
|
|
13
13
|
private pageSegments;
|
|
@@ -17,17 +17,17 @@ export declare class VorbisParser implements Ogg.IPageConsumer {
|
|
|
17
17
|
* @param header Ogg Page Header
|
|
18
18
|
* @param pageData Page data
|
|
19
19
|
*/
|
|
20
|
-
parsePage(header:
|
|
20
|
+
parsePage(header: IPageHeader, pageData: Buffer): void;
|
|
21
21
|
flush(): void;
|
|
22
22
|
parseUserComment(pageData: Buffer, offset: number): number;
|
|
23
23
|
addTag(id: string, value: string | IVorbisPicture): void;
|
|
24
|
-
calculateDuration(header:
|
|
24
|
+
calculateDuration(header: IPageHeader): void;
|
|
25
25
|
/**
|
|
26
26
|
* Parse first Ogg/Vorbis page
|
|
27
|
-
* @param
|
|
28
|
-
* @param
|
|
27
|
+
* @param header
|
|
28
|
+
* @param pageData
|
|
29
29
|
*/
|
|
30
|
-
protected parseFirstPage(header:
|
|
30
|
+
protected parseFirstPage(header: IPageHeader, pageData: Buffer): void;
|
|
31
31
|
protected parseFullPage(pageData: Buffer): void;
|
|
32
32
|
/**
|
|
33
33
|
* Ref: https://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-840005.2
|