music-metadata 10.1.0 → 10.3.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 +465 -141
- package/lib/ParseError.d.ts +87 -0
- package/lib/ParseError.js +39 -0
- package/lib/ParserFactory.d.ts +1 -1
- package/lib/ParserFactory.js +9 -8
- package/lib/aiff/AiffParser.js +6 -7
- package/lib/aiff/AiffToken.d.ts +15 -0
- package/lib/aiff/AiffToken.js +5 -2
- package/lib/apev2/APEv2Parser.d.ts +15 -0
- package/lib/apev2/APEv2Parser.js +6 -3
- package/lib/asf/AsfObject.d.ts +15 -0
- package/lib/asf/AsfObject.js +4 -1
- package/lib/asf/AsfParser.js +2 -1
- package/lib/common/CombinedTagMapper.js +2 -1
- package/lib/common/FourCC.js +3 -2
- package/lib/common/MetadataCollector.js +2 -4
- package/lib/common/Util.js +3 -2
- package/lib/core.d.ts +2 -1
- package/lib/core.js +1 -1
- package/lib/default.cjs +5 -0
- package/lib/dsdiff/DsdiffParser.d.ts +15 -0
- package/lib/dsdiff/DsdiffParser.js +6 -3
- package/lib/dsf/DsfParser.d.ts +15 -0
- package/lib/dsf/DsfParser.js +4 -1
- package/lib/ebml/EbmlIterator.d.ts +67 -0
- package/lib/ebml/EbmlIterator.js +223 -0
- package/lib/ebml/types.d.ts +36 -0
- package/lib/ebml/types.js +10 -0
- package/lib/flac/FlacParser.js +5 -2
- package/lib/id3v2/FrameParser.d.ts +14 -0
- package/lib/id3v2/FrameParser.js +7 -1
- package/lib/id3v2/ID3v2Parser.js +10 -8
- package/lib/matroska/MatroskaDtd.d.ts +2 -2
- package/lib/matroska/MatroskaDtd.js +246 -239
- package/lib/matroska/MatroskaParser.d.ts +8 -22
- package/lib/matroska/MatroskaParser.js +119 -204
- package/lib/matroska/types.d.ts +8 -44
- package/lib/matroska/types.js +0 -9
- package/lib/mp4/AtomToken.d.ts +14 -0
- package/lib/mp4/AtomToken.js +6 -3
- package/lib/mp4/MP4Parser.js +4 -3
- package/lib/mpeg/MpegParser.d.ts +15 -0
- package/lib/mpeg/MpegParser.js +7 -4
- package/lib/musepack/MusepackConentError.d.ts +15 -0
- package/lib/musepack/MusepackConentError.js +4 -0
- package/lib/musepack/index.js +4 -3
- package/lib/musepack/sv7/MpcSv7Parser.js +2 -1
- package/lib/musepack/sv8/MpcSv8Parser.js +3 -2
- package/lib/node.cjs +5 -0
- package/lib/ogg/OggParser.d.ts +15 -0
- package/lib/ogg/OggParser.js +5 -2
- package/lib/ogg/opus/Opus.d.ts +15 -0
- package/lib/ogg/opus/Opus.js +4 -1
- package/lib/ogg/opus/OpusParser.js +2 -1
- package/lib/ogg/vorbis/VorbisParser.d.ts +15 -0
- package/lib/ogg/vorbis/VorbisParser.js +6 -3
- package/lib/type.d.ts +9 -0
- package/lib/wav/WaveChunk.d.ts +15 -0
- package/lib/wav/WaveChunk.js +5 -2
- package/lib/wav/WaveParser.js +3 -2
- package/lib/wavpack/WavPackParser.d.ts +15 -0
- package/lib/wavpack/WavPackParser.js +6 -3
- package/package.json +20 -11
|
@@ -3,6 +3,7 @@ import { BasicParser } from '../../common/BasicParser.js';
|
|
|
3
3
|
import { APEv2Parser } from '../../apev2/APEv2Parser.js';
|
|
4
4
|
import { BitReader } from './BitReader.js';
|
|
5
5
|
import * as SV7 from './StreamVersion7.js';
|
|
6
|
+
import { MusepackContentError } from '../MusepackConentError.js';
|
|
6
7
|
const debug = initDebug('music-metadata:parser:musepack');
|
|
7
8
|
export class MpcSv7Parser extends BasicParser {
|
|
8
9
|
constructor() {
|
|
@@ -14,7 +15,7 @@ export class MpcSv7Parser extends BasicParser {
|
|
|
14
15
|
async parse() {
|
|
15
16
|
const header = await this.tokenizer.readToken(SV7.Header);
|
|
16
17
|
if (header.signature !== 'MP+')
|
|
17
|
-
throw new
|
|
18
|
+
throw new MusepackContentError('Unexpected magic number');
|
|
18
19
|
debug(`stream-version=${header.streamMajorVersion}.${header.streamMinorVersion}`);
|
|
19
20
|
this.metadata.setFormat('container', 'Musepack, SV7');
|
|
20
21
|
this.metadata.setFormat('sampleRate', header.sampleFrequency);
|
|
@@ -3,6 +3,7 @@ import { BasicParser } from '../../common/BasicParser.js';
|
|
|
3
3
|
import { APEv2Parser } from '../../apev2/APEv2Parser.js';
|
|
4
4
|
import { FourCcToken } from '../../common/FourCC.js';
|
|
5
5
|
import * as SV8 from './StreamVersion8.js';
|
|
6
|
+
import { MusepackContentError } from '../MusepackConentError.js';
|
|
6
7
|
const debug = initDebug('music-metadata:parser:musepack');
|
|
7
8
|
export class MpcSv8Parser extends BasicParser {
|
|
8
9
|
constructor() {
|
|
@@ -12,7 +13,7 @@ export class MpcSv8Parser extends BasicParser {
|
|
|
12
13
|
async parse() {
|
|
13
14
|
const signature = await this.tokenizer.readToken(FourCcToken);
|
|
14
15
|
if (signature !== 'MPCK')
|
|
15
|
-
throw new
|
|
16
|
+
throw new MusepackContentError('Invalid Magic number');
|
|
16
17
|
this.metadata.setFormat('container', 'Musepack, SV8');
|
|
17
18
|
return this.parsePacket();
|
|
18
19
|
}
|
|
@@ -47,7 +48,7 @@ export class MpcSv8Parser extends BasicParser {
|
|
|
47
48
|
}
|
|
48
49
|
return APEv2Parser.tryParseApeHeader(this.metadata, this.tokenizer, this.options);
|
|
49
50
|
default:
|
|
50
|
-
throw new
|
|
51
|
+
throw new MusepackContentError(`Unexpected header: ${header.key}`);
|
|
51
52
|
}
|
|
52
53
|
} while (true);
|
|
53
54
|
}
|
package/lib/node.cjs
ADDED
package/lib/ogg/OggParser.d.ts
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import { type IGetToken } from 'strtok3';
|
|
2
2
|
import { BasicParser } from '../common/BasicParser.js';
|
|
3
3
|
import type * as Ogg from './Ogg.js';
|
|
4
|
+
declare const OggContentError_base: {
|
|
5
|
+
new (message: string): {
|
|
6
|
+
readonly fileType: string;
|
|
7
|
+
toString(): string;
|
|
8
|
+
name: "UnexpectedFileContentError";
|
|
9
|
+
message: string;
|
|
10
|
+
stack?: string;
|
|
11
|
+
};
|
|
12
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
13
|
+
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
14
|
+
stackTraceLimit: number;
|
|
15
|
+
};
|
|
16
|
+
export declare class OggContentError extends OggContentError_base {
|
|
17
|
+
}
|
|
4
18
|
export declare class SegmentTable implements IGetToken<Ogg.ISegmentTable> {
|
|
5
19
|
private static sum;
|
|
6
20
|
len: number;
|
|
@@ -21,3 +35,4 @@ export declare class OggParser extends BasicParser {
|
|
|
21
35
|
*/
|
|
22
36
|
parse(): Promise<void>;
|
|
23
37
|
}
|
|
38
|
+
export {};
|
package/lib/ogg/OggParser.js
CHANGED
|
@@ -8,6 +8,9 @@ import { VorbisParser } from './vorbis/VorbisParser.js';
|
|
|
8
8
|
import { OpusParser } from './opus/OpusParser.js';
|
|
9
9
|
import { SpeexParser } from './speex/SpeexParser.js';
|
|
10
10
|
import { TheoraParser } from './theora/TheoraParser.js';
|
|
11
|
+
import { makeUnexpectedFileContentError } from '../ParseError.js';
|
|
12
|
+
export class OggContentError extends makeUnexpectedFileContentError('Ogg') {
|
|
13
|
+
}
|
|
11
14
|
const debug = initDebug('music-metadata:parser:ogg');
|
|
12
15
|
export class SegmentTable {
|
|
13
16
|
static sum(buf, off, len) {
|
|
@@ -48,7 +51,7 @@ export class OggParser extends BasicParser {
|
|
|
48
51
|
do {
|
|
49
52
|
header = await this.tokenizer.readToken(OggParser.Header);
|
|
50
53
|
if (header.capturePattern !== 'OggS')
|
|
51
|
-
throw new
|
|
54
|
+
throw new OggContentError('Invalid Ogg capture pattern');
|
|
52
55
|
this.metadata.setFormat('container', 'Ogg');
|
|
53
56
|
this.header = header;
|
|
54
57
|
this.pageNumber = header.pageSequenceNo;
|
|
@@ -78,7 +81,7 @@ export class OggParser extends BasicParser {
|
|
|
78
81
|
this.pageConsumer = new TheoraParser(this.metadata, this.options, this.tokenizer);
|
|
79
82
|
break;
|
|
80
83
|
default:
|
|
81
|
-
throw new
|
|
84
|
+
throw new OggContentError(`gg audio-codec not recognized (id=${id})`);
|
|
82
85
|
}
|
|
83
86
|
}
|
|
84
87
|
await this.pageConsumer.parsePage(header, pageData);
|
package/lib/ogg/opus/Opus.d.ts
CHANGED
|
@@ -37,6 +37,20 @@ export interface IIdHeader {
|
|
|
37
37
|
*/
|
|
38
38
|
channelMapping: number;
|
|
39
39
|
}
|
|
40
|
+
declare const OpusContentError_base: {
|
|
41
|
+
new (message: string): {
|
|
42
|
+
readonly fileType: string;
|
|
43
|
+
toString(): string;
|
|
44
|
+
name: "UnexpectedFileContentError";
|
|
45
|
+
message: string;
|
|
46
|
+
stack?: string;
|
|
47
|
+
};
|
|
48
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
49
|
+
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
50
|
+
stackTraceLimit: number;
|
|
51
|
+
};
|
|
52
|
+
export declare class OpusContentError extends OpusContentError_base {
|
|
53
|
+
}
|
|
40
54
|
/**
|
|
41
55
|
* Opus ID Header parser
|
|
42
56
|
* Ref: https://wiki.xiph.org/OggOpus#ID_Header
|
|
@@ -46,3 +60,4 @@ export declare class IdHeader implements IGetToken<IIdHeader> {
|
|
|
46
60
|
constructor(len: number);
|
|
47
61
|
get(buf: Uint8Array, off: number): IIdHeader;
|
|
48
62
|
}
|
|
63
|
+
export {};
|
package/lib/ogg/opus/Opus.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import * as Token from 'token-types';
|
|
2
|
+
import { makeUnexpectedFileContentError } from '../../ParseError.js';
|
|
3
|
+
export class OpusContentError extends makeUnexpectedFileContentError('Opus') {
|
|
4
|
+
}
|
|
2
5
|
/**
|
|
3
6
|
* Opus ID Header parser
|
|
4
7
|
* Ref: https://wiki.xiph.org/OggOpus#ID_Header
|
|
@@ -7,7 +10,7 @@ export class IdHeader {
|
|
|
7
10
|
constructor(len) {
|
|
8
11
|
this.len = len;
|
|
9
12
|
if (len < 19) {
|
|
10
|
-
throw new
|
|
13
|
+
throw new OpusContentError('ID-header-page 0 should be at least 19 bytes long');
|
|
11
14
|
}
|
|
12
15
|
}
|
|
13
16
|
get(buf, off) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as Token from 'token-types';
|
|
2
2
|
import { VorbisParser } from '../vorbis/VorbisParser.js';
|
|
3
3
|
import * as Opus from './Opus.js';
|
|
4
|
+
import { OpusContentError } from './Opus.js';
|
|
4
5
|
/**
|
|
5
6
|
* Opus parser
|
|
6
7
|
* Internet Engineering Task Force (IETF) - RFC 6716
|
|
@@ -23,7 +24,7 @@ export class OpusParser extends VorbisParser {
|
|
|
23
24
|
// Parse Opus ID Header
|
|
24
25
|
this.idHeader = new Opus.IdHeader(pageData.length).get(pageData, 0);
|
|
25
26
|
if (this.idHeader.magicSignature !== "OpusHead")
|
|
26
|
-
throw new
|
|
27
|
+
throw new OpusContentError("Illegal ogg/Opus magic-signature");
|
|
27
28
|
this.metadata.setFormat('sampleRate', this.idHeader.inputSampleRate);
|
|
28
29
|
this.metadata.setFormat('numberOfChannels', this.idHeader.channelCount);
|
|
29
30
|
}
|
|
@@ -2,6 +2,20 @@ import { type IVorbisPicture } from './Vorbis.js';
|
|
|
2
2
|
import type { IPageConsumer, IPageHeader } from '../Ogg.js';
|
|
3
3
|
import type { IOptions } from '../../type.js';
|
|
4
4
|
import type { INativeMetadataCollector } from '../../common/MetadataCollector.js';
|
|
5
|
+
declare const VorbisContentError_base: {
|
|
6
|
+
new (message: string): {
|
|
7
|
+
readonly fileType: string;
|
|
8
|
+
toString(): string;
|
|
9
|
+
name: "UnexpectedFileContentError";
|
|
10
|
+
message: string;
|
|
11
|
+
stack?: string;
|
|
12
|
+
};
|
|
13
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
14
|
+
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
15
|
+
stackTraceLimit: number;
|
|
16
|
+
};
|
|
17
|
+
export declare class VorbisContentError extends VorbisContentError_base {
|
|
18
|
+
}
|
|
5
19
|
/**
|
|
6
20
|
* Vorbis 1 Parser.
|
|
7
21
|
* Used by OggParser
|
|
@@ -34,3 +48,4 @@ export declare class VorbisParser implements IPageConsumer {
|
|
|
34
48
|
*/
|
|
35
49
|
protected parseUserCommentList(pageData: Uint8Array, offset: number): Promise<void>;
|
|
36
50
|
}
|
|
51
|
+
export {};
|
|
@@ -2,7 +2,10 @@ import * as Token from 'token-types';
|
|
|
2
2
|
import debugInit from 'debug';
|
|
3
3
|
import { VorbisDecoder } from './VorbisDecoder.js';
|
|
4
4
|
import { CommonHeader, IdentificationHeader, VorbisPictureToken } from './Vorbis.js';
|
|
5
|
+
import { makeUnexpectedFileContentError } from '../../ParseError.js';
|
|
5
6
|
const debug = debugInit('music-metadata:parser:ogg:vorbis1');
|
|
7
|
+
export class VorbisContentError extends makeUnexpectedFileContentError('Vorbis') {
|
|
8
|
+
}
|
|
6
9
|
/**
|
|
7
10
|
* Vorbis 1 Parser.
|
|
8
11
|
* Used by OggParser
|
|
@@ -25,7 +28,7 @@ export class VorbisParser {
|
|
|
25
28
|
else {
|
|
26
29
|
if (header.headerType.continued) {
|
|
27
30
|
if (this.pageSegments.length === 0) {
|
|
28
|
-
throw new
|
|
31
|
+
throw new VorbisContentError('Cannot continue on previous page');
|
|
29
32
|
}
|
|
30
33
|
this.pageSegments.push(pageData);
|
|
31
34
|
}
|
|
@@ -93,7 +96,7 @@ export class VorbisParser {
|
|
|
93
96
|
// Parse Vorbis common header
|
|
94
97
|
const commonHeader = CommonHeader.get(pageData, 0);
|
|
95
98
|
if (commonHeader.vorbis !== 'vorbis')
|
|
96
|
-
throw new
|
|
99
|
+
throw new VorbisContentError('Metadata does not look like Vorbis');
|
|
97
100
|
if (commonHeader.packetType === 1) {
|
|
98
101
|
const idHeader = IdentificationHeader.get(pageData, CommonHeader.len);
|
|
99
102
|
this.metadata.setFormat('sampleRate', idHeader.sampleRate);
|
|
@@ -102,7 +105,7 @@ export class VorbisParser {
|
|
|
102
105
|
debug('sample-rate=%s[hz], bitrate=%s[b/s], channel-mode=%s', idHeader.sampleRate, idHeader.bitrateNominal, idHeader.channelMode);
|
|
103
106
|
}
|
|
104
107
|
else
|
|
105
|
-
throw new
|
|
108
|
+
throw new VorbisContentError('First Ogg page should be type 1: the identification header');
|
|
106
109
|
}
|
|
107
110
|
async parseFullPage(pageData) {
|
|
108
111
|
// New page
|
package/lib/type.d.ts
CHANGED
|
@@ -544,6 +544,15 @@ export interface IOptions {
|
|
|
544
544
|
* Set observer for async callbacks to common or format.
|
|
545
545
|
*/
|
|
546
546
|
observer?: Observer;
|
|
547
|
+
/**
|
|
548
|
+
* In Matroska based files, use the _SeekHead_ element index to skip _segment/cluster_ elements.
|
|
549
|
+
* By default, disabled
|
|
550
|
+
* Can have a significant performance impact if enabled.
|
|
551
|
+
* Possible side effect can be that certain metadata maybe skipped, depending on the index.
|
|
552
|
+
* If there is no _SeekHead_ element present in the Matroska file, this flag has no effect
|
|
553
|
+
* Ref: https://www.matroska.org/technical/diagram.html
|
|
554
|
+
*/
|
|
555
|
+
mkvUseIndex?: boolean;
|
|
547
556
|
}
|
|
548
557
|
export interface IApeHeader extends IOptions {
|
|
549
558
|
/**
|
package/lib/wav/WaveChunk.d.ts
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import type { IGetToken } from 'strtok3';
|
|
2
2
|
import type { IChunkHeader } from '../iff/index.js';
|
|
3
|
+
declare const WaveContentError_base: {
|
|
4
|
+
new (message: string): {
|
|
5
|
+
readonly fileType: string;
|
|
6
|
+
toString(): string;
|
|
7
|
+
name: "UnexpectedFileContentError";
|
|
8
|
+
message: string;
|
|
9
|
+
stack?: string;
|
|
10
|
+
};
|
|
11
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
12
|
+
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
13
|
+
stackTraceLimit: number;
|
|
14
|
+
};
|
|
15
|
+
export declare class WaveContentError extends WaveContentError_base {
|
|
16
|
+
}
|
|
3
17
|
/**
|
|
4
18
|
* Ref: https://msdn.microsoft.com/en-us/library/windows/desktop/dd317599(v=vs.85).aspx
|
|
5
19
|
*/
|
|
@@ -61,3 +75,4 @@ export declare class FactChunk implements IGetToken<IFactChunk> {
|
|
|
61
75
|
constructor(header: IChunkHeader);
|
|
62
76
|
get(buf: Uint8Array, off: number): IFactChunk;
|
|
63
77
|
}
|
|
78
|
+
export {};
|
package/lib/wav/WaveChunk.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import * as Token from 'token-types';
|
|
2
|
+
import { makeUnexpectedFileContentError } from '../ParseError.js';
|
|
3
|
+
export class WaveContentError extends makeUnexpectedFileContentError('Wave') {
|
|
4
|
+
}
|
|
2
5
|
/**
|
|
3
6
|
* Ref: https://msdn.microsoft.com/en-us/library/windows/desktop/dd317599(v=vs.85).aspx
|
|
4
7
|
*/
|
|
@@ -27,7 +30,7 @@ export var WaveFormat;
|
|
|
27
30
|
export class Format {
|
|
28
31
|
constructor(header) {
|
|
29
32
|
if (header.chunkSize < 16)
|
|
30
|
-
throw new
|
|
33
|
+
throw new WaveContentError('Invalid chunk size');
|
|
31
34
|
this.len = header.chunkSize;
|
|
32
35
|
}
|
|
33
36
|
get(buf, off) {
|
|
@@ -49,7 +52,7 @@ export class Format {
|
|
|
49
52
|
export class FactChunk {
|
|
50
53
|
constructor(header) {
|
|
51
54
|
if (header.chunkSize < 4) {
|
|
52
|
-
throw new
|
|
55
|
+
throw new WaveContentError('Invalid fact chunk size.');
|
|
53
56
|
}
|
|
54
57
|
this.len = header.chunkSize;
|
|
55
58
|
}
|
package/lib/wav/WaveParser.js
CHANGED
|
@@ -8,6 +8,7 @@ import * as util from '../common/Util.js';
|
|
|
8
8
|
import { FourCcToken } from '../common/FourCC.js';
|
|
9
9
|
import { BasicParser } from '../common/BasicParser.js';
|
|
10
10
|
import { BroadcastAudioExtensionChunk } from './BwfChunk.js';
|
|
11
|
+
import { WaveContentError } from './WaveChunk.js';
|
|
11
12
|
const debug = initDebug('music-metadata:parser:RIFF');
|
|
12
13
|
/**
|
|
13
14
|
* Resource Interchange File Format (RIFF) Parser
|
|
@@ -43,7 +44,7 @@ export class WaveParser extends BasicParser {
|
|
|
43
44
|
case 'WAVE':
|
|
44
45
|
return this.readWaveChunk(chunkSize - FourCcToken.len);
|
|
45
46
|
default:
|
|
46
|
-
throw new
|
|
47
|
+
throw new WaveContentError(`Unsupported RIFF format: RIFF/${type}`);
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
50
|
async readWaveChunk(remaining) {
|
|
@@ -159,7 +160,7 @@ export class WaveParser extends BasicParser {
|
|
|
159
160
|
chunkSize -= (8 + valueToken.len);
|
|
160
161
|
}
|
|
161
162
|
if (chunkSize !== 0) {
|
|
162
|
-
throw new
|
|
163
|
+
throw new WaveContentError(`Illegal remaining size: ${chunkSize}`);
|
|
163
164
|
}
|
|
164
165
|
}
|
|
165
166
|
addTag(id, value) {
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import { BasicParser } from '../common/BasicParser.js';
|
|
2
|
+
declare const WavPackContentError_base: {
|
|
3
|
+
new (message: string): {
|
|
4
|
+
readonly fileType: string;
|
|
5
|
+
toString(): string;
|
|
6
|
+
name: "UnexpectedFileContentError";
|
|
7
|
+
message: string;
|
|
8
|
+
stack?: string;
|
|
9
|
+
};
|
|
10
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
11
|
+
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
12
|
+
stackTraceLimit: number;
|
|
13
|
+
};
|
|
14
|
+
export declare class WavPackContentError extends WavPackContentError_base {
|
|
15
|
+
}
|
|
2
16
|
/**
|
|
3
17
|
* WavPack Parser
|
|
4
18
|
*/
|
|
@@ -13,3 +27,4 @@ export declare class WavPackParser extends BasicParser {
|
|
|
13
27
|
*/
|
|
14
28
|
private parseMetadataSubBlock;
|
|
15
29
|
}
|
|
30
|
+
export {};
|
|
@@ -5,7 +5,10 @@ import { BasicParser } from '../common/BasicParser.js';
|
|
|
5
5
|
import { BlockHeaderToken, MetadataIdToken } from './WavPackToken.js';
|
|
6
6
|
import initDebug from 'debug';
|
|
7
7
|
import { uint8ArrayToHex } from 'uint8array-extras';
|
|
8
|
+
import { makeUnexpectedFileContentError } from '../ParseError.js';
|
|
8
9
|
const debug = initDebug('music-metadata:parser:WavPack');
|
|
10
|
+
export class WavPackContentError extends makeUnexpectedFileContentError('WavPack') {
|
|
11
|
+
}
|
|
9
12
|
/**
|
|
10
13
|
* WavPack Parser
|
|
11
14
|
*/
|
|
@@ -28,7 +31,7 @@ export class WavPackParser extends BasicParser {
|
|
|
28
31
|
break;
|
|
29
32
|
const header = await this.tokenizer.readToken(BlockHeaderToken);
|
|
30
33
|
if (header.BlockID !== 'wvpk')
|
|
31
|
-
throw new
|
|
34
|
+
throw new WavPackContentError('Invalid WavPack Block-ID');
|
|
32
35
|
debug(`WavPack header blockIndex=${header.blockIndex}, len=${BlockHeaderToken.len}`);
|
|
33
36
|
if (header.blockIndex === 0 && !this.metadata.format.container) {
|
|
34
37
|
this.metadata.setFormat('container', 'WavPack');
|
|
@@ -76,7 +79,7 @@ export class WavPackParser extends BasicParser {
|
|
|
76
79
|
const mp = 1 << Token.UINT8.get(data, 0);
|
|
77
80
|
const samplingRate = header.flags.samplingRate * mp * 8; // ToDo: second factor should be read from DSD-metadata block https://github.com/dbry/WavPack/issues/71#issuecomment-483094813
|
|
78
81
|
if (!header.flags.isDSD)
|
|
79
|
-
throw new
|
|
82
|
+
throw new WavPackContentError('Only expect DSD block if DSD-flag is set');
|
|
80
83
|
this.metadata.setFormat('sampleRate', samplingRate);
|
|
81
84
|
this.metadata.setFormat('duration', header.totalSamples / samplingRate);
|
|
82
85
|
break;
|
|
@@ -100,7 +103,7 @@ export class WavPackParser extends BasicParser {
|
|
|
100
103
|
this.tokenizer.ignore(1);
|
|
101
104
|
}
|
|
102
105
|
if (remaining !== 0)
|
|
103
|
-
throw new
|
|
106
|
+
throw new WavPackContentError('metadata-sub-block should fit it remaining length');
|
|
104
107
|
}
|
|
105
108
|
}
|
|
106
109
|
//# sourceMappingURL=WavPackParser.js.map
|
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.3.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Borewit",
|
|
7
7
|
"url": "https://github.com/Borewit"
|
|
@@ -19,14 +19,23 @@
|
|
|
19
19
|
"type": "module",
|
|
20
20
|
"exports": {
|
|
21
21
|
".": {
|
|
22
|
-
"node":
|
|
23
|
-
|
|
22
|
+
"node": {
|
|
23
|
+
"import": "./lib/index.js",
|
|
24
|
+
"require": "./lib/node.cjs",
|
|
25
|
+
"types": "./lib/index.d.ts"
|
|
26
|
+
},
|
|
27
|
+
"default": {
|
|
28
|
+
"import": "./lib/core.js",
|
|
29
|
+
"require": "./lib/default.cjs",
|
|
30
|
+
"types": "./lib/core.d.ts"
|
|
31
|
+
}
|
|
24
32
|
}
|
|
25
33
|
},
|
|
26
34
|
"types": "lib/index.d.ts",
|
|
27
35
|
"files": [
|
|
28
36
|
"lib/**/*.js",
|
|
29
|
-
"lib/**/*.d.ts"
|
|
37
|
+
"lib/**/*.d.ts",
|
|
38
|
+
"lib/*.cjs"
|
|
30
39
|
],
|
|
31
40
|
"keywords": [
|
|
32
41
|
"music",
|
|
@@ -85,7 +94,7 @@
|
|
|
85
94
|
"compile-doc": "tsc -p doc-gen",
|
|
86
95
|
"compile": "yarn run compile-src && yarn compile-test && yarn compile-doc",
|
|
87
96
|
"lint-ts": "biome check",
|
|
88
|
-
"lint-md": "yarn run remark -u preset-lint-
|
|
97
|
+
"lint-md": "yarn run remark -u remark-preset-lint-consistent .",
|
|
89
98
|
"lint": "yarn run lint-ts && yarn run lint-md",
|
|
90
99
|
"test": "mocha",
|
|
91
100
|
"build": "yarn run clean && yarn compile && yarn run doc-gen",
|
|
@@ -97,21 +106,21 @@
|
|
|
97
106
|
"@tokenizer/token": "^0.3.0",
|
|
98
107
|
"content-type": "^1.0.5",
|
|
99
108
|
"debug": "^4.3.4",
|
|
100
|
-
"file-type": "^19.4.
|
|
109
|
+
"file-type": "^19.4.1",
|
|
101
110
|
"media-typer": "^1.1.0",
|
|
102
|
-
"strtok3": "^8.0
|
|
111
|
+
"strtok3": "^8.1.0",
|
|
103
112
|
"token-types": "^6.0.0",
|
|
104
113
|
"uint8array-extras": "^1.4.0"
|
|
105
114
|
},
|
|
106
115
|
"devDependencies": {
|
|
107
116
|
"@biomejs/biome": "1.8.3",
|
|
108
|
-
"@types/chai": "^4.3.
|
|
109
|
-
"@types/chai-as-promised": "^
|
|
117
|
+
"@types/chai": "^4.3.19",
|
|
118
|
+
"@types/chai-as-promised": "^8.0.0",
|
|
110
119
|
"@types/content-type": "^1.1.8",
|
|
111
120
|
"@types/debug": "^4.1.12",
|
|
112
121
|
"@types/media-typer": "^1.1.3",
|
|
113
122
|
"@types/mocha": "^10.0.7",
|
|
114
|
-
"@types/node": "^22.
|
|
123
|
+
"@types/node": "^22.5.1",
|
|
115
124
|
"c8": "^10.1.2",
|
|
116
125
|
"chai": "^5.1.1",
|
|
117
126
|
"chai-as-promised": "^8.0.0",
|
|
@@ -120,7 +129,7 @@
|
|
|
120
129
|
"mocha": "^10.7.3",
|
|
121
130
|
"prettier": "^3.3.3",
|
|
122
131
|
"remark-cli": "^12.0.1",
|
|
123
|
-
"remark-preset-lint-
|
|
132
|
+
"remark-preset-lint-consistent": "^6.0.0",
|
|
124
133
|
"ts-node": "^10.9.2",
|
|
125
134
|
"typescript": "^5.5.3"
|
|
126
135
|
},
|