music-metadata 7.11.3 → 7.11.7
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 +432 -432
- package/lib/ParserFactory.d.ts +49 -49
- package/lib/ParserFactory.js +251 -251
- package/lib/aiff/AiffParser.d.ts +15 -15
- package/lib/aiff/AiffParser.js +85 -85
- package/lib/aiff/AiffToken.d.ts +22 -22
- package/lib/aiff/AiffToken.js +43 -43
- package/lib/apev2/APEv2Parser.d.ts +30 -30
- package/lib/apev2/APEv2Parser.js +162 -162
- package/lib/apev2/APEv2TagMapper.d.ts +4 -4
- package/lib/apev2/APEv2TagMapper.js +87 -86
- package/lib/apev2/APEv2Token.d.ts +100 -100
- package/lib/apev2/APEv2Token.js +127 -126
- package/lib/asf/AsfObject.d.ts +319 -319
- package/lib/asf/AsfObject.js +384 -384
- package/lib/asf/AsfParser.d.ts +17 -17
- package/lib/asf/AsfParser.js +135 -135
- package/lib/asf/AsfTagMapper.d.ts +7 -7
- package/lib/asf/AsfTagMapper.js +96 -95
- package/lib/asf/AsfUtil.d.ts +13 -13
- package/lib/asf/AsfUtil.js +40 -40
- package/lib/asf/GUID.d.ts +86 -86
- package/lib/asf/GUID.js +123 -123
- package/lib/common/BasicParser.d.ts +17 -17
- package/lib/common/BasicParser.js +18 -18
- package/lib/common/CaseInsensitiveTagMap.d.ts +10 -10
- package/lib/common/CaseInsensitiveTagMap.js +22 -21
- package/lib/common/CombinedTagMapper.d.ts +19 -19
- package/lib/common/CombinedTagMapper.js +52 -51
- package/lib/common/FourCC.d.ts +6 -6
- package/lib/common/FourCC.js +29 -28
- package/lib/common/GenericTagMapper.d.ts +51 -51
- package/lib/common/GenericTagMapper.js +56 -55
- package/lib/common/GenericTagTypes.d.ts +33 -33
- package/lib/common/GenericTagTypes.js +132 -131
- package/lib/common/MetadataCollector.d.ts +76 -76
- package/lib/common/MetadataCollector.js +276 -274
- package/lib/common/RandomFileReader.d.ts +20 -20
- package/lib/common/RandomFileReader.js +37 -37
- package/lib/common/RandomUint8ArrayReader.d.ts +18 -18
- package/lib/common/RandomUint8ArrayReader.js +25 -25
- package/lib/common/Util.d.ts +58 -57
- package/lib/common/Util.js +163 -169
- package/lib/core.d.ts +48 -48
- package/lib/core.js +90 -90
- package/lib/dsdiff/DsdiffParser.d.ts +14 -14
- package/lib/dsdiff/DsdiffParser.js +143 -143
- package/lib/dsdiff/DsdiffToken.d.ts +9 -9
- package/lib/dsdiff/DsdiffToken.js +21 -21
- package/lib/dsf/DsfChunk.d.ts +86 -86
- package/lib/dsf/DsfChunk.js +54 -54
- package/lib/dsf/DsfParser.d.ts +9 -9
- package/lib/dsf/DsfParser.js +56 -56
- package/lib/flac/FlacParser.d.ts +28 -28
- package/lib/flac/FlacParser.js +175 -175
- package/lib/id3v1/ID3v1Parser.d.ts +13 -13
- package/lib/id3v1/ID3v1Parser.js +134 -134
- package/lib/id3v1/ID3v1TagMap.d.ts +4 -4
- package/lib/id3v1/ID3v1TagMap.js +23 -22
- package/lib/id3v2/AbstractID3Parser.d.ts +17 -17
- package/lib/id3v2/AbstractID3Parser.js +60 -60
- package/lib/id3v2/FrameParser.d.ts +32 -32
- package/lib/id3v2/FrameParser.js +329 -323
- package/lib/id3v2/ID3v22TagMapper.d.ts +9 -9
- package/lib/id3v2/ID3v22TagMapper.js +56 -54
- package/lib/id3v2/ID3v24TagMapper.d.ts +14 -14
- package/lib/id3v2/ID3v24TagMapper.js +194 -193
- package/lib/id3v2/ID3v2Parser.d.ts +29 -29
- package/lib/id3v2/ID3v2Parser.js +194 -194
- package/lib/id3v2/ID3v2Token.d.ts +73 -73
- package/lib/id3v2/ID3v2Token.js +106 -106
- package/lib/iff/index.d.ts +33 -33
- package/lib/iff/index.js +19 -19
- package/lib/index.d.ts +45 -34
- package/lib/index.js +74 -64
- package/lib/lyrics3/Lyrics3.d.ts +3 -3
- package/lib/lyrics3/Lyrics3.js +17 -17
- package/lib/matroska/MatroskaDtd.d.ts +8 -8
- package/lib/matroska/MatroskaDtd.js +279 -279
- package/lib/matroska/MatroskaParser.d.ts +37 -37
- package/lib/matroska/MatroskaParser.js +235 -234
- package/lib/matroska/MatroskaTagMapper.d.ts +4 -4
- package/lib/matroska/MatroskaTagMapper.js +36 -35
- package/lib/matroska/types.d.ts +175 -175
- package/lib/matroska/types.js +32 -32
- package/lib/mp4/Atom.d.ts +16 -16
- package/lib/mp4/Atom.js +70 -70
- package/lib/mp4/AtomToken.d.ts +395 -395
- package/lib/mp4/AtomToken.js +406 -406
- package/lib/mp4/MP4Parser.d.ts +30 -30
- package/lib/mp4/MP4Parser.js +511 -511
- package/lib/mp4/MP4TagMapper.d.ts +5 -5
- package/lib/mp4/MP4TagMapper.js +116 -115
- package/lib/mpeg/ExtendedLameHeader.d.ts +27 -27
- package/lib/mpeg/ExtendedLameHeader.js +31 -31
- package/lib/mpeg/MpegParser.d.ts +49 -49
- package/lib/mpeg/MpegParser.js +529 -529
- package/lib/mpeg/ReplayGainDataFormat.d.ts +55 -55
- package/lib/mpeg/ReplayGainDataFormat.js +69 -69
- package/lib/mpeg/XingTag.d.ts +45 -45
- package/lib/mpeg/XingTag.js +69 -69
- package/lib/musepack/index.d.ts +5 -5
- package/lib/musepack/index.js +32 -32
- package/lib/musepack/sv7/BitReader.d.ts +13 -13
- package/lib/musepack/sv7/BitReader.js +54 -54
- package/lib/musepack/sv7/MpcSv7Parser.d.ts +8 -8
- package/lib/musepack/sv7/MpcSv7Parser.js +46 -46
- package/lib/musepack/sv7/StreamVersion7.d.ts +28 -28
- package/lib/musepack/sv7/StreamVersion7.js +41 -41
- package/lib/musepack/sv8/MpcSv8Parser.d.ts +6 -6
- package/lib/musepack/sv8/MpcSv8Parser.js +55 -55
- package/lib/musepack/sv8/StreamVersion8.d.ts +40 -40
- package/lib/musepack/sv8/StreamVersion8.js +80 -80
- package/lib/ogg/Ogg.d.ts +72 -72
- package/lib/ogg/Ogg.js +2 -2
- package/lib/ogg/OggParser.d.ts +23 -23
- package/lib/ogg/OggParser.js +126 -126
- package/lib/ogg/opus/Opus.d.ts +48 -48
- package/lib/ogg/opus/Opus.js +28 -28
- package/lib/ogg/opus/OpusParser.d.ts +25 -25
- package/lib/ogg/opus/OpusParser.js +56 -56
- package/lib/ogg/speex/Speex.d.ts +36 -36
- package/lib/ogg/speex/Speex.js +31 -31
- package/lib/ogg/speex/SpeexParser.d.ts +22 -22
- package/lib/ogg/speex/SpeexParser.js +35 -35
- package/lib/ogg/theora/Theora.d.ts +20 -20
- package/lib/ogg/theora/Theora.js +23 -23
- package/lib/ogg/theora/TheoraParser.d.ts +28 -28
- package/lib/ogg/theora/TheoraParser.js +44 -44
- package/lib/ogg/vorbis/Vorbis.d.ts +79 -79
- package/lib/ogg/vorbis/Vorbis.js +78 -78
- package/lib/ogg/vorbis/VorbisDecoder.d.ts +12 -12
- package/lib/ogg/vorbis/VorbisDecoder.js +32 -32
- package/lib/ogg/vorbis/VorbisParser.d.ts +36 -36
- package/lib/ogg/vorbis/VorbisParser.js +128 -128
- package/lib/ogg/vorbis/VorbisTagMapper.d.ts +7 -7
- package/lib/ogg/vorbis/VorbisTagMapper.js +133 -132
- package/lib/riff/RiffChunk.d.ts +16 -16
- package/lib/riff/RiffChunk.js +32 -32
- package/lib/riff/RiffInfoTagMap.d.ts +10 -10
- package/lib/riff/RiffInfoTagMap.js +38 -37
- package/lib/type.d.ts +599 -599
- package/lib/type.js +14 -13
- package/lib/wav/WaveChunk.d.ts +64 -64
- package/lib/wav/WaveChunk.js +65 -65
- package/lib/wav/WaveParser.d.ts +24 -24
- package/lib/wav/WaveParser.js +144 -144
- package/lib/wavpack/WavPackParser.d.ts +14 -14
- package/lib/wavpack/WavPackParser.js +105 -105
- package/lib/wavpack/WavPackToken.d.ts +64 -64
- package/lib/wavpack/WavPackToken.js +76 -76
- package/package.json +142 -142
package/lib/ogg/opus/Opus.d.ts
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { IGetToken } from 'strtok3/lib/core';
|
|
2
|
-
/**
|
|
3
|
-
* Opus ID Header interface
|
|
4
|
-
* Ref: https://wiki.xiph.org/OggOpus#ID_Header
|
|
5
|
-
*/
|
|
6
|
-
export interface IIdHeader {
|
|
7
|
-
/**
|
|
8
|
-
* Magic signature: "OpusHead" (64 bits)
|
|
9
|
-
*/
|
|
10
|
-
magicSignature: string;
|
|
11
|
-
/**
|
|
12
|
-
* Version number (8 bits unsigned): 0x01 for this spec
|
|
13
|
-
*/
|
|
14
|
-
version: number;
|
|
15
|
-
/**
|
|
16
|
-
* Channel count 'c' (8 bits unsigned): MUST be > 0
|
|
17
|
-
*/
|
|
18
|
-
channelCount: number;
|
|
19
|
-
/**
|
|
20
|
-
* Pre-skip (16 bits unsigned, little endian)
|
|
21
|
-
*/
|
|
22
|
-
preSkip: number;
|
|
23
|
-
/**
|
|
24
|
-
* Input sample rate (32 bits unsigned, little endian): informational only
|
|
25
|
-
*/
|
|
26
|
-
inputSampleRate: number;
|
|
27
|
-
/**
|
|
28
|
-
* Output gain (16 bits, little endian, signed Q7.8 in dB) to apply when decoding
|
|
29
|
-
*/
|
|
30
|
-
outputGain: number;
|
|
31
|
-
/**
|
|
32
|
-
* Channel mapping family (8 bits unsigned)
|
|
33
|
-
* - 0 = one stream: mono or L,R stereo
|
|
34
|
-
* - 1 = channels in vorbis spec order: mono or L,R stereo or ... or FL,C,FR,RL,RR,LFE, ...
|
|
35
|
-
* - 2..254 = reserved (treat as 255)
|
|
36
|
-
* - 255 = no defined channel meaning
|
|
37
|
-
*/
|
|
38
|
-
channelMapping: number;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Opus ID Header parser
|
|
42
|
-
* Ref: https://wiki.xiph.org/OggOpus#ID_Header
|
|
43
|
-
*/
|
|
44
|
-
export declare class IdHeader implements IGetToken<IIdHeader> {
|
|
45
|
-
len: number;
|
|
46
|
-
constructor(len: number);
|
|
47
|
-
get(buf: any, off: any): IIdHeader;
|
|
48
|
-
}
|
|
1
|
+
import { IGetToken } from 'strtok3/lib/core';
|
|
2
|
+
/**
|
|
3
|
+
* Opus ID Header interface
|
|
4
|
+
* Ref: https://wiki.xiph.org/OggOpus#ID_Header
|
|
5
|
+
*/
|
|
6
|
+
export interface IIdHeader {
|
|
7
|
+
/**
|
|
8
|
+
* Magic signature: "OpusHead" (64 bits)
|
|
9
|
+
*/
|
|
10
|
+
magicSignature: string;
|
|
11
|
+
/**
|
|
12
|
+
* Version number (8 bits unsigned): 0x01 for this spec
|
|
13
|
+
*/
|
|
14
|
+
version: number;
|
|
15
|
+
/**
|
|
16
|
+
* Channel count 'c' (8 bits unsigned): MUST be > 0
|
|
17
|
+
*/
|
|
18
|
+
channelCount: number;
|
|
19
|
+
/**
|
|
20
|
+
* Pre-skip (16 bits unsigned, little endian)
|
|
21
|
+
*/
|
|
22
|
+
preSkip: number;
|
|
23
|
+
/**
|
|
24
|
+
* Input sample rate (32 bits unsigned, little endian): informational only
|
|
25
|
+
*/
|
|
26
|
+
inputSampleRate: number;
|
|
27
|
+
/**
|
|
28
|
+
* Output gain (16 bits, little endian, signed Q7.8 in dB) to apply when decoding
|
|
29
|
+
*/
|
|
30
|
+
outputGain: number;
|
|
31
|
+
/**
|
|
32
|
+
* Channel mapping family (8 bits unsigned)
|
|
33
|
+
* - 0 = one stream: mono or L,R stereo
|
|
34
|
+
* - 1 = channels in vorbis spec order: mono or L,R stereo or ... or FL,C,FR,RL,RR,LFE, ...
|
|
35
|
+
* - 2..254 = reserved (treat as 255)
|
|
36
|
+
* - 255 = no defined channel meaning
|
|
37
|
+
*/
|
|
38
|
+
channelMapping: number;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Opus ID Header parser
|
|
42
|
+
* Ref: https://wiki.xiph.org/OggOpus#ID_Header
|
|
43
|
+
*/
|
|
44
|
+
export declare class IdHeader implements IGetToken<IIdHeader> {
|
|
45
|
+
len: number;
|
|
46
|
+
constructor(len: number);
|
|
47
|
+
get(buf: any, off: any): IIdHeader;
|
|
48
|
+
}
|
package/lib/ogg/opus/Opus.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IdHeader = void 0;
|
|
4
|
-
const Token = require("token-types");
|
|
5
|
-
/**
|
|
6
|
-
* Opus ID Header parser
|
|
7
|
-
* Ref: https://wiki.xiph.org/OggOpus#ID_Header
|
|
8
|
-
*/
|
|
9
|
-
class IdHeader {
|
|
10
|
-
constructor(len) {
|
|
11
|
-
this.len = len;
|
|
12
|
-
if (len < 19) {
|
|
13
|
-
throw new Error("ID-header-page 0 should be at least 19 bytes long");
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
get(buf, off) {
|
|
17
|
-
return {
|
|
18
|
-
magicSignature: new Token.StringType(8, 'ascii').get(buf, off + 0),
|
|
19
|
-
version: buf.readUInt8(off + 8),
|
|
20
|
-
channelCount: buf.readUInt8(off + 9),
|
|
21
|
-
preSkip: buf.readInt16LE(off + 10),
|
|
22
|
-
inputSampleRate: buf.readInt32LE(off + 12),
|
|
23
|
-
outputGain: buf.readInt16LE(off + 16),
|
|
24
|
-
channelMapping: buf.readUInt8(off + 18)
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.IdHeader = IdHeader;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IdHeader = void 0;
|
|
4
|
+
const Token = require("token-types");
|
|
5
|
+
/**
|
|
6
|
+
* Opus ID Header parser
|
|
7
|
+
* Ref: https://wiki.xiph.org/OggOpus#ID_Header
|
|
8
|
+
*/
|
|
9
|
+
class IdHeader {
|
|
10
|
+
constructor(len) {
|
|
11
|
+
this.len = len;
|
|
12
|
+
if (len < 19) {
|
|
13
|
+
throw new Error("ID-header-page 0 should be at least 19 bytes long");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
get(buf, off) {
|
|
17
|
+
return {
|
|
18
|
+
magicSignature: new Token.StringType(8, 'ascii').get(buf, off + 0),
|
|
19
|
+
version: buf.readUInt8(off + 8),
|
|
20
|
+
channelCount: buf.readUInt8(off + 9),
|
|
21
|
+
preSkip: buf.readInt16LE(off + 10),
|
|
22
|
+
inputSampleRate: buf.readInt32LE(off + 12),
|
|
23
|
+
outputGain: buf.readInt16LE(off + 16),
|
|
24
|
+
channelMapping: buf.readUInt8(off + 18)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.IdHeader = IdHeader;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { ITokenizer } from 'strtok3/lib/core';
|
|
3
|
-
import { IPageHeader } from '../Ogg';
|
|
4
|
-
import { VorbisParser } from '../vorbis/VorbisParser';
|
|
5
|
-
import { IOptions } from '../../type';
|
|
6
|
-
import { INativeMetadataCollector } from '../../common/MetadataCollector';
|
|
7
|
-
/**
|
|
8
|
-
* Opus parser
|
|
9
|
-
* Internet Engineering Task Force (IETF) - RFC 6716
|
|
10
|
-
* Used by OggParser
|
|
11
|
-
*/
|
|
12
|
-
export declare class OpusParser extends VorbisParser {
|
|
13
|
-
private tokenizer;
|
|
14
|
-
private idHeader;
|
|
15
|
-
private lastPos;
|
|
16
|
-
constructor(metadata: INativeMetadataCollector, options: IOptions, tokenizer: ITokenizer);
|
|
17
|
-
/**
|
|
18
|
-
* Parse first Opus Ogg page
|
|
19
|
-
* @param {IPageHeader} header
|
|
20
|
-
* @param {Buffer} pageData
|
|
21
|
-
*/
|
|
22
|
-
protected parseFirstPage(header: IPageHeader, pageData: Buffer): void;
|
|
23
|
-
protected parseFullPage(pageData: Buffer): void;
|
|
24
|
-
calculateDuration(header: IPageHeader): void;
|
|
25
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ITokenizer } from 'strtok3/lib/core';
|
|
3
|
+
import { IPageHeader } from '../Ogg';
|
|
4
|
+
import { VorbisParser } from '../vorbis/VorbisParser';
|
|
5
|
+
import { IOptions } from '../../type';
|
|
6
|
+
import { INativeMetadataCollector } from '../../common/MetadataCollector';
|
|
7
|
+
/**
|
|
8
|
+
* Opus parser
|
|
9
|
+
* Internet Engineering Task Force (IETF) - RFC 6716
|
|
10
|
+
* Used by OggParser
|
|
11
|
+
*/
|
|
12
|
+
export declare class OpusParser extends VorbisParser {
|
|
13
|
+
private tokenizer;
|
|
14
|
+
private idHeader;
|
|
15
|
+
private lastPos;
|
|
16
|
+
constructor(metadata: INativeMetadataCollector, options: IOptions, tokenizer: ITokenizer);
|
|
17
|
+
/**
|
|
18
|
+
* Parse first Opus Ogg page
|
|
19
|
+
* @param {IPageHeader} header
|
|
20
|
+
* @param {Buffer} pageData
|
|
21
|
+
*/
|
|
22
|
+
protected parseFirstPage(header: IPageHeader, pageData: Buffer): void;
|
|
23
|
+
protected parseFullPage(pageData: Buffer): void;
|
|
24
|
+
calculateDuration(header: IPageHeader): void;
|
|
25
|
+
}
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OpusParser = void 0;
|
|
4
|
-
const Token = require("token-types");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
/**
|
|
8
|
-
* Opus parser
|
|
9
|
-
* Internet Engineering Task Force (IETF) - RFC 6716
|
|
10
|
-
* Used by OggParser
|
|
11
|
-
*/
|
|
12
|
-
class OpusParser extends VorbisParser_1.VorbisParser {
|
|
13
|
-
constructor(metadata, options, tokenizer) {
|
|
14
|
-
super(metadata, options);
|
|
15
|
-
this.tokenizer = tokenizer;
|
|
16
|
-
this.lastPos = -1;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Parse first Opus Ogg page
|
|
20
|
-
* @param {IPageHeader} header
|
|
21
|
-
* @param {Buffer} pageData
|
|
22
|
-
*/
|
|
23
|
-
parseFirstPage(header, pageData) {
|
|
24
|
-
this.metadata.setFormat('codec', 'Opus');
|
|
25
|
-
// Parse Opus ID Header
|
|
26
|
-
this.idHeader = new Opus.IdHeader(pageData.length).get(pageData, 0);
|
|
27
|
-
if (this.idHeader.magicSignature !== "OpusHead")
|
|
28
|
-
throw new Error("Illegal ogg/Opus magic-signature");
|
|
29
|
-
this.metadata.setFormat('sampleRate', this.idHeader.inputSampleRate);
|
|
30
|
-
this.metadata.setFormat('numberOfChannels', this.idHeader.channelCount);
|
|
31
|
-
}
|
|
32
|
-
parseFullPage(pageData) {
|
|
33
|
-
const magicSignature = new Token.StringType(8, 'ascii').get(pageData, 0);
|
|
34
|
-
switch (magicSignature) {
|
|
35
|
-
case 'OpusTags':
|
|
36
|
-
this.parseUserCommentList(pageData, 8);
|
|
37
|
-
this.lastPos = this.tokenizer.position - pageData.length;
|
|
38
|
-
break;
|
|
39
|
-
default:
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
calculateDuration(header) {
|
|
44
|
-
if (this.metadata.format.sampleRate && header.absoluteGranulePosition >= 0) {
|
|
45
|
-
// Calculate duration
|
|
46
|
-
const pos_48bit = header.absoluteGranulePosition - this.idHeader.preSkip;
|
|
47
|
-
this.metadata.setFormat('numberOfSamples', pos_48bit);
|
|
48
|
-
this.metadata.setFormat('duration', pos_48bit / 48000);
|
|
49
|
-
if (this.lastPos !== -1 && this.tokenizer.fileInfo.size && this.metadata.format.duration) {
|
|
50
|
-
const dataSize = this.tokenizer.fileInfo.size - this.lastPos;
|
|
51
|
-
this.metadata.setFormat('bitrate', 8 * dataSize / this.metadata.format.duration);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
exports.OpusParser = OpusParser;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OpusParser = void 0;
|
|
4
|
+
const Token = require("token-types");
|
|
5
|
+
const VorbisParser_1 = require("../vorbis/VorbisParser");
|
|
6
|
+
const Opus = require("./Opus");
|
|
7
|
+
/**
|
|
8
|
+
* Opus parser
|
|
9
|
+
* Internet Engineering Task Force (IETF) - RFC 6716
|
|
10
|
+
* Used by OggParser
|
|
11
|
+
*/
|
|
12
|
+
class OpusParser extends VorbisParser_1.VorbisParser {
|
|
13
|
+
constructor(metadata, options, tokenizer) {
|
|
14
|
+
super(metadata, options);
|
|
15
|
+
this.tokenizer = tokenizer;
|
|
16
|
+
this.lastPos = -1;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Parse first Opus Ogg page
|
|
20
|
+
* @param {IPageHeader} header
|
|
21
|
+
* @param {Buffer} pageData
|
|
22
|
+
*/
|
|
23
|
+
parseFirstPage(header, pageData) {
|
|
24
|
+
this.metadata.setFormat('codec', 'Opus');
|
|
25
|
+
// Parse Opus ID Header
|
|
26
|
+
this.idHeader = new Opus.IdHeader(pageData.length).get(pageData, 0);
|
|
27
|
+
if (this.idHeader.magicSignature !== "OpusHead")
|
|
28
|
+
throw new Error("Illegal ogg/Opus magic-signature");
|
|
29
|
+
this.metadata.setFormat('sampleRate', this.idHeader.inputSampleRate);
|
|
30
|
+
this.metadata.setFormat('numberOfChannels', this.idHeader.channelCount);
|
|
31
|
+
}
|
|
32
|
+
parseFullPage(pageData) {
|
|
33
|
+
const magicSignature = new Token.StringType(8, 'ascii').get(pageData, 0);
|
|
34
|
+
switch (magicSignature) {
|
|
35
|
+
case 'OpusTags':
|
|
36
|
+
this.parseUserCommentList(pageData, 8);
|
|
37
|
+
this.lastPos = this.tokenizer.position - pageData.length;
|
|
38
|
+
break;
|
|
39
|
+
default:
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
calculateDuration(header) {
|
|
44
|
+
if (this.metadata.format.sampleRate && header.absoluteGranulePosition >= 0) {
|
|
45
|
+
// Calculate duration
|
|
46
|
+
const pos_48bit = header.absoluteGranulePosition - this.idHeader.preSkip;
|
|
47
|
+
this.metadata.setFormat('numberOfSamples', pos_48bit);
|
|
48
|
+
this.metadata.setFormat('duration', pos_48bit / 48000);
|
|
49
|
+
if (this.lastPos !== -1 && this.tokenizer.fileInfo.size && this.metadata.format.duration) {
|
|
50
|
+
const dataSize = this.tokenizer.fileInfo.size - this.lastPos;
|
|
51
|
+
this.metadata.setFormat('bitrate', 8 * dataSize / this.metadata.format.duration);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.OpusParser = OpusParser;
|
package/lib/ogg/speex/Speex.d.ts
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { IGetToken } from 'strtok3/lib/core';
|
|
2
|
-
/**
|
|
3
|
-
* Speex Header Packet
|
|
4
|
-
* Ref: https://www.speex.org/docs/manual/speex-manual/node8.html#SECTION00830000000000000000
|
|
5
|
-
*/
|
|
6
|
-
export interface IHeader {
|
|
7
|
-
/**
|
|
8
|
-
* speex_string, char[] 8
|
|
9
|
-
*/
|
|
10
|
-
speex: string;
|
|
11
|
-
/**
|
|
12
|
-
* speex_version, char[] 20
|
|
13
|
-
*/
|
|
14
|
-
version: string;
|
|
15
|
-
/**
|
|
16
|
-
* Version id
|
|
17
|
-
*/
|
|
18
|
-
version_id: number;
|
|
19
|
-
header_size: number;
|
|
20
|
-
rate: number;
|
|
21
|
-
mode: number;
|
|
22
|
-
mode_bitstream_version: number;
|
|
23
|
-
nb_channels: number;
|
|
24
|
-
bitrate: number;
|
|
25
|
-
frame_size: number;
|
|
26
|
-
vbr: number;
|
|
27
|
-
frames_per_packet: number;
|
|
28
|
-
extra_headers: number;
|
|
29
|
-
reserved1: number;
|
|
30
|
-
reserved2: number;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Speex Header Packet
|
|
34
|
-
* Ref: https://www.speex.org/docs/manual/speex-manual/node8.html#SECTION00830000000000000000
|
|
35
|
-
*/
|
|
36
|
-
export declare const Header: IGetToken<IHeader>;
|
|
1
|
+
import { IGetToken } from 'strtok3/lib/core';
|
|
2
|
+
/**
|
|
3
|
+
* Speex Header Packet
|
|
4
|
+
* Ref: https://www.speex.org/docs/manual/speex-manual/node8.html#SECTION00830000000000000000
|
|
5
|
+
*/
|
|
6
|
+
export interface IHeader {
|
|
7
|
+
/**
|
|
8
|
+
* speex_string, char[] 8
|
|
9
|
+
*/
|
|
10
|
+
speex: string;
|
|
11
|
+
/**
|
|
12
|
+
* speex_version, char[] 20
|
|
13
|
+
*/
|
|
14
|
+
version: string;
|
|
15
|
+
/**
|
|
16
|
+
* Version id
|
|
17
|
+
*/
|
|
18
|
+
version_id: number;
|
|
19
|
+
header_size: number;
|
|
20
|
+
rate: number;
|
|
21
|
+
mode: number;
|
|
22
|
+
mode_bitstream_version: number;
|
|
23
|
+
nb_channels: number;
|
|
24
|
+
bitrate: number;
|
|
25
|
+
frame_size: number;
|
|
26
|
+
vbr: number;
|
|
27
|
+
frames_per_packet: number;
|
|
28
|
+
extra_headers: number;
|
|
29
|
+
reserved1: number;
|
|
30
|
+
reserved2: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Speex Header Packet
|
|
34
|
+
* Ref: https://www.speex.org/docs/manual/speex-manual/node8.html#SECTION00830000000000000000
|
|
35
|
+
*/
|
|
36
|
+
export declare const Header: IGetToken<IHeader>;
|
package/lib/ogg/speex/Speex.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Header = void 0;
|
|
4
|
-
const Token = require("token-types");
|
|
5
|
-
const util = require("../../common/Util");
|
|
6
|
-
/**
|
|
7
|
-
* Speex Header Packet
|
|
8
|
-
* Ref: https://www.speex.org/docs/manual/speex-manual/node8.html#SECTION00830000000000000000
|
|
9
|
-
*/
|
|
10
|
-
exports.Header = {
|
|
11
|
-
len: 80,
|
|
12
|
-
get: (buf, off) => {
|
|
13
|
-
return {
|
|
14
|
-
speex: new Token.StringType(8, 'ascii').get(buf, off + 0),
|
|
15
|
-
version: util.trimRightNull(new Token.StringType(20, 'ascii').get(buf, off + 8)),
|
|
16
|
-
version_id: buf.readInt32LE(off + 28),
|
|
17
|
-
header_size: buf.readInt32LE(off + 32),
|
|
18
|
-
rate: buf.readInt32LE(off + 36),
|
|
19
|
-
mode: buf.readInt32LE(off + 40),
|
|
20
|
-
mode_bitstream_version: buf.readInt32LE(off + 44),
|
|
21
|
-
nb_channels: buf.readInt32LE(off + 48),
|
|
22
|
-
bitrate: buf.readInt32LE(off + 52),
|
|
23
|
-
frame_size: buf.readInt32LE(off + 56),
|
|
24
|
-
vbr: buf.readInt32LE(off + 60),
|
|
25
|
-
frames_per_packet: buf.readInt32LE(off + 64),
|
|
26
|
-
extra_headers: buf.readInt32LE(off + 68),
|
|
27
|
-
reserved1: buf.readInt32LE(off + 72),
|
|
28
|
-
reserved2: buf.readInt32LE(off + 76)
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Header = void 0;
|
|
4
|
+
const Token = require("token-types");
|
|
5
|
+
const util = require("../../common/Util");
|
|
6
|
+
/**
|
|
7
|
+
* Speex Header Packet
|
|
8
|
+
* Ref: https://www.speex.org/docs/manual/speex-manual/node8.html#SECTION00830000000000000000
|
|
9
|
+
*/
|
|
10
|
+
exports.Header = {
|
|
11
|
+
len: 80,
|
|
12
|
+
get: (buf, off) => {
|
|
13
|
+
return {
|
|
14
|
+
speex: new Token.StringType(8, 'ascii').get(buf, off + 0),
|
|
15
|
+
version: util.trimRightNull(new Token.StringType(20, 'ascii').get(buf, off + 8)),
|
|
16
|
+
version_id: buf.readInt32LE(off + 28),
|
|
17
|
+
header_size: buf.readInt32LE(off + 32),
|
|
18
|
+
rate: buf.readInt32LE(off + 36),
|
|
19
|
+
mode: buf.readInt32LE(off + 40),
|
|
20
|
+
mode_bitstream_version: buf.readInt32LE(off + 44),
|
|
21
|
+
nb_channels: buf.readInt32LE(off + 48),
|
|
22
|
+
bitrate: buf.readInt32LE(off + 52),
|
|
23
|
+
frame_size: buf.readInt32LE(off + 56),
|
|
24
|
+
vbr: buf.readInt32LE(off + 60),
|
|
25
|
+
frames_per_packet: buf.readInt32LE(off + 64),
|
|
26
|
+
extra_headers: buf.readInt32LE(off + 68),
|
|
27
|
+
reserved1: buf.readInt32LE(off + 72),
|
|
28
|
+
reserved2: buf.readInt32LE(off + 76)
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
};
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { ITokenizer } from 'strtok3/lib/core';
|
|
3
|
-
import { IPageHeader } from '../Ogg';
|
|
4
|
-
import { VorbisParser } from '../vorbis/VorbisParser';
|
|
5
|
-
import { IOptions } from '../../type';
|
|
6
|
-
import { INativeMetadataCollector } from '../../common/MetadataCollector';
|
|
7
|
-
/**
|
|
8
|
-
* Speex, RFC 5574
|
|
9
|
-
* Ref:
|
|
10
|
-
* https://www.speex.org/docs/manual/speex-manual/
|
|
11
|
-
* https://tools.ietf.org/html/rfc5574
|
|
12
|
-
*/
|
|
13
|
-
export declare class SpeexParser extends VorbisParser {
|
|
14
|
-
private tokenizer;
|
|
15
|
-
constructor(metadata: INativeMetadataCollector, options: IOptions, tokenizer: ITokenizer);
|
|
16
|
-
/**
|
|
17
|
-
* Parse first Speex Ogg page
|
|
18
|
-
* @param {IPageHeader} header
|
|
19
|
-
* @param {Buffer} pageData
|
|
20
|
-
*/
|
|
21
|
-
protected parseFirstPage(header: IPageHeader, pageData: Buffer): void;
|
|
22
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ITokenizer } from 'strtok3/lib/core';
|
|
3
|
+
import { IPageHeader } from '../Ogg';
|
|
4
|
+
import { VorbisParser } from '../vorbis/VorbisParser';
|
|
5
|
+
import { IOptions } from '../../type';
|
|
6
|
+
import { INativeMetadataCollector } from '../../common/MetadataCollector';
|
|
7
|
+
/**
|
|
8
|
+
* Speex, RFC 5574
|
|
9
|
+
* Ref:
|
|
10
|
+
* https://www.speex.org/docs/manual/speex-manual/
|
|
11
|
+
* https://tools.ietf.org/html/rfc5574
|
|
12
|
+
*/
|
|
13
|
+
export declare class SpeexParser extends VorbisParser {
|
|
14
|
+
private tokenizer;
|
|
15
|
+
constructor(metadata: INativeMetadataCollector, options: IOptions, tokenizer: ITokenizer);
|
|
16
|
+
/**
|
|
17
|
+
* Parse first Speex Ogg page
|
|
18
|
+
* @param {IPageHeader} header
|
|
19
|
+
* @param {Buffer} pageData
|
|
20
|
+
*/
|
|
21
|
+
protected parseFirstPage(header: IPageHeader, pageData: Buffer): void;
|
|
22
|
+
}
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SpeexParser = void 0;
|
|
4
|
-
const initDebug = require("debug");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const debug = initDebug('music-metadata:parser:ogg:speex');
|
|
8
|
-
/**
|
|
9
|
-
* Speex, RFC 5574
|
|
10
|
-
* Ref:
|
|
11
|
-
* https://www.speex.org/docs/manual/speex-manual/
|
|
12
|
-
* https://tools.ietf.org/html/rfc5574
|
|
13
|
-
*/
|
|
14
|
-
class SpeexParser extends VorbisParser_1.VorbisParser {
|
|
15
|
-
constructor(metadata, options, tokenizer) {
|
|
16
|
-
super(metadata, options);
|
|
17
|
-
this.tokenizer = tokenizer;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Parse first Speex Ogg page
|
|
21
|
-
* @param {IPageHeader} header
|
|
22
|
-
* @param {Buffer} pageData
|
|
23
|
-
*/
|
|
24
|
-
parseFirstPage(header, pageData) {
|
|
25
|
-
debug('First Ogg/Speex page');
|
|
26
|
-
const speexHeader = Speex.Header.get(pageData, 0);
|
|
27
|
-
this.metadata.setFormat('codec', `Speex ${speexHeader.version}`);
|
|
28
|
-
this.metadata.setFormat('numberOfChannels', speexHeader.nb_channels);
|
|
29
|
-
this.metadata.setFormat('sampleRate', speexHeader.rate);
|
|
30
|
-
if (speexHeader.bitrate !== -1) {
|
|
31
|
-
this.metadata.setFormat('bitrate', speexHeader.bitrate);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.SpeexParser = SpeexParser;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SpeexParser = void 0;
|
|
4
|
+
const initDebug = require("debug");
|
|
5
|
+
const VorbisParser_1 = require("../vorbis/VorbisParser");
|
|
6
|
+
const Speex = require("./Speex");
|
|
7
|
+
const debug = initDebug('music-metadata:parser:ogg:speex');
|
|
8
|
+
/**
|
|
9
|
+
* Speex, RFC 5574
|
|
10
|
+
* Ref:
|
|
11
|
+
* https://www.speex.org/docs/manual/speex-manual/
|
|
12
|
+
* https://tools.ietf.org/html/rfc5574
|
|
13
|
+
*/
|
|
14
|
+
class SpeexParser extends VorbisParser_1.VorbisParser {
|
|
15
|
+
constructor(metadata, options, tokenizer) {
|
|
16
|
+
super(metadata, options);
|
|
17
|
+
this.tokenizer = tokenizer;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Parse first Speex Ogg page
|
|
21
|
+
* @param {IPageHeader} header
|
|
22
|
+
* @param {Buffer} pageData
|
|
23
|
+
*/
|
|
24
|
+
parseFirstPage(header, pageData) {
|
|
25
|
+
debug('First Ogg/Speex page');
|
|
26
|
+
const speexHeader = Speex.Header.get(pageData, 0);
|
|
27
|
+
this.metadata.setFormat('codec', `Speex ${speexHeader.version}`);
|
|
28
|
+
this.metadata.setFormat('numberOfChannels', speexHeader.nb_channels);
|
|
29
|
+
this.metadata.setFormat('sampleRate', speexHeader.rate);
|
|
30
|
+
if (speexHeader.bitrate !== -1) {
|
|
31
|
+
this.metadata.setFormat('bitrate', speexHeader.bitrate);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.SpeexParser = SpeexParser;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { IGetToken } from 'strtok3/lib/core';
|
|
2
|
-
/**
|
|
3
|
-
* 6.2 Identification Header
|
|
4
|
-
* Ref: https://theora.org/doc/Theora.pdf: 6.2 Identification Header Decode
|
|
5
|
-
*/
|
|
6
|
-
export interface IIdentificationHeader {
|
|
7
|
-
id: string;
|
|
8
|
-
vmaj: number;
|
|
9
|
-
vmin: number;
|
|
10
|
-
vrev: number;
|
|
11
|
-
vmbw: number;
|
|
12
|
-
vmbh: number;
|
|
13
|
-
nombr: number;
|
|
14
|
-
nqual: number;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* 6.2 Identification Header
|
|
18
|
-
* Ref: https://theora.org/doc/Theora.pdf: 6.2 Identification Header Decode
|
|
19
|
-
*/
|
|
20
|
-
export declare const IdentificationHeader: IGetToken<IIdentificationHeader>;
|
|
1
|
+
import { IGetToken } from 'strtok3/lib/core';
|
|
2
|
+
/**
|
|
3
|
+
* 6.2 Identification Header
|
|
4
|
+
* Ref: https://theora.org/doc/Theora.pdf: 6.2 Identification Header Decode
|
|
5
|
+
*/
|
|
6
|
+
export interface IIdentificationHeader {
|
|
7
|
+
id: string;
|
|
8
|
+
vmaj: number;
|
|
9
|
+
vmin: number;
|
|
10
|
+
vrev: number;
|
|
11
|
+
vmbw: number;
|
|
12
|
+
vmbh: number;
|
|
13
|
+
nombr: number;
|
|
14
|
+
nqual: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 6.2 Identification Header
|
|
18
|
+
* Ref: https://theora.org/doc/Theora.pdf: 6.2 Identification Header Decode
|
|
19
|
+
*/
|
|
20
|
+
export declare const IdentificationHeader: IGetToken<IIdentificationHeader>;
|
package/lib/ogg/theora/Theora.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IdentificationHeader = void 0;
|
|
4
|
-
const Token = require("token-types");
|
|
5
|
-
/**
|
|
6
|
-
* 6.2 Identification Header
|
|
7
|
-
* Ref: https://theora.org/doc/Theora.pdf: 6.2 Identification Header Decode
|
|
8
|
-
*/
|
|
9
|
-
exports.IdentificationHeader = {
|
|
10
|
-
len: 42,
|
|
11
|
-
get: (buf, off) => {
|
|
12
|
-
return {
|
|
13
|
-
id: new Token.StringType(7, 'ascii').get(buf, off),
|
|
14
|
-
vmaj: buf.readUInt8(off + 7),
|
|
15
|
-
vmin: buf.readUInt8(off + 8),
|
|
16
|
-
vrev: buf.readUInt8(off + 9),
|
|
17
|
-
vmbw: buf.readUInt16BE(off + 10),
|
|
18
|
-
vmbh: buf.readUInt16BE(off + 17),
|
|
19
|
-
nombr: Token.UINT24_BE.get(buf, off + 37),
|
|
20
|
-
nqual: buf.readUInt8(off + 40)
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IdentificationHeader = void 0;
|
|
4
|
+
const Token = require("token-types");
|
|
5
|
+
/**
|
|
6
|
+
* 6.2 Identification Header
|
|
7
|
+
* Ref: https://theora.org/doc/Theora.pdf: 6.2 Identification Header Decode
|
|
8
|
+
*/
|
|
9
|
+
exports.IdentificationHeader = {
|
|
10
|
+
len: 42,
|
|
11
|
+
get: (buf, off) => {
|
|
12
|
+
return {
|
|
13
|
+
id: new Token.StringType(7, 'ascii').get(buf, off),
|
|
14
|
+
vmaj: buf.readUInt8(off + 7),
|
|
15
|
+
vmin: buf.readUInt8(off + 8),
|
|
16
|
+
vrev: buf.readUInt8(off + 9),
|
|
17
|
+
vmbw: buf.readUInt16BE(off + 10),
|
|
18
|
+
vmbh: buf.readUInt16BE(off + 17),
|
|
19
|
+
nombr: Token.UINT24_BE.get(buf, off + 37),
|
|
20
|
+
nqual: buf.readUInt8(off + 40)
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
};
|