music-metadata 7.12.3 → 7.12.6
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/LICENSE.txt +9 -9
- package/README.md +434 -434
- package/lib/ParserFactory.d.ts +48 -48
- package/lib/ParserFactory.js +252 -252
- package/lib/aiff/AiffParser.d.ts +14 -14
- package/lib/aiff/AiffParser.js +96 -84
- package/lib/aiff/AiffToken.d.ts +22 -22
- package/lib/aiff/AiffToken.js +48 -43
- package/lib/apev2/APEv2Parser.d.ts +30 -30
- package/lib/apev2/APEv2Parser.js +164 -164
- package/lib/apev2/APEv2TagMapper.d.ts +4 -4
- package/lib/apev2/APEv2TagMapper.js +86 -86
- package/lib/apev2/APEv2Token.d.ts +100 -100
- package/lib/apev2/APEv2Token.js +126 -126
- package/lib/asf/AsfObject.d.ts +319 -319
- package/lib/asf/AsfObject.js +381 -381
- 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 +95 -95
- package/lib/asf/AsfUtil.d.ts +13 -13
- package/lib/asf/AsfUtil.js +38 -38
- package/lib/asf/GUID.d.ts +84 -84
- package/lib/asf/GUID.js +121 -121
- 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 +21 -21
- package/lib/common/CombinedTagMapper.d.ts +19 -19
- package/lib/common/CombinedTagMapper.js +51 -51
- package/lib/common/FourCC.d.ts +6 -6
- package/lib/common/FourCC.js +28 -28
- package/lib/common/GenericTagMapper.d.ts +51 -51
- package/lib/common/GenericTagMapper.js +55 -55
- package/lib/common/GenericTagTypes.d.ts +33 -33
- package/lib/common/GenericTagTypes.js +131 -131
- package/lib/common/MetadataCollector.d.ts +76 -76
- package/lib/common/MetadataCollector.js +275 -275
- package/lib/common/RandomFileReader.d.ts +22 -22
- package/lib/common/RandomFileReader.js +34 -34
- package/lib/common/RandomUint8ArrayReader.d.ts +18 -18
- package/lib/common/RandomUint8ArrayReader.js +25 -25
- package/lib/common/Util.d.ts +57 -57
- package/lib/common/Util.js +157 -157
- 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 +22 -22
- package/lib/id3v2/AbstractID3Parser.d.ts +17 -17
- package/lib/id3v2/AbstractID3Parser.js +60 -60
- package/lib/id3v2/FrameParser.d.ts +31 -31
- package/lib/id3v2/FrameParser.js +329 -329
- package/lib/id3v2/ID3v22TagMapper.d.ts +9 -9
- package/lib/id3v2/ID3v22TagMapper.js +55 -55
- package/lib/id3v2/ID3v24TagMapper.d.ts +14 -14
- package/lib/id3v2/ID3v24TagMapper.js +193 -193
- package/lib/id3v2/ID3v2Parser.d.ts +28 -28
- package/lib/id3v2/ID3v2Parser.js +182 -182
- 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 -45
- package/lib/index.js +74 -74
- 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 -235
- package/lib/matroska/MatroskaTagMapper.d.ts +4 -4
- package/lib/matroska/MatroskaTagMapper.js +35 -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 +115 -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 +524 -524
- 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 +69 -69
- 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 +132 -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 +37 -37
- package/lib/type.d.ts +592 -592
- package/lib/type.js +5 -5
- package/lib/wav/BwfChunk.d.ts +17 -17
- package/lib/wav/BwfChunk.js +29 -28
- 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 +158 -156
- package/lib/wavpack/WavPackParser.d.ts +14 -14
- package/lib/wavpack/WavPackParser.js +99 -99
- package/lib/wavpack/WavPackToken.d.ts +64 -64
- package/lib/wavpack/WavPackToken.js +76 -76
- package/package.json +150 -150
package/lib/core.d.ts
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Readable } from 'stream';
|
|
3
|
-
import * as strtok3 from 'strtok3/lib/core';
|
|
4
|
-
import { IAudioMetadata, INativeTagDict, IOptions, IPicture, IPrivateOptions, IRandomReader, ITag } from './type';
|
|
5
|
-
export { IFileInfo } from 'strtok3/lib/core';
|
|
6
|
-
/**
|
|
7
|
-
* Parse audio from Node Stream.Readable
|
|
8
|
-
* @param stream - Stream to read the audio track from
|
|
9
|
-
* @param options - Parsing options
|
|
10
|
-
* @param fileInfo - File information object or MIME-type string
|
|
11
|
-
* @returns Metadata
|
|
12
|
-
*/
|
|
13
|
-
export declare function parseStream(stream: Readable, fileInfo?: strtok3.IFileInfo | string, options?: IOptions): Promise<IAudioMetadata>;
|
|
14
|
-
/**
|
|
15
|
-
* Parse audio from Node Buffer
|
|
16
|
-
* @param uint8Array - Uint8Array holding audio data
|
|
17
|
-
* @param fileInfo - File information object or MIME-type string
|
|
18
|
-
* @param options - Parsing options
|
|
19
|
-
* @returns Metadata
|
|
20
|
-
* Ref: https://github.com/Borewit/strtok3/blob/e6938c81ff685074d5eb3064a11c0b03ca934c1d/src/index.ts#L15
|
|
21
|
-
*/
|
|
22
|
-
export declare function parseBuffer(uint8Array: Uint8Array, fileInfo?: strtok3.IFileInfo | string, options?: IOptions): Promise<IAudioMetadata>;
|
|
23
|
-
/**
|
|
24
|
-
* Parse audio from ITokenizer source
|
|
25
|
-
* @param tokenizer - Audio source implementing the tokenizer interface
|
|
26
|
-
* @param options - Parsing options
|
|
27
|
-
* @returns Metadata
|
|
28
|
-
*/
|
|
29
|
-
export declare function parseFromTokenizer(tokenizer: strtok3.ITokenizer, options?: IOptions): Promise<IAudioMetadata>;
|
|
30
|
-
/**
|
|
31
|
-
* Create a dictionary ordered by their tag id (key)
|
|
32
|
-
* @param nativeTags list of tags
|
|
33
|
-
* @returns tags indexed by id
|
|
34
|
-
*/
|
|
35
|
-
export declare function orderTags(nativeTags: ITag[]): INativeTagDict;
|
|
36
|
-
/**
|
|
37
|
-
* Convert rating to 1-5 star rating
|
|
38
|
-
* @param rating: Normalized rating [0..1] (common.rating[n].rating)
|
|
39
|
-
* @returns Number of stars: 1, 2, 3, 4 or 5 stars
|
|
40
|
-
*/
|
|
41
|
-
export declare function ratingToStars(rating: number): number;
|
|
42
|
-
/**
|
|
43
|
-
* Select most likely cover image.
|
|
44
|
-
* @param pictures Usually metadata.common.picture
|
|
45
|
-
* @return Cover image, if any, otherwise null
|
|
46
|
-
*/
|
|
47
|
-
export declare function selectCover(pictures?: IPicture[]): IPicture | null;
|
|
48
|
-
export declare function scanAppendingHeaders(randomReader: IRandomReader, options?: IPrivateOptions): Promise<void>;
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Readable } from 'stream';
|
|
3
|
+
import * as strtok3 from 'strtok3/lib/core';
|
|
4
|
+
import { IAudioMetadata, INativeTagDict, IOptions, IPicture, IPrivateOptions, IRandomReader, ITag } from './type';
|
|
5
|
+
export { IFileInfo } from 'strtok3/lib/core';
|
|
6
|
+
/**
|
|
7
|
+
* Parse audio from Node Stream.Readable
|
|
8
|
+
* @param stream - Stream to read the audio track from
|
|
9
|
+
* @param options - Parsing options
|
|
10
|
+
* @param fileInfo - File information object or MIME-type string
|
|
11
|
+
* @returns Metadata
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseStream(stream: Readable, fileInfo?: strtok3.IFileInfo | string, options?: IOptions): Promise<IAudioMetadata>;
|
|
14
|
+
/**
|
|
15
|
+
* Parse audio from Node Buffer
|
|
16
|
+
* @param uint8Array - Uint8Array holding audio data
|
|
17
|
+
* @param fileInfo - File information object or MIME-type string
|
|
18
|
+
* @param options - Parsing options
|
|
19
|
+
* @returns Metadata
|
|
20
|
+
* Ref: https://github.com/Borewit/strtok3/blob/e6938c81ff685074d5eb3064a11c0b03ca934c1d/src/index.ts#L15
|
|
21
|
+
*/
|
|
22
|
+
export declare function parseBuffer(uint8Array: Uint8Array, fileInfo?: strtok3.IFileInfo | string, options?: IOptions): Promise<IAudioMetadata>;
|
|
23
|
+
/**
|
|
24
|
+
* Parse audio from ITokenizer source
|
|
25
|
+
* @param tokenizer - Audio source implementing the tokenizer interface
|
|
26
|
+
* @param options - Parsing options
|
|
27
|
+
* @returns Metadata
|
|
28
|
+
*/
|
|
29
|
+
export declare function parseFromTokenizer(tokenizer: strtok3.ITokenizer, options?: IOptions): Promise<IAudioMetadata>;
|
|
30
|
+
/**
|
|
31
|
+
* Create a dictionary ordered by their tag id (key)
|
|
32
|
+
* @param nativeTags list of tags
|
|
33
|
+
* @returns tags indexed by id
|
|
34
|
+
*/
|
|
35
|
+
export declare function orderTags(nativeTags: ITag[]): INativeTagDict;
|
|
36
|
+
/**
|
|
37
|
+
* Convert rating to 1-5 star rating
|
|
38
|
+
* @param rating: Normalized rating [0..1] (common.rating[n].rating)
|
|
39
|
+
* @returns Number of stars: 1, 2, 3, 4 or 5 stars
|
|
40
|
+
*/
|
|
41
|
+
export declare function ratingToStars(rating: number): number;
|
|
42
|
+
/**
|
|
43
|
+
* Select most likely cover image.
|
|
44
|
+
* @param pictures Usually metadata.common.picture
|
|
45
|
+
* @return Cover image, if any, otherwise null
|
|
46
|
+
*/
|
|
47
|
+
export declare function selectCover(pictures?: IPicture[]): IPicture | null;
|
|
48
|
+
export declare function scanAppendingHeaders(randomReader: IRandomReader, options?: IPrivateOptions): Promise<void>;
|
package/lib/core.js
CHANGED
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.scanAppendingHeaders = exports.selectCover = exports.ratingToStars = exports.orderTags = exports.parseFromTokenizer = exports.parseBuffer = exports.parseStream = void 0;
|
|
4
|
-
const strtok3 = require("strtok3/lib/core");
|
|
5
|
-
const ParserFactory_1 = require("./ParserFactory");
|
|
6
|
-
const RandomUint8ArrayReader_1 = require("./common/RandomUint8ArrayReader");
|
|
7
|
-
const APEv2Parser_1 = require("./apev2/APEv2Parser");
|
|
8
|
-
const ID3v1Parser_1 = require("./id3v1/ID3v1Parser");
|
|
9
|
-
const Lyrics3_1 = require("./lyrics3/Lyrics3");
|
|
10
|
-
/**
|
|
11
|
-
* Parse audio from Node Stream.Readable
|
|
12
|
-
* @param stream - Stream to read the audio track from
|
|
13
|
-
* @param options - Parsing options
|
|
14
|
-
* @param fileInfo - File information object or MIME-type string
|
|
15
|
-
* @returns Metadata
|
|
16
|
-
*/
|
|
17
|
-
function parseStream(stream, fileInfo, options = {}) {
|
|
18
|
-
return parseFromTokenizer(strtok3.fromStream(stream, typeof fileInfo === 'string' ? { mimeType: fileInfo } : fileInfo), options);
|
|
19
|
-
}
|
|
20
|
-
exports.parseStream = parseStream;
|
|
21
|
-
/**
|
|
22
|
-
* Parse audio from Node Buffer
|
|
23
|
-
* @param uint8Array - Uint8Array holding audio data
|
|
24
|
-
* @param fileInfo - File information object or MIME-type string
|
|
25
|
-
* @param options - Parsing options
|
|
26
|
-
* @returns Metadata
|
|
27
|
-
* Ref: https://github.com/Borewit/strtok3/blob/e6938c81ff685074d5eb3064a11c0b03ca934c1d/src/index.ts#L15
|
|
28
|
-
*/
|
|
29
|
-
async function parseBuffer(uint8Array, fileInfo, options = {}) {
|
|
30
|
-
const bufferReader = new RandomUint8ArrayReader_1.RandomUint8ArrayReader(uint8Array);
|
|
31
|
-
await scanAppendingHeaders(bufferReader, options);
|
|
32
|
-
const tokenizer = strtok3.fromBuffer(uint8Array, typeof fileInfo === 'string' ? { mimeType: fileInfo } : fileInfo);
|
|
33
|
-
return parseFromTokenizer(tokenizer, options);
|
|
34
|
-
}
|
|
35
|
-
exports.parseBuffer = parseBuffer;
|
|
36
|
-
/**
|
|
37
|
-
* Parse audio from ITokenizer source
|
|
38
|
-
* @param tokenizer - Audio source implementing the tokenizer interface
|
|
39
|
-
* @param options - Parsing options
|
|
40
|
-
* @returns Metadata
|
|
41
|
-
*/
|
|
42
|
-
function parseFromTokenizer(tokenizer, options) {
|
|
43
|
-
return ParserFactory_1.ParserFactory.parseOnContentType(tokenizer, options);
|
|
44
|
-
}
|
|
45
|
-
exports.parseFromTokenizer = parseFromTokenizer;
|
|
46
|
-
/**
|
|
47
|
-
* Create a dictionary ordered by their tag id (key)
|
|
48
|
-
* @param nativeTags list of tags
|
|
49
|
-
* @returns tags indexed by id
|
|
50
|
-
*/
|
|
51
|
-
function orderTags(nativeTags) {
|
|
52
|
-
const tags = {};
|
|
53
|
-
for (const tag of nativeTags) {
|
|
54
|
-
(tags[tag.id] = (tags[tag.id] || [])).push(tag.value);
|
|
55
|
-
}
|
|
56
|
-
return tags;
|
|
57
|
-
}
|
|
58
|
-
exports.orderTags = orderTags;
|
|
59
|
-
/**
|
|
60
|
-
* Convert rating to 1-5 star rating
|
|
61
|
-
* @param rating: Normalized rating [0..1] (common.rating[n].rating)
|
|
62
|
-
* @returns Number of stars: 1, 2, 3, 4 or 5 stars
|
|
63
|
-
*/
|
|
64
|
-
function ratingToStars(rating) {
|
|
65
|
-
return rating === undefined ? 0 : 1 + Math.round(rating * 4);
|
|
66
|
-
}
|
|
67
|
-
exports.ratingToStars = ratingToStars;
|
|
68
|
-
/**
|
|
69
|
-
* Select most likely cover image.
|
|
70
|
-
* @param pictures Usually metadata.common.picture
|
|
71
|
-
* @return Cover image, if any, otherwise null
|
|
72
|
-
*/
|
|
73
|
-
function selectCover(pictures) {
|
|
74
|
-
return pictures ? pictures.reduce((acc, cur) => {
|
|
75
|
-
if (cur.name && cur.name.toLowerCase() in ['front', 'cover', 'cover (front)'])
|
|
76
|
-
return cur;
|
|
77
|
-
return acc;
|
|
78
|
-
}) : null;
|
|
79
|
-
}
|
|
80
|
-
exports.selectCover = selectCover;
|
|
81
|
-
async function scanAppendingHeaders(randomReader, options = {}) {
|
|
82
|
-
let apeOffset = randomReader.fileSize;
|
|
83
|
-
if (await (0, ID3v1Parser_1.hasID3v1Header)(randomReader)) {
|
|
84
|
-
apeOffset -= 128;
|
|
85
|
-
const lyricsLen = await (0, Lyrics3_1.getLyricsHeaderLength)(randomReader);
|
|
86
|
-
apeOffset -= lyricsLen;
|
|
87
|
-
}
|
|
88
|
-
options.apeHeader = await APEv2Parser_1.APEv2Parser.findApeFooterOffset(randomReader, apeOffset);
|
|
89
|
-
}
|
|
90
|
-
exports.scanAppendingHeaders = scanAppendingHeaders;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.scanAppendingHeaders = exports.selectCover = exports.ratingToStars = exports.orderTags = exports.parseFromTokenizer = exports.parseBuffer = exports.parseStream = void 0;
|
|
4
|
+
const strtok3 = require("strtok3/lib/core");
|
|
5
|
+
const ParserFactory_1 = require("./ParserFactory");
|
|
6
|
+
const RandomUint8ArrayReader_1 = require("./common/RandomUint8ArrayReader");
|
|
7
|
+
const APEv2Parser_1 = require("./apev2/APEv2Parser");
|
|
8
|
+
const ID3v1Parser_1 = require("./id3v1/ID3v1Parser");
|
|
9
|
+
const Lyrics3_1 = require("./lyrics3/Lyrics3");
|
|
10
|
+
/**
|
|
11
|
+
* Parse audio from Node Stream.Readable
|
|
12
|
+
* @param stream - Stream to read the audio track from
|
|
13
|
+
* @param options - Parsing options
|
|
14
|
+
* @param fileInfo - File information object or MIME-type string
|
|
15
|
+
* @returns Metadata
|
|
16
|
+
*/
|
|
17
|
+
function parseStream(stream, fileInfo, options = {}) {
|
|
18
|
+
return parseFromTokenizer(strtok3.fromStream(stream, typeof fileInfo === 'string' ? { mimeType: fileInfo } : fileInfo), options);
|
|
19
|
+
}
|
|
20
|
+
exports.parseStream = parseStream;
|
|
21
|
+
/**
|
|
22
|
+
* Parse audio from Node Buffer
|
|
23
|
+
* @param uint8Array - Uint8Array holding audio data
|
|
24
|
+
* @param fileInfo - File information object or MIME-type string
|
|
25
|
+
* @param options - Parsing options
|
|
26
|
+
* @returns Metadata
|
|
27
|
+
* Ref: https://github.com/Borewit/strtok3/blob/e6938c81ff685074d5eb3064a11c0b03ca934c1d/src/index.ts#L15
|
|
28
|
+
*/
|
|
29
|
+
async function parseBuffer(uint8Array, fileInfo, options = {}) {
|
|
30
|
+
const bufferReader = new RandomUint8ArrayReader_1.RandomUint8ArrayReader(uint8Array);
|
|
31
|
+
await scanAppendingHeaders(bufferReader, options);
|
|
32
|
+
const tokenizer = strtok3.fromBuffer(uint8Array, typeof fileInfo === 'string' ? { mimeType: fileInfo } : fileInfo);
|
|
33
|
+
return parseFromTokenizer(tokenizer, options);
|
|
34
|
+
}
|
|
35
|
+
exports.parseBuffer = parseBuffer;
|
|
36
|
+
/**
|
|
37
|
+
* Parse audio from ITokenizer source
|
|
38
|
+
* @param tokenizer - Audio source implementing the tokenizer interface
|
|
39
|
+
* @param options - Parsing options
|
|
40
|
+
* @returns Metadata
|
|
41
|
+
*/
|
|
42
|
+
function parseFromTokenizer(tokenizer, options) {
|
|
43
|
+
return ParserFactory_1.ParserFactory.parseOnContentType(tokenizer, options);
|
|
44
|
+
}
|
|
45
|
+
exports.parseFromTokenizer = parseFromTokenizer;
|
|
46
|
+
/**
|
|
47
|
+
* Create a dictionary ordered by their tag id (key)
|
|
48
|
+
* @param nativeTags list of tags
|
|
49
|
+
* @returns tags indexed by id
|
|
50
|
+
*/
|
|
51
|
+
function orderTags(nativeTags) {
|
|
52
|
+
const tags = {};
|
|
53
|
+
for (const tag of nativeTags) {
|
|
54
|
+
(tags[tag.id] = (tags[tag.id] || [])).push(tag.value);
|
|
55
|
+
}
|
|
56
|
+
return tags;
|
|
57
|
+
}
|
|
58
|
+
exports.orderTags = orderTags;
|
|
59
|
+
/**
|
|
60
|
+
* Convert rating to 1-5 star rating
|
|
61
|
+
* @param rating: Normalized rating [0..1] (common.rating[n].rating)
|
|
62
|
+
* @returns Number of stars: 1, 2, 3, 4 or 5 stars
|
|
63
|
+
*/
|
|
64
|
+
function ratingToStars(rating) {
|
|
65
|
+
return rating === undefined ? 0 : 1 + Math.round(rating * 4);
|
|
66
|
+
}
|
|
67
|
+
exports.ratingToStars = ratingToStars;
|
|
68
|
+
/**
|
|
69
|
+
* Select most likely cover image.
|
|
70
|
+
* @param pictures Usually metadata.common.picture
|
|
71
|
+
* @return Cover image, if any, otherwise null
|
|
72
|
+
*/
|
|
73
|
+
function selectCover(pictures) {
|
|
74
|
+
return pictures ? pictures.reduce((acc, cur) => {
|
|
75
|
+
if (cur.name && cur.name.toLowerCase() in ['front', 'cover', 'cover (front)'])
|
|
76
|
+
return cur;
|
|
77
|
+
return acc;
|
|
78
|
+
}) : null;
|
|
79
|
+
}
|
|
80
|
+
exports.selectCover = selectCover;
|
|
81
|
+
async function scanAppendingHeaders(randomReader, options = {}) {
|
|
82
|
+
let apeOffset = randomReader.fileSize;
|
|
83
|
+
if (await (0, ID3v1Parser_1.hasID3v1Header)(randomReader)) {
|
|
84
|
+
apeOffset -= 128;
|
|
85
|
+
const lyricsLen = await (0, Lyrics3_1.getLyricsHeaderLength)(randomReader);
|
|
86
|
+
apeOffset -= lyricsLen;
|
|
87
|
+
}
|
|
88
|
+
options.apeHeader = await APEv2Parser_1.APEv2Parser.findApeFooterOffset(randomReader, apeOffset);
|
|
89
|
+
}
|
|
90
|
+
exports.scanAppendingHeaders = scanAppendingHeaders;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { BasicParser } from '../common/BasicParser';
|
|
2
|
-
/**
|
|
3
|
-
* DSDIFF - Direct Stream Digital Interchange File Format (Phillips)
|
|
4
|
-
*
|
|
5
|
-
* Ref:
|
|
6
|
-
* - http://www.sonicstudio.com/pdf/dsd/DSDIFF_1.5_Spec.pdf
|
|
7
|
-
*/
|
|
8
|
-
export declare class DsdiffParser extends BasicParser {
|
|
9
|
-
parse(): Promise<void>;
|
|
10
|
-
private readFmt8Chunks;
|
|
11
|
-
private readData;
|
|
12
|
-
private handleSoundPropertyChunks;
|
|
13
|
-
private handleChannelChunks;
|
|
14
|
-
}
|
|
1
|
+
import { BasicParser } from '../common/BasicParser';
|
|
2
|
+
/**
|
|
3
|
+
* DSDIFF - Direct Stream Digital Interchange File Format (Phillips)
|
|
4
|
+
*
|
|
5
|
+
* Ref:
|
|
6
|
+
* - http://www.sonicstudio.com/pdf/dsd/DSDIFF_1.5_Spec.pdf
|
|
7
|
+
*/
|
|
8
|
+
export declare class DsdiffParser extends BasicParser {
|
|
9
|
+
parse(): Promise<void>;
|
|
10
|
+
private readFmt8Chunks;
|
|
11
|
+
private readData;
|
|
12
|
+
private handleSoundPropertyChunks;
|
|
13
|
+
private handleChannelChunks;
|
|
14
|
+
}
|
|
@@ -1,143 +1,143 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DsdiffParser = void 0;
|
|
4
|
-
const Token = require("token-types");
|
|
5
|
-
const debug_1 = require("debug");
|
|
6
|
-
const strtok3 = require("strtok3/lib/core");
|
|
7
|
-
const FourCC_1 = require("../common/FourCC");
|
|
8
|
-
const BasicParser_1 = require("../common/BasicParser");
|
|
9
|
-
const ID3v2Parser_1 = require("../id3v2/ID3v2Parser");
|
|
10
|
-
const DsdiffToken_1 = require("./DsdiffToken");
|
|
11
|
-
const debug = (0, debug_1.default)('music-metadata:parser:aiff');
|
|
12
|
-
/**
|
|
13
|
-
* DSDIFF - Direct Stream Digital Interchange File Format (Phillips)
|
|
14
|
-
*
|
|
15
|
-
* Ref:
|
|
16
|
-
* - http://www.sonicstudio.com/pdf/dsd/DSDIFF_1.5_Spec.pdf
|
|
17
|
-
*/
|
|
18
|
-
class DsdiffParser extends BasicParser_1.BasicParser {
|
|
19
|
-
async parse() {
|
|
20
|
-
const header = await this.tokenizer.readToken(DsdiffToken_1.ChunkHeader64);
|
|
21
|
-
if (header.chunkID !== 'FRM8')
|
|
22
|
-
throw new Error('Unexpected chunk-ID');
|
|
23
|
-
const type = (await this.tokenizer.readToken(FourCC_1.FourCcToken)).trim();
|
|
24
|
-
switch (type) {
|
|
25
|
-
case 'DSD':
|
|
26
|
-
this.metadata.setFormat('container', `DSDIFF/${type}`);
|
|
27
|
-
this.metadata.setFormat('lossless', true);
|
|
28
|
-
return this.readFmt8Chunks(header.chunkSize - BigInt(FourCC_1.FourCcToken.len));
|
|
29
|
-
default:
|
|
30
|
-
throw Error(`Unsupported DSDIFF type: ${type}`);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
async readFmt8Chunks(remainingSize) {
|
|
34
|
-
while (remainingSize >= DsdiffToken_1.ChunkHeader64.len) {
|
|
35
|
-
const chunkHeader = await this.tokenizer.readToken(DsdiffToken_1.ChunkHeader64);
|
|
36
|
-
// If the data is an odd number of bytes in length, a pad byte must be added at the end
|
|
37
|
-
debug(`Chunk id=${chunkHeader.chunkID}`);
|
|
38
|
-
await this.readData(chunkHeader);
|
|
39
|
-
remainingSize -= (BigInt(DsdiffToken_1.ChunkHeader64.len) + chunkHeader.chunkSize);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
async readData(header) {
|
|
43
|
-
debug(`Reading data of chunk[ID=${header.chunkID}, size=${header.chunkSize}]`);
|
|
44
|
-
const p0 = this.tokenizer.position;
|
|
45
|
-
switch (header.chunkID.trim()) {
|
|
46
|
-
case 'FVER': // 3.1 FORMAT VERSION CHUNK
|
|
47
|
-
const version = await this.tokenizer.readToken(Token.UINT32_LE);
|
|
48
|
-
debug(`DSDIFF version=${version}`);
|
|
49
|
-
break;
|
|
50
|
-
case 'PROP': // 3.2 PROPERTY CHUNK
|
|
51
|
-
const propType = await this.tokenizer.readToken(FourCC_1.FourCcToken);
|
|
52
|
-
if (propType !== 'SND ')
|
|
53
|
-
throw new Error('Unexpected PROP-chunk ID');
|
|
54
|
-
await this.handleSoundPropertyChunks(header.chunkSize - BigInt(FourCC_1.FourCcToken.len));
|
|
55
|
-
break;
|
|
56
|
-
case 'ID3': // Unofficial ID3 tag support
|
|
57
|
-
const id3_data = await this.tokenizer.readToken(new Token.Uint8ArrayType(Number(header.chunkSize)));
|
|
58
|
-
const rst = strtok3.fromBuffer(id3_data);
|
|
59
|
-
await new ID3v2Parser_1.ID3v2Parser().parse(this.metadata, rst, this.options);
|
|
60
|
-
break;
|
|
61
|
-
default:
|
|
62
|
-
debug(`Ignore chunk[ID=${header.chunkID}, size=${header.chunkSize}]`);
|
|
63
|
-
break;
|
|
64
|
-
case 'DSD':
|
|
65
|
-
this.metadata.setFormat('numberOfSamples', Number(header.chunkSize * BigInt(8) / BigInt(this.metadata.format.numberOfChannels)));
|
|
66
|
-
this.metadata.setFormat('duration', this.metadata.format.numberOfSamples / this.metadata.format.sampleRate);
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
const remaining = header.chunkSize - BigInt(this.tokenizer.position - p0);
|
|
70
|
-
if (remaining > 0) {
|
|
71
|
-
debug(`After Parsing chunk, remaining ${remaining} bytes`);
|
|
72
|
-
await this.tokenizer.ignore(Number(remaining));
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
async handleSoundPropertyChunks(remainingSize) {
|
|
76
|
-
debug(`Parsing sound-property-chunks, remainingSize=${remainingSize}`);
|
|
77
|
-
while (remainingSize > 0) {
|
|
78
|
-
const sndPropHeader = await this.tokenizer.readToken(DsdiffToken_1.ChunkHeader64);
|
|
79
|
-
debug(`Sound-property-chunk[ID=${sndPropHeader.chunkID}, size=${sndPropHeader.chunkSize}]`);
|
|
80
|
-
const p0 = this.tokenizer.position;
|
|
81
|
-
switch (sndPropHeader.chunkID.trim()) {
|
|
82
|
-
case 'FS': // 3.2.1 Sample Rate Chunk
|
|
83
|
-
const sampleRate = await this.tokenizer.readToken(Token.UINT32_BE);
|
|
84
|
-
this.metadata.setFormat('sampleRate', sampleRate);
|
|
85
|
-
break;
|
|
86
|
-
case 'CHNL': // 3.2.2 Channels Chunk
|
|
87
|
-
const numChannels = await this.tokenizer.readToken(Token.UINT16_BE);
|
|
88
|
-
this.metadata.setFormat('numberOfChannels', numChannels);
|
|
89
|
-
await this.handleChannelChunks(sndPropHeader.chunkSize - BigInt(Token.UINT16_BE.len));
|
|
90
|
-
break;
|
|
91
|
-
case 'CMPR': // 3.2.3 Compression Type Chunk
|
|
92
|
-
const compressionIdCode = (await this.tokenizer.readToken(FourCC_1.FourCcToken)).trim();
|
|
93
|
-
const count = await this.tokenizer.readToken(Token.UINT8);
|
|
94
|
-
const compressionName = await this.tokenizer.readToken(new Token.StringType(count, 'ascii'));
|
|
95
|
-
if (compressionIdCode === 'DSD') {
|
|
96
|
-
this.metadata.setFormat('lossless', true);
|
|
97
|
-
this.metadata.setFormat('bitsPerSample', 1);
|
|
98
|
-
}
|
|
99
|
-
this.metadata.setFormat('codec', `${compressionIdCode} (${compressionName})`);
|
|
100
|
-
break;
|
|
101
|
-
case 'ABSS': // 3.2.4 Absolute Start Time Chunk
|
|
102
|
-
const hours = await this.tokenizer.readToken(Token.UINT16_BE);
|
|
103
|
-
const minutes = await this.tokenizer.readToken(Token.UINT8);
|
|
104
|
-
const seconds = await this.tokenizer.readToken(Token.UINT8);
|
|
105
|
-
const samples = await this.tokenizer.readToken(Token.UINT32_BE);
|
|
106
|
-
debug(`ABSS ${hours}:${minutes}:${seconds}.${samples}`);
|
|
107
|
-
break;
|
|
108
|
-
case 'LSCO': // 3.2.5 Loudspeaker Configuration Chunk
|
|
109
|
-
const lsConfig = await this.tokenizer.readToken(Token.UINT16_BE);
|
|
110
|
-
debug(`LSCO lsConfig=${lsConfig}`);
|
|
111
|
-
break;
|
|
112
|
-
case 'COMT':
|
|
113
|
-
default:
|
|
114
|
-
debug(`Unknown sound-property-chunk[ID=${sndPropHeader.chunkID}, size=${sndPropHeader.chunkSize}]`);
|
|
115
|
-
await this.tokenizer.ignore(Number(sndPropHeader.chunkSize));
|
|
116
|
-
}
|
|
117
|
-
const remaining = sndPropHeader.chunkSize - BigInt(this.tokenizer.position - p0);
|
|
118
|
-
if (remaining > 0) {
|
|
119
|
-
debug(`After Parsing sound-property-chunk ${sndPropHeader.chunkSize}, remaining ${remaining} bytes`);
|
|
120
|
-
await this.tokenizer.ignore(Number(remaining));
|
|
121
|
-
}
|
|
122
|
-
remainingSize -= BigInt(DsdiffToken_1.ChunkHeader64.len) + sndPropHeader.chunkSize;
|
|
123
|
-
debug(`Parsing sound-property-chunks, remainingSize=${remainingSize}`);
|
|
124
|
-
}
|
|
125
|
-
if (this.metadata.format.lossless && this.metadata.format.sampleRate && this.metadata.format.numberOfChannels && this.metadata.format.bitsPerSample) {
|
|
126
|
-
const bitrate = this.metadata.format.sampleRate * this.metadata.format.numberOfChannels * this.metadata.format.bitsPerSample;
|
|
127
|
-
this.metadata.setFormat('bitrate', bitrate);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
async handleChannelChunks(remainingSize) {
|
|
131
|
-
debug(`Parsing channel-chunks, remainingSize=${remainingSize}`);
|
|
132
|
-
const channels = [];
|
|
133
|
-
while (remainingSize >= FourCC_1.FourCcToken.len) {
|
|
134
|
-
const channelId = await this.tokenizer.readToken(FourCC_1.FourCcToken);
|
|
135
|
-
debug(`Channel[ID=${channelId}]`);
|
|
136
|
-
channels.push(channelId);
|
|
137
|
-
remainingSize -= BigInt(FourCC_1.FourCcToken.len);
|
|
138
|
-
}
|
|
139
|
-
debug(`Channels: ${channels.join(', ')}`);
|
|
140
|
-
return channels;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
exports.DsdiffParser = DsdiffParser;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DsdiffParser = void 0;
|
|
4
|
+
const Token = require("token-types");
|
|
5
|
+
const debug_1 = require("debug");
|
|
6
|
+
const strtok3 = require("strtok3/lib/core");
|
|
7
|
+
const FourCC_1 = require("../common/FourCC");
|
|
8
|
+
const BasicParser_1 = require("../common/BasicParser");
|
|
9
|
+
const ID3v2Parser_1 = require("../id3v2/ID3v2Parser");
|
|
10
|
+
const DsdiffToken_1 = require("./DsdiffToken");
|
|
11
|
+
const debug = (0, debug_1.default)('music-metadata:parser:aiff');
|
|
12
|
+
/**
|
|
13
|
+
* DSDIFF - Direct Stream Digital Interchange File Format (Phillips)
|
|
14
|
+
*
|
|
15
|
+
* Ref:
|
|
16
|
+
* - http://www.sonicstudio.com/pdf/dsd/DSDIFF_1.5_Spec.pdf
|
|
17
|
+
*/
|
|
18
|
+
class DsdiffParser extends BasicParser_1.BasicParser {
|
|
19
|
+
async parse() {
|
|
20
|
+
const header = await this.tokenizer.readToken(DsdiffToken_1.ChunkHeader64);
|
|
21
|
+
if (header.chunkID !== 'FRM8')
|
|
22
|
+
throw new Error('Unexpected chunk-ID');
|
|
23
|
+
const type = (await this.tokenizer.readToken(FourCC_1.FourCcToken)).trim();
|
|
24
|
+
switch (type) {
|
|
25
|
+
case 'DSD':
|
|
26
|
+
this.metadata.setFormat('container', `DSDIFF/${type}`);
|
|
27
|
+
this.metadata.setFormat('lossless', true);
|
|
28
|
+
return this.readFmt8Chunks(header.chunkSize - BigInt(FourCC_1.FourCcToken.len));
|
|
29
|
+
default:
|
|
30
|
+
throw Error(`Unsupported DSDIFF type: ${type}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
async readFmt8Chunks(remainingSize) {
|
|
34
|
+
while (remainingSize >= DsdiffToken_1.ChunkHeader64.len) {
|
|
35
|
+
const chunkHeader = await this.tokenizer.readToken(DsdiffToken_1.ChunkHeader64);
|
|
36
|
+
// If the data is an odd number of bytes in length, a pad byte must be added at the end
|
|
37
|
+
debug(`Chunk id=${chunkHeader.chunkID}`);
|
|
38
|
+
await this.readData(chunkHeader);
|
|
39
|
+
remainingSize -= (BigInt(DsdiffToken_1.ChunkHeader64.len) + chunkHeader.chunkSize);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async readData(header) {
|
|
43
|
+
debug(`Reading data of chunk[ID=${header.chunkID}, size=${header.chunkSize}]`);
|
|
44
|
+
const p0 = this.tokenizer.position;
|
|
45
|
+
switch (header.chunkID.trim()) {
|
|
46
|
+
case 'FVER': // 3.1 FORMAT VERSION CHUNK
|
|
47
|
+
const version = await this.tokenizer.readToken(Token.UINT32_LE);
|
|
48
|
+
debug(`DSDIFF version=${version}`);
|
|
49
|
+
break;
|
|
50
|
+
case 'PROP': // 3.2 PROPERTY CHUNK
|
|
51
|
+
const propType = await this.tokenizer.readToken(FourCC_1.FourCcToken);
|
|
52
|
+
if (propType !== 'SND ')
|
|
53
|
+
throw new Error('Unexpected PROP-chunk ID');
|
|
54
|
+
await this.handleSoundPropertyChunks(header.chunkSize - BigInt(FourCC_1.FourCcToken.len));
|
|
55
|
+
break;
|
|
56
|
+
case 'ID3': // Unofficial ID3 tag support
|
|
57
|
+
const id3_data = await this.tokenizer.readToken(new Token.Uint8ArrayType(Number(header.chunkSize)));
|
|
58
|
+
const rst = strtok3.fromBuffer(id3_data);
|
|
59
|
+
await new ID3v2Parser_1.ID3v2Parser().parse(this.metadata, rst, this.options);
|
|
60
|
+
break;
|
|
61
|
+
default:
|
|
62
|
+
debug(`Ignore chunk[ID=${header.chunkID}, size=${header.chunkSize}]`);
|
|
63
|
+
break;
|
|
64
|
+
case 'DSD':
|
|
65
|
+
this.metadata.setFormat('numberOfSamples', Number(header.chunkSize * BigInt(8) / BigInt(this.metadata.format.numberOfChannels)));
|
|
66
|
+
this.metadata.setFormat('duration', this.metadata.format.numberOfSamples / this.metadata.format.sampleRate);
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
const remaining = header.chunkSize - BigInt(this.tokenizer.position - p0);
|
|
70
|
+
if (remaining > 0) {
|
|
71
|
+
debug(`After Parsing chunk, remaining ${remaining} bytes`);
|
|
72
|
+
await this.tokenizer.ignore(Number(remaining));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
async handleSoundPropertyChunks(remainingSize) {
|
|
76
|
+
debug(`Parsing sound-property-chunks, remainingSize=${remainingSize}`);
|
|
77
|
+
while (remainingSize > 0) {
|
|
78
|
+
const sndPropHeader = await this.tokenizer.readToken(DsdiffToken_1.ChunkHeader64);
|
|
79
|
+
debug(`Sound-property-chunk[ID=${sndPropHeader.chunkID}, size=${sndPropHeader.chunkSize}]`);
|
|
80
|
+
const p0 = this.tokenizer.position;
|
|
81
|
+
switch (sndPropHeader.chunkID.trim()) {
|
|
82
|
+
case 'FS': // 3.2.1 Sample Rate Chunk
|
|
83
|
+
const sampleRate = await this.tokenizer.readToken(Token.UINT32_BE);
|
|
84
|
+
this.metadata.setFormat('sampleRate', sampleRate);
|
|
85
|
+
break;
|
|
86
|
+
case 'CHNL': // 3.2.2 Channels Chunk
|
|
87
|
+
const numChannels = await this.tokenizer.readToken(Token.UINT16_BE);
|
|
88
|
+
this.metadata.setFormat('numberOfChannels', numChannels);
|
|
89
|
+
await this.handleChannelChunks(sndPropHeader.chunkSize - BigInt(Token.UINT16_BE.len));
|
|
90
|
+
break;
|
|
91
|
+
case 'CMPR': // 3.2.3 Compression Type Chunk
|
|
92
|
+
const compressionIdCode = (await this.tokenizer.readToken(FourCC_1.FourCcToken)).trim();
|
|
93
|
+
const count = await this.tokenizer.readToken(Token.UINT8);
|
|
94
|
+
const compressionName = await this.tokenizer.readToken(new Token.StringType(count, 'ascii'));
|
|
95
|
+
if (compressionIdCode === 'DSD') {
|
|
96
|
+
this.metadata.setFormat('lossless', true);
|
|
97
|
+
this.metadata.setFormat('bitsPerSample', 1);
|
|
98
|
+
}
|
|
99
|
+
this.metadata.setFormat('codec', `${compressionIdCode} (${compressionName})`);
|
|
100
|
+
break;
|
|
101
|
+
case 'ABSS': // 3.2.4 Absolute Start Time Chunk
|
|
102
|
+
const hours = await this.tokenizer.readToken(Token.UINT16_BE);
|
|
103
|
+
const minutes = await this.tokenizer.readToken(Token.UINT8);
|
|
104
|
+
const seconds = await this.tokenizer.readToken(Token.UINT8);
|
|
105
|
+
const samples = await this.tokenizer.readToken(Token.UINT32_BE);
|
|
106
|
+
debug(`ABSS ${hours}:${minutes}:${seconds}.${samples}`);
|
|
107
|
+
break;
|
|
108
|
+
case 'LSCO': // 3.2.5 Loudspeaker Configuration Chunk
|
|
109
|
+
const lsConfig = await this.tokenizer.readToken(Token.UINT16_BE);
|
|
110
|
+
debug(`LSCO lsConfig=${lsConfig}`);
|
|
111
|
+
break;
|
|
112
|
+
case 'COMT':
|
|
113
|
+
default:
|
|
114
|
+
debug(`Unknown sound-property-chunk[ID=${sndPropHeader.chunkID}, size=${sndPropHeader.chunkSize}]`);
|
|
115
|
+
await this.tokenizer.ignore(Number(sndPropHeader.chunkSize));
|
|
116
|
+
}
|
|
117
|
+
const remaining = sndPropHeader.chunkSize - BigInt(this.tokenizer.position - p0);
|
|
118
|
+
if (remaining > 0) {
|
|
119
|
+
debug(`After Parsing sound-property-chunk ${sndPropHeader.chunkSize}, remaining ${remaining} bytes`);
|
|
120
|
+
await this.tokenizer.ignore(Number(remaining));
|
|
121
|
+
}
|
|
122
|
+
remainingSize -= BigInt(DsdiffToken_1.ChunkHeader64.len) + sndPropHeader.chunkSize;
|
|
123
|
+
debug(`Parsing sound-property-chunks, remainingSize=${remainingSize}`);
|
|
124
|
+
}
|
|
125
|
+
if (this.metadata.format.lossless && this.metadata.format.sampleRate && this.metadata.format.numberOfChannels && this.metadata.format.bitsPerSample) {
|
|
126
|
+
const bitrate = this.metadata.format.sampleRate * this.metadata.format.numberOfChannels * this.metadata.format.bitsPerSample;
|
|
127
|
+
this.metadata.setFormat('bitrate', bitrate);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
async handleChannelChunks(remainingSize) {
|
|
131
|
+
debug(`Parsing channel-chunks, remainingSize=${remainingSize}`);
|
|
132
|
+
const channels = [];
|
|
133
|
+
while (remainingSize >= FourCC_1.FourCcToken.len) {
|
|
134
|
+
const channelId = await this.tokenizer.readToken(FourCC_1.FourCcToken);
|
|
135
|
+
debug(`Channel[ID=${channelId}]`);
|
|
136
|
+
channels.push(channelId);
|
|
137
|
+
remainingSize -= BigInt(FourCC_1.FourCcToken.len);
|
|
138
|
+
}
|
|
139
|
+
debug(`Channels: ${channels.join(', ')}`);
|
|
140
|
+
return channels;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
exports.DsdiffParser = DsdiffParser;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { IGetToken } from 'strtok3/lib/core';
|
|
2
|
-
import { IChunkHeader64 } from '../iff';
|
|
3
|
-
export { IChunkHeader64 } from '../iff';
|
|
4
|
-
/**
|
|
5
|
-
* DSDIFF chunk header
|
|
6
|
-
* The data-size encoding is deviating from EA-IFF 85
|
|
7
|
-
* Ref: http://www.sonicstudio.com/pdf/dsd/DSDIFF_1.5_Spec.pdf
|
|
8
|
-
*/
|
|
9
|
-
export declare const ChunkHeader64: IGetToken<IChunkHeader64>;
|
|
1
|
+
import { IGetToken } from 'strtok3/lib/core';
|
|
2
|
+
import { IChunkHeader64 } from '../iff';
|
|
3
|
+
export { IChunkHeader64 } from '../iff';
|
|
4
|
+
/**
|
|
5
|
+
* DSDIFF chunk header
|
|
6
|
+
* The data-size encoding is deviating from EA-IFF 85
|
|
7
|
+
* Ref: http://www.sonicstudio.com/pdf/dsd/DSDIFF_1.5_Spec.pdf
|
|
8
|
+
*/
|
|
9
|
+
export declare const ChunkHeader64: IGetToken<IChunkHeader64>;
|