music-metadata 7.11.7 → 7.11.8

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.
Files changed (152) hide show
  1. package/README.md +433 -432
  2. package/lib/ParserFactory.d.ts +48 -49
  3. package/lib/ParserFactory.js +251 -251
  4. package/lib/aiff/AiffParser.d.ts +14 -15
  5. package/lib/aiff/AiffParser.js +84 -85
  6. package/lib/aiff/AiffToken.d.ts +22 -22
  7. package/lib/aiff/AiffToken.js +43 -43
  8. package/lib/apev2/APEv2Parser.d.ts +30 -30
  9. package/lib/apev2/APEv2Parser.js +161 -162
  10. package/lib/apev2/APEv2TagMapper.d.ts +4 -4
  11. package/lib/apev2/APEv2TagMapper.js +86 -86
  12. package/lib/apev2/APEv2Token.d.ts +100 -100
  13. package/lib/apev2/APEv2Token.js +126 -126
  14. package/lib/asf/AsfObject.d.ts +319 -319
  15. package/lib/asf/AsfObject.js +384 -384
  16. package/lib/asf/AsfParser.d.ts +17 -17
  17. package/lib/asf/AsfParser.js +135 -135
  18. package/lib/asf/AsfTagMapper.d.ts +7 -7
  19. package/lib/asf/AsfTagMapper.js +95 -95
  20. package/lib/asf/AsfUtil.d.ts +13 -13
  21. package/lib/asf/AsfUtil.js +40 -40
  22. package/lib/asf/GUID.d.ts +84 -86
  23. package/lib/asf/GUID.js +121 -123
  24. package/lib/common/BasicParser.d.ts +17 -17
  25. package/lib/common/BasicParser.js +18 -18
  26. package/lib/common/CaseInsensitiveTagMap.d.ts +10 -10
  27. package/lib/common/CaseInsensitiveTagMap.js +21 -21
  28. package/lib/common/CombinedTagMapper.d.ts +19 -19
  29. package/lib/common/CombinedTagMapper.js +51 -51
  30. package/lib/common/FourCC.d.ts +6 -6
  31. package/lib/common/FourCC.js +28 -28
  32. package/lib/common/GenericTagMapper.d.ts +51 -51
  33. package/lib/common/GenericTagMapper.js +55 -55
  34. package/lib/common/GenericTagTypes.d.ts +33 -33
  35. package/lib/common/GenericTagTypes.js +131 -131
  36. package/lib/common/MetadataCollector.d.ts +76 -76
  37. package/lib/common/MetadataCollector.js +275 -275
  38. package/lib/common/RandomFileReader.d.ts +20 -20
  39. package/lib/common/RandomFileReader.js +37 -37
  40. package/lib/common/RandomUint8ArrayReader.d.ts +18 -18
  41. package/lib/common/RandomUint8ArrayReader.js +25 -25
  42. package/lib/common/Util.d.ts +58 -58
  43. package/lib/common/Util.js +157 -162
  44. package/lib/core.d.ts +48 -48
  45. package/lib/core.js +90 -90
  46. package/lib/dsdiff/DsdiffParser.d.ts +14 -14
  47. package/lib/dsdiff/DsdiffParser.js +143 -143
  48. package/lib/dsdiff/DsdiffToken.d.ts +9 -9
  49. package/lib/dsdiff/DsdiffToken.js +21 -21
  50. package/lib/dsf/DsfChunk.d.ts +86 -86
  51. package/lib/dsf/DsfChunk.js +54 -54
  52. package/lib/dsf/DsfParser.d.ts +9 -9
  53. package/lib/dsf/DsfParser.js +56 -56
  54. package/lib/flac/FlacParser.d.ts +28 -28
  55. package/lib/flac/FlacParser.js +175 -175
  56. package/lib/id3v1/ID3v1Parser.d.ts +13 -13
  57. package/lib/id3v1/ID3v1Parser.js +134 -134
  58. package/lib/id3v1/ID3v1TagMap.d.ts +4 -4
  59. package/lib/id3v1/ID3v1TagMap.js +22 -22
  60. package/lib/id3v2/AbstractID3Parser.d.ts +17 -17
  61. package/lib/id3v2/AbstractID3Parser.js +60 -60
  62. package/lib/id3v2/FrameParser.d.ts +32 -32
  63. package/lib/id3v2/FrameParser.js +329 -329
  64. package/lib/id3v2/ID3v22TagMapper.d.ts +9 -9
  65. package/lib/id3v2/ID3v22TagMapper.js +55 -55
  66. package/lib/id3v2/ID3v24TagMapper.d.ts +14 -14
  67. package/lib/id3v2/ID3v24TagMapper.js +193 -193
  68. package/lib/id3v2/ID3v2Parser.d.ts +29 -29
  69. package/lib/id3v2/ID3v2Parser.js +184 -194
  70. package/lib/id3v2/ID3v2Token.d.ts +73 -73
  71. package/lib/id3v2/ID3v2Token.js +106 -106
  72. package/lib/iff/index.d.ts +33 -33
  73. package/lib/iff/index.js +19 -19
  74. package/lib/index.d.ts +45 -45
  75. package/lib/index.js +74 -74
  76. package/lib/lyrics3/Lyrics3.d.ts +3 -3
  77. package/lib/lyrics3/Lyrics3.js +17 -17
  78. package/lib/matroska/MatroskaDtd.d.ts +8 -8
  79. package/lib/matroska/MatroskaDtd.js +279 -279
  80. package/lib/matroska/MatroskaParser.d.ts +37 -37
  81. package/lib/matroska/MatroskaParser.js +235 -235
  82. package/lib/matroska/MatroskaTagMapper.d.ts +4 -4
  83. package/lib/matroska/MatroskaTagMapper.js +35 -35
  84. package/lib/matroska/types.d.ts +175 -175
  85. package/lib/matroska/types.js +33 -32
  86. package/lib/mp4/Atom.d.ts +16 -16
  87. package/lib/mp4/Atom.js +70 -70
  88. package/lib/mp4/AtomToken.d.ts +395 -395
  89. package/lib/mp4/AtomToken.js +406 -406
  90. package/lib/mp4/MP4Parser.d.ts +30 -30
  91. package/lib/mp4/MP4Parser.js +511 -511
  92. package/lib/mp4/MP4TagMapper.d.ts +5 -5
  93. package/lib/mp4/MP4TagMapper.js +115 -115
  94. package/lib/mpeg/ExtendedLameHeader.d.ts +27 -27
  95. package/lib/mpeg/ExtendedLameHeader.js +31 -31
  96. package/lib/mpeg/MpegParser.d.ts +49 -49
  97. package/lib/mpeg/MpegParser.js +524 -529
  98. package/lib/mpeg/ReplayGainDataFormat.d.ts +55 -55
  99. package/lib/mpeg/ReplayGainDataFormat.js +69 -69
  100. package/lib/mpeg/XingTag.d.ts +45 -45
  101. package/lib/mpeg/XingTag.js +69 -69
  102. package/lib/musepack/index.d.ts +5 -5
  103. package/lib/musepack/index.js +32 -32
  104. package/lib/musepack/sv7/BitReader.d.ts +13 -13
  105. package/lib/musepack/sv7/BitReader.js +54 -54
  106. package/lib/musepack/sv7/MpcSv7Parser.d.ts +8 -8
  107. package/lib/musepack/sv7/MpcSv7Parser.js +46 -46
  108. package/lib/musepack/sv7/StreamVersion7.d.ts +28 -28
  109. package/lib/musepack/sv7/StreamVersion7.js +41 -41
  110. package/lib/musepack/sv8/MpcSv8Parser.d.ts +6 -6
  111. package/lib/musepack/sv8/MpcSv8Parser.js +55 -55
  112. package/lib/musepack/sv8/StreamVersion8.d.ts +40 -40
  113. package/lib/musepack/sv8/StreamVersion8.js +80 -80
  114. package/lib/ogg/Ogg.d.ts +72 -72
  115. package/lib/ogg/Ogg.js +2 -2
  116. package/lib/ogg/OggParser.d.ts +23 -23
  117. package/lib/ogg/OggParser.js +126 -126
  118. package/lib/ogg/opus/Opus.d.ts +48 -48
  119. package/lib/ogg/opus/Opus.js +28 -28
  120. package/lib/ogg/opus/OpusParser.d.ts +25 -25
  121. package/lib/ogg/opus/OpusParser.js +56 -56
  122. package/lib/ogg/speex/Speex.d.ts +36 -36
  123. package/lib/ogg/speex/Speex.js +31 -31
  124. package/lib/ogg/speex/SpeexParser.d.ts +22 -22
  125. package/lib/ogg/speex/SpeexParser.js +35 -35
  126. package/lib/ogg/theora/Theora.d.ts +20 -20
  127. package/lib/ogg/theora/Theora.js +23 -23
  128. package/lib/ogg/theora/TheoraParser.d.ts +28 -28
  129. package/lib/ogg/theora/TheoraParser.js +44 -44
  130. package/lib/ogg/vorbis/Vorbis.d.ts +69 -79
  131. package/lib/ogg/vorbis/Vorbis.js +78 -78
  132. package/lib/ogg/vorbis/VorbisDecoder.d.ts +12 -12
  133. package/lib/ogg/vorbis/VorbisDecoder.js +32 -32
  134. package/lib/ogg/vorbis/VorbisParser.d.ts +36 -36
  135. package/lib/ogg/vorbis/VorbisParser.js +128 -128
  136. package/lib/ogg/vorbis/VorbisTagMapper.d.ts +7 -7
  137. package/lib/ogg/vorbis/VorbisTagMapper.js +132 -132
  138. package/lib/riff/RiffChunk.d.ts +16 -16
  139. package/lib/riff/RiffChunk.js +32 -32
  140. package/lib/riff/RiffInfoTagMap.d.ts +10 -10
  141. package/lib/riff/RiffInfoTagMap.js +37 -37
  142. package/lib/type.d.ts +592 -599
  143. package/lib/type.js +5 -13
  144. package/lib/wav/WaveChunk.d.ts +64 -64
  145. package/lib/wav/WaveChunk.js +65 -65
  146. package/lib/wav/WaveParser.d.ts +24 -24
  147. package/lib/wav/WaveParser.js +144 -144
  148. package/lib/wavpack/WavPackParser.d.ts +14 -14
  149. package/lib/wavpack/WavPackParser.js +99 -105
  150. package/lib/wavpack/WavPackToken.d.ts +64 -64
  151. package/lib/wavpack/WavPackToken.js +76 -76
  152. package/package.json +150 -142
package/lib/type.js CHANGED
@@ -1,14 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TrackType = void 0;
4
- var TrackType;
5
- (function (TrackType) {
6
- TrackType[TrackType["video"] = 1] = "video";
7
- TrackType[TrackType["audio"] = 2] = "audio";
8
- TrackType[TrackType["complex"] = 3] = "complex";
9
- TrackType[TrackType["logo"] = 4] = "logo";
10
- TrackType[TrackType["subtitle"] = 17] = "subtitle";
11
- TrackType[TrackType["button"] = 18] = "button";
12
- TrackType[TrackType["control"] = 32] = "control";
13
- })(TrackType = exports.TrackType || (exports.TrackType = {}));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TrackType = void 0;
4
+ var types_1 = require("./matroska/types");
5
+ Object.defineProperty(exports, "TrackType", { enumerable: true, get: function () { return types_1.TrackType; } });
14
6
  //# sourceMappingURL=type.js.map
@@ -1,64 +1,64 @@
1
- /// <reference types="node" />
2
- import { IGetToken } from 'strtok3/lib/core';
3
- import { IChunkHeader } from '../iff';
4
- /**
5
- * Ref: https://msdn.microsoft.com/en-us/library/windows/desktop/dd317599(v=vs.85).aspx
6
- */
7
- export declare enum WaveFormat {
8
- PCM = 1,
9
- ADPCM = 2,
10
- IEEE_FLOAT = 3,
11
- MPEG_ADTS_AAC = 5632,
12
- MPEG_LOAS = 5634,
13
- RAW_AAC1 = 255,
14
- DOLBY_AC3_SPDIF = 146,
15
- DVM = 8192,
16
- RAW_SPORT = 576,
17
- ESST_AC3 = 577,
18
- DRM = 9,
19
- DTS2 = 8193,
20
- MPEG = 80
21
- }
22
- /**
23
- * "fmt" sub-chunk describes the sound data's format
24
- * Ref: http://soundfile.sapp.org/doc/WaveFormat
25
- */
26
- export interface IWaveFormat {
27
- /**
28
- * PCM = 1 (i.e. Linear quantization). Values other than 1 indicate some form of compression.
29
- */
30
- wFormatTag: WaveFormat;
31
- /**
32
- * Mono = 1, Stereo = 2, etc.
33
- */
34
- nChannels: number;
35
- /**
36
- * 8000, 44100, etc.
37
- */
38
- nSamplesPerSec: number;
39
- nAvgBytesPerSec: number;
40
- nBlockAlign: number;
41
- wBitsPerSample: number;
42
- }
43
- /**
44
- * format chunk; chunk-id is "fmt "
45
- * http://soundfile.sapp.org/doc/WaveFormat/
46
- */
47
- export declare class Format implements IGetToken<IWaveFormat> {
48
- len: number;
49
- constructor(header: IChunkHeader);
50
- get(buf: Buffer, off: number): IWaveFormat;
51
- }
52
- export interface IFactChunk {
53
- dwSampleLength: number;
54
- }
55
- /**
56
- * Fact chunk; chunk-id is "fact"
57
- * http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html
58
- * http://www.recordingblogs.com/wiki/fact-chunk-of-a-wave-file
59
- */
60
- export declare class FactChunk implements IGetToken<IFactChunk> {
61
- len: number;
62
- constructor(header: IChunkHeader);
63
- get(buf: Buffer, off: number): IFactChunk;
64
- }
1
+ /// <reference types="node" />
2
+ import { IGetToken } from 'strtok3/lib/core';
3
+ import { IChunkHeader } from '../iff';
4
+ /**
5
+ * Ref: https://msdn.microsoft.com/en-us/library/windows/desktop/dd317599(v=vs.85).aspx
6
+ */
7
+ export declare enum WaveFormat {
8
+ PCM = 1,
9
+ ADPCM = 2,
10
+ IEEE_FLOAT = 3,
11
+ MPEG_ADTS_AAC = 5632,
12
+ MPEG_LOAS = 5634,
13
+ RAW_AAC1 = 255,
14
+ DOLBY_AC3_SPDIF = 146,
15
+ DVM = 8192,
16
+ RAW_SPORT = 576,
17
+ ESST_AC3 = 577,
18
+ DRM = 9,
19
+ DTS2 = 8193,
20
+ MPEG = 80
21
+ }
22
+ /**
23
+ * "fmt" sub-chunk describes the sound data's format
24
+ * Ref: http://soundfile.sapp.org/doc/WaveFormat
25
+ */
26
+ export interface IWaveFormat {
27
+ /**
28
+ * PCM = 1 (i.e. Linear quantization). Values other than 1 indicate some form of compression.
29
+ */
30
+ wFormatTag: WaveFormat;
31
+ /**
32
+ * Mono = 1, Stereo = 2, etc.
33
+ */
34
+ nChannels: number;
35
+ /**
36
+ * 8000, 44100, etc.
37
+ */
38
+ nSamplesPerSec: number;
39
+ nAvgBytesPerSec: number;
40
+ nBlockAlign: number;
41
+ wBitsPerSample: number;
42
+ }
43
+ /**
44
+ * format chunk; chunk-id is "fmt "
45
+ * http://soundfile.sapp.org/doc/WaveFormat/
46
+ */
47
+ export declare class Format implements IGetToken<IWaveFormat> {
48
+ len: number;
49
+ constructor(header: IChunkHeader);
50
+ get(buf: Buffer, off: number): IWaveFormat;
51
+ }
52
+ export interface IFactChunk {
53
+ dwSampleLength: number;
54
+ }
55
+ /**
56
+ * Fact chunk; chunk-id is "fact"
57
+ * http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html
58
+ * http://www.recordingblogs.com/wiki/fact-chunk-of-a-wave-file
59
+ */
60
+ export declare class FactChunk implements IGetToken<IFactChunk> {
61
+ len: number;
62
+ constructor(header: IChunkHeader);
63
+ get(buf: Buffer, off: number): IFactChunk;
64
+ }
@@ -1,65 +1,65 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FactChunk = exports.Format = exports.WaveFormat = void 0;
4
- /**
5
- * Ref: https://msdn.microsoft.com/en-us/library/windows/desktop/dd317599(v=vs.85).aspx
6
- */
7
- var WaveFormat;
8
- (function (WaveFormat) {
9
- WaveFormat[WaveFormat["PCM"] = 1] = "PCM";
10
- // MPEG-4 and AAC Audio Types
11
- WaveFormat[WaveFormat["ADPCM"] = 2] = "ADPCM";
12
- WaveFormat[WaveFormat["IEEE_FLOAT"] = 3] = "IEEE_FLOAT";
13
- WaveFormat[WaveFormat["MPEG_ADTS_AAC"] = 5632] = "MPEG_ADTS_AAC";
14
- WaveFormat[WaveFormat["MPEG_LOAS"] = 5634] = "MPEG_LOAS";
15
- WaveFormat[WaveFormat["RAW_AAC1"] = 255] = "RAW_AAC1";
16
- // Dolby Audio Types
17
- WaveFormat[WaveFormat["DOLBY_AC3_SPDIF"] = 146] = "DOLBY_AC3_SPDIF";
18
- WaveFormat[WaveFormat["DVM"] = 8192] = "DVM";
19
- WaveFormat[WaveFormat["RAW_SPORT"] = 576] = "RAW_SPORT";
20
- WaveFormat[WaveFormat["ESST_AC3"] = 577] = "ESST_AC3";
21
- WaveFormat[WaveFormat["DRM"] = 9] = "DRM";
22
- WaveFormat[WaveFormat["DTS2"] = 8193] = "DTS2";
23
- WaveFormat[WaveFormat["MPEG"] = 80] = "MPEG";
24
- })(WaveFormat = exports.WaveFormat || (exports.WaveFormat = {}));
25
- /**
26
- * format chunk; chunk-id is "fmt "
27
- * http://soundfile.sapp.org/doc/WaveFormat/
28
- */
29
- class Format {
30
- constructor(header) {
31
- if (header.chunkSize < 16)
32
- throw new Error('Invalid chunk size');
33
- this.len = header.chunkSize;
34
- }
35
- get(buf, off) {
36
- return {
37
- wFormatTag: buf.readUInt16LE(off),
38
- nChannels: buf.readUInt16LE(off + 2),
39
- nSamplesPerSec: buf.readUInt32LE(off + 4),
40
- nAvgBytesPerSec: buf.readUInt32LE(off + 8),
41
- nBlockAlign: buf.readUInt16LE(off + 12),
42
- wBitsPerSample: buf.readUInt16LE(off + 14)
43
- };
44
- }
45
- }
46
- exports.Format = Format;
47
- /**
48
- * Fact chunk; chunk-id is "fact"
49
- * http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html
50
- * http://www.recordingblogs.com/wiki/fact-chunk-of-a-wave-file
51
- */
52
- class FactChunk {
53
- constructor(header) {
54
- if (header.chunkSize < 4) {
55
- throw new Error('Invalid fact chunk size.');
56
- }
57
- this.len = header.chunkSize;
58
- }
59
- get(buf, off) {
60
- return {
61
- dwSampleLength: buf.readUInt32LE(off)
62
- };
63
- }
64
- }
65
- exports.FactChunk = FactChunk;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FactChunk = exports.Format = exports.WaveFormat = void 0;
4
+ /**
5
+ * Ref: https://msdn.microsoft.com/en-us/library/windows/desktop/dd317599(v=vs.85).aspx
6
+ */
7
+ var WaveFormat;
8
+ (function (WaveFormat) {
9
+ WaveFormat[WaveFormat["PCM"] = 1] = "PCM";
10
+ // MPEG-4 and AAC Audio Types
11
+ WaveFormat[WaveFormat["ADPCM"] = 2] = "ADPCM";
12
+ WaveFormat[WaveFormat["IEEE_FLOAT"] = 3] = "IEEE_FLOAT";
13
+ WaveFormat[WaveFormat["MPEG_ADTS_AAC"] = 5632] = "MPEG_ADTS_AAC";
14
+ WaveFormat[WaveFormat["MPEG_LOAS"] = 5634] = "MPEG_LOAS";
15
+ WaveFormat[WaveFormat["RAW_AAC1"] = 255] = "RAW_AAC1";
16
+ // Dolby Audio Types
17
+ WaveFormat[WaveFormat["DOLBY_AC3_SPDIF"] = 146] = "DOLBY_AC3_SPDIF";
18
+ WaveFormat[WaveFormat["DVM"] = 8192] = "DVM";
19
+ WaveFormat[WaveFormat["RAW_SPORT"] = 576] = "RAW_SPORT";
20
+ WaveFormat[WaveFormat["ESST_AC3"] = 577] = "ESST_AC3";
21
+ WaveFormat[WaveFormat["DRM"] = 9] = "DRM";
22
+ WaveFormat[WaveFormat["DTS2"] = 8193] = "DTS2";
23
+ WaveFormat[WaveFormat["MPEG"] = 80] = "MPEG";
24
+ })(WaveFormat = exports.WaveFormat || (exports.WaveFormat = {}));
25
+ /**
26
+ * format chunk; chunk-id is "fmt "
27
+ * http://soundfile.sapp.org/doc/WaveFormat/
28
+ */
29
+ class Format {
30
+ constructor(header) {
31
+ if (header.chunkSize < 16)
32
+ throw new Error('Invalid chunk size');
33
+ this.len = header.chunkSize;
34
+ }
35
+ get(buf, off) {
36
+ return {
37
+ wFormatTag: buf.readUInt16LE(off),
38
+ nChannels: buf.readUInt16LE(off + 2),
39
+ nSamplesPerSec: buf.readUInt32LE(off + 4),
40
+ nAvgBytesPerSec: buf.readUInt32LE(off + 8),
41
+ nBlockAlign: buf.readUInt16LE(off + 12),
42
+ wBitsPerSample: buf.readUInt16LE(off + 14)
43
+ };
44
+ }
45
+ }
46
+ exports.Format = Format;
47
+ /**
48
+ * Fact chunk; chunk-id is "fact"
49
+ * http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html
50
+ * http://www.recordingblogs.com/wiki/fact-chunk-of-a-wave-file
51
+ */
52
+ class FactChunk {
53
+ constructor(header) {
54
+ if (header.chunkSize < 4) {
55
+ throw new Error('Invalid fact chunk size.');
56
+ }
57
+ this.len = header.chunkSize;
58
+ }
59
+ get(buf, off) {
60
+ return {
61
+ dwSampleLength: buf.readUInt32LE(off)
62
+ };
63
+ }
64
+ }
65
+ exports.FactChunk = FactChunk;
@@ -1,24 +1,24 @@
1
- import * as riff from '../riff/RiffChunk';
2
- import { BasicParser } from '../common/BasicParser';
3
- /**
4
- * Resource Interchange File Format (RIFF) Parser
5
- *
6
- * WAVE PCM soundfile format
7
- *
8
- * Ref:
9
- * http://www.johnloomis.org/cpe102/asgn/asgn1/riff.html
10
- * http://soundfile.sapp.org/doc/WaveFormat
11
- *
12
- * ToDo: Split WAVE part from RIFF parser
13
- */
14
- export declare class WaveParser extends BasicParser {
15
- private fact;
16
- private blockAlign;
17
- private header;
18
- parse(): Promise<void>;
19
- parseRiffChunk(chunkSize: number): Promise<void>;
20
- readWaveChunk(remaining: number): Promise<void>;
21
- parseListTag(listHeader: riff.IChunkHeader): Promise<void>;
22
- private parseRiffInfoTags;
23
- private addTag;
24
- }
1
+ import * as riff from '../riff/RiffChunk';
2
+ import { BasicParser } from '../common/BasicParser';
3
+ /**
4
+ * Resource Interchange File Format (RIFF) Parser
5
+ *
6
+ * WAVE PCM soundfile format
7
+ *
8
+ * Ref:
9
+ * - http://www.johnloomis.org/cpe102/asgn/asgn1/riff.html
10
+ * - http://soundfile.sapp.org/doc/WaveFormat
11
+ *
12
+ * ToDo: Split WAVE part from RIFF parser
13
+ */
14
+ export declare class WaveParser extends BasicParser {
15
+ private fact;
16
+ private blockAlign;
17
+ private header;
18
+ parse(): Promise<void>;
19
+ parseRiffChunk(chunkSize: number): Promise<void>;
20
+ readWaveChunk(remaining: number): Promise<void>;
21
+ parseListTag(listHeader: riff.IChunkHeader): Promise<void>;
22
+ private parseRiffInfoTags;
23
+ private addTag;
24
+ }
@@ -1,144 +1,144 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WaveParser = void 0;
4
- const strtok3 = require("strtok3/lib/core");
5
- const Token = require("token-types");
6
- const initDebug = require("debug");
7
- const riff = require("../riff/RiffChunk");
8
- const WaveChunk = require("./../wav/WaveChunk");
9
- const ID3v2Parser_1 = require("../id3v2/ID3v2Parser");
10
- const util = require("../common/Util");
11
- const FourCC_1 = require("../common/FourCC");
12
- const BasicParser_1 = require("../common/BasicParser");
13
- const debug = initDebug('music-metadata:parser:RIFF');
14
- /**
15
- * Resource Interchange File Format (RIFF) Parser
16
- *
17
- * WAVE PCM soundfile format
18
- *
19
- * Ref:
20
- * http://www.johnloomis.org/cpe102/asgn/asgn1/riff.html
21
- * http://soundfile.sapp.org/doc/WaveFormat
22
- *
23
- * ToDo: Split WAVE part from RIFF parser
24
- */
25
- class WaveParser extends BasicParser_1.BasicParser {
26
- async parse() {
27
- const riffHeader = await this.tokenizer.readToken(riff.Header);
28
- debug(`pos=${this.tokenizer.position}, parse: chunkID=${riffHeader.chunkID}`);
29
- if (riffHeader.chunkID !== 'RIFF')
30
- return; // Not RIFF format
31
- return this.parseRiffChunk(riffHeader.chunkSize).catch(err => {
32
- if (!(err instanceof strtok3.EndOfStreamError)) {
33
- throw err;
34
- }
35
- });
36
- }
37
- async parseRiffChunk(chunkSize) {
38
- const type = await this.tokenizer.readToken(FourCC_1.FourCcToken);
39
- this.metadata.setFormat('container', type);
40
- switch (type) {
41
- case 'WAVE':
42
- return this.readWaveChunk(chunkSize - FourCC_1.FourCcToken.len);
43
- default:
44
- throw new Error(`Unsupported RIFF format: RIFF/${type}`);
45
- }
46
- }
47
- async readWaveChunk(remaining) {
48
- while (remaining >= riff.Header.len) {
49
- const header = await this.tokenizer.readToken(riff.Header);
50
- remaining -= riff.Header.len + header.chunkSize;
51
- if (header.chunkSize > remaining) {
52
- this.metadata.addWarning('Data chunk size exceeds file size');
53
- }
54
- this.header = header;
55
- debug(`pos=${this.tokenizer.position}, readChunk: chunkID=RIFF/WAVE/${header.chunkID}`);
56
- switch (header.chunkID) {
57
- case 'LIST':
58
- await this.parseListTag(header);
59
- break;
60
- case 'fact': // extended Format chunk,
61
- this.metadata.setFormat('lossless', false);
62
- this.fact = await this.tokenizer.readToken(new WaveChunk.FactChunk(header));
63
- break;
64
- case 'fmt ': // The Util Chunk, non-PCM Formats
65
- const fmt = await this.tokenizer.readToken(new WaveChunk.Format(header));
66
- let subFormat = WaveChunk.WaveFormat[fmt.wFormatTag];
67
- if (!subFormat) {
68
- debug('WAVE/non-PCM format=' + fmt.wFormatTag);
69
- subFormat = 'non-PCM (' + fmt.wFormatTag + ')';
70
- }
71
- this.metadata.setFormat('codec', subFormat);
72
- this.metadata.setFormat('bitsPerSample', fmt.wBitsPerSample);
73
- this.metadata.setFormat('sampleRate', fmt.nSamplesPerSec);
74
- this.metadata.setFormat('numberOfChannels', fmt.nChannels);
75
- this.metadata.setFormat('bitrate', fmt.nBlockAlign * fmt.nSamplesPerSec * 8);
76
- this.blockAlign = fmt.nBlockAlign;
77
- break;
78
- case 'id3 ': // The way Picard, FooBar currently stores, ID3 meta-data
79
- case 'ID3 ': // The way Mp3Tags stores ID3 meta-data
80
- const id3_data = await this.tokenizer.readToken(new Token.Uint8ArrayType(header.chunkSize));
81
- const rst = strtok3.fromBuffer(id3_data);
82
- await new ID3v2Parser_1.ID3v2Parser().parse(this.metadata, rst, this.options);
83
- break;
84
- case 'data': // PCM-data
85
- if (this.metadata.format.lossless !== false) {
86
- this.metadata.setFormat('lossless', true);
87
- }
88
- let chunkSize = header.chunkSize;
89
- if (this.tokenizer.fileInfo.size) {
90
- const calcRemaining = this.tokenizer.fileInfo.size - this.tokenizer.position;
91
- if (calcRemaining < chunkSize) {
92
- this.metadata.addWarning('data chunk length exceeding file length');
93
- chunkSize = calcRemaining;
94
- }
95
- }
96
- const numberOfSamples = this.fact ? this.fact.dwSampleLength : (chunkSize === 0xffffffff ? undefined : chunkSize / this.blockAlign);
97
- if (numberOfSamples) {
98
- this.metadata.setFormat('numberOfSamples', numberOfSamples);
99
- this.metadata.setFormat('duration', numberOfSamples / this.metadata.format.sampleRate);
100
- }
101
- this.metadata.setFormat('bitrate', this.metadata.format.numberOfChannels * this.blockAlign * this.metadata.format.sampleRate); // ToDo: check me
102
- await this.tokenizer.ignore(header.chunkSize);
103
- break;
104
- default:
105
- debug(`Ignore chunk: RIFF/${header.chunkID} of ${header.chunkSize} bytes`);
106
- this.metadata.addWarning('Ignore chunk: RIFF/' + header.chunkID);
107
- await this.tokenizer.ignore(header.chunkSize);
108
- }
109
- if (this.header.chunkSize % 2 === 1) {
110
- debug('Read odd padding byte'); // https://wiki.multimedia.cx/index.php/RIFF
111
- await this.tokenizer.ignore(1);
112
- }
113
- }
114
- }
115
- async parseListTag(listHeader) {
116
- const listType = await this.tokenizer.readToken(new Token.StringType(4, 'binary'));
117
- debug('pos=%s, parseListTag: chunkID=RIFF/WAVE/LIST/%s', this.tokenizer.position, listType);
118
- switch (listType) {
119
- case 'INFO':
120
- return this.parseRiffInfoTags(listHeader.chunkSize - 4);
121
- case 'adtl':
122
- default:
123
- this.metadata.addWarning('Ignore chunk: RIFF/WAVE/LIST/' + listType);
124
- debug('Ignoring chunkID=RIFF/WAVE/LIST/' + listType);
125
- return this.tokenizer.ignore(listHeader.chunkSize - 4).then();
126
- }
127
- }
128
- async parseRiffInfoTags(chunkSize) {
129
- while (chunkSize >= 8) {
130
- const header = await this.tokenizer.readToken(riff.Header);
131
- const valueToken = new riff.ListInfoTagValue(header);
132
- const value = await this.tokenizer.readToken(valueToken);
133
- this.addTag(header.chunkID, util.stripNulls(value));
134
- chunkSize -= (8 + valueToken.len);
135
- }
136
- if (chunkSize !== 0) {
137
- throw Error('Illegal remaining size: ' + chunkSize);
138
- }
139
- }
140
- addTag(id, value) {
141
- this.metadata.addTag('exif', id, value);
142
- }
143
- }
144
- exports.WaveParser = WaveParser;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WaveParser = void 0;
4
+ const strtok3 = require("strtok3/lib/core");
5
+ const Token = require("token-types");
6
+ const initDebug = require("debug");
7
+ const riff = require("../riff/RiffChunk");
8
+ const WaveChunk = require("./../wav/WaveChunk");
9
+ const ID3v2Parser_1 = require("../id3v2/ID3v2Parser");
10
+ const util = require("../common/Util");
11
+ const FourCC_1 = require("../common/FourCC");
12
+ const BasicParser_1 = require("../common/BasicParser");
13
+ const debug = initDebug('music-metadata:parser:RIFF');
14
+ /**
15
+ * Resource Interchange File Format (RIFF) Parser
16
+ *
17
+ * WAVE PCM soundfile format
18
+ *
19
+ * Ref:
20
+ * - http://www.johnloomis.org/cpe102/asgn/asgn1/riff.html
21
+ * - http://soundfile.sapp.org/doc/WaveFormat
22
+ *
23
+ * ToDo: Split WAVE part from RIFF parser
24
+ */
25
+ class WaveParser extends BasicParser_1.BasicParser {
26
+ async parse() {
27
+ const riffHeader = await this.tokenizer.readToken(riff.Header);
28
+ debug(`pos=${this.tokenizer.position}, parse: chunkID=${riffHeader.chunkID}`);
29
+ if (riffHeader.chunkID !== 'RIFF')
30
+ return; // Not RIFF format
31
+ return this.parseRiffChunk(riffHeader.chunkSize).catch(err => {
32
+ if (!(err instanceof strtok3.EndOfStreamError)) {
33
+ throw err;
34
+ }
35
+ });
36
+ }
37
+ async parseRiffChunk(chunkSize) {
38
+ const type = await this.tokenizer.readToken(FourCC_1.FourCcToken);
39
+ this.metadata.setFormat('container', type);
40
+ switch (type) {
41
+ case 'WAVE':
42
+ return this.readWaveChunk(chunkSize - FourCC_1.FourCcToken.len);
43
+ default:
44
+ throw new Error(`Unsupported RIFF format: RIFF/${type}`);
45
+ }
46
+ }
47
+ async readWaveChunk(remaining) {
48
+ while (remaining >= riff.Header.len) {
49
+ const header = await this.tokenizer.readToken(riff.Header);
50
+ remaining -= riff.Header.len + header.chunkSize;
51
+ if (header.chunkSize > remaining) {
52
+ this.metadata.addWarning('Data chunk size exceeds file size');
53
+ }
54
+ this.header = header;
55
+ debug(`pos=${this.tokenizer.position}, readChunk: chunkID=RIFF/WAVE/${header.chunkID}`);
56
+ switch (header.chunkID) {
57
+ case 'LIST':
58
+ await this.parseListTag(header);
59
+ break;
60
+ case 'fact': // extended Format chunk,
61
+ this.metadata.setFormat('lossless', false);
62
+ this.fact = await this.tokenizer.readToken(new WaveChunk.FactChunk(header));
63
+ break;
64
+ case 'fmt ': // The Util Chunk, non-PCM Formats
65
+ const fmt = await this.tokenizer.readToken(new WaveChunk.Format(header));
66
+ let subFormat = WaveChunk.WaveFormat[fmt.wFormatTag];
67
+ if (!subFormat) {
68
+ debug('WAVE/non-PCM format=' + fmt.wFormatTag);
69
+ subFormat = 'non-PCM (' + fmt.wFormatTag + ')';
70
+ }
71
+ this.metadata.setFormat('codec', subFormat);
72
+ this.metadata.setFormat('bitsPerSample', fmt.wBitsPerSample);
73
+ this.metadata.setFormat('sampleRate', fmt.nSamplesPerSec);
74
+ this.metadata.setFormat('numberOfChannels', fmt.nChannels);
75
+ this.metadata.setFormat('bitrate', fmt.nBlockAlign * fmt.nSamplesPerSec * 8);
76
+ this.blockAlign = fmt.nBlockAlign;
77
+ break;
78
+ case 'id3 ': // The way Picard, FooBar currently stores, ID3 meta-data
79
+ case 'ID3 ': // The way Mp3Tags stores ID3 meta-data
80
+ const id3_data = await this.tokenizer.readToken(new Token.Uint8ArrayType(header.chunkSize));
81
+ const rst = strtok3.fromBuffer(id3_data);
82
+ await new ID3v2Parser_1.ID3v2Parser().parse(this.metadata, rst, this.options);
83
+ break;
84
+ case 'data': // PCM-data
85
+ if (this.metadata.format.lossless !== false) {
86
+ this.metadata.setFormat('lossless', true);
87
+ }
88
+ let chunkSize = header.chunkSize;
89
+ if (this.tokenizer.fileInfo.size) {
90
+ const calcRemaining = this.tokenizer.fileInfo.size - this.tokenizer.position;
91
+ if (calcRemaining < chunkSize) {
92
+ this.metadata.addWarning('data chunk length exceeding file length');
93
+ chunkSize = calcRemaining;
94
+ }
95
+ }
96
+ const numberOfSamples = this.fact ? this.fact.dwSampleLength : (chunkSize === 0xffffffff ? undefined : chunkSize / this.blockAlign);
97
+ if (numberOfSamples) {
98
+ this.metadata.setFormat('numberOfSamples', numberOfSamples);
99
+ this.metadata.setFormat('duration', numberOfSamples / this.metadata.format.sampleRate);
100
+ }
101
+ this.metadata.setFormat('bitrate', this.metadata.format.numberOfChannels * this.blockAlign * this.metadata.format.sampleRate); // ToDo: check me
102
+ await this.tokenizer.ignore(header.chunkSize);
103
+ break;
104
+ default:
105
+ debug(`Ignore chunk: RIFF/${header.chunkID} of ${header.chunkSize} bytes`);
106
+ this.metadata.addWarning('Ignore chunk: RIFF/' + header.chunkID);
107
+ await this.tokenizer.ignore(header.chunkSize);
108
+ }
109
+ if (this.header.chunkSize % 2 === 1) {
110
+ debug('Read odd padding byte'); // https://wiki.multimedia.cx/index.php/RIFF
111
+ await this.tokenizer.ignore(1);
112
+ }
113
+ }
114
+ }
115
+ async parseListTag(listHeader) {
116
+ const listType = await this.tokenizer.readToken(new Token.StringType(4, 'binary'));
117
+ debug('pos=%s, parseListTag: chunkID=RIFF/WAVE/LIST/%s', this.tokenizer.position, listType);
118
+ switch (listType) {
119
+ case 'INFO':
120
+ return this.parseRiffInfoTags(listHeader.chunkSize - 4);
121
+ case 'adtl':
122
+ default:
123
+ this.metadata.addWarning('Ignore chunk: RIFF/WAVE/LIST/' + listType);
124
+ debug('Ignoring chunkID=RIFF/WAVE/LIST/' + listType);
125
+ return this.tokenizer.ignore(listHeader.chunkSize - 4).then();
126
+ }
127
+ }
128
+ async parseRiffInfoTags(chunkSize) {
129
+ while (chunkSize >= 8) {
130
+ const header = await this.tokenizer.readToken(riff.Header);
131
+ const valueToken = new riff.ListInfoTagValue(header);
132
+ const value = await this.tokenizer.readToken(valueToken);
133
+ this.addTag(header.chunkID, util.stripNulls(value));
134
+ chunkSize -= (8 + valueToken.len);
135
+ }
136
+ if (chunkSize !== 0) {
137
+ throw Error('Illegal remaining size: ' + chunkSize);
138
+ }
139
+ }
140
+ addTag(id, value) {
141
+ this.metadata.addTag('exif', id, value);
142
+ }
143
+ }
144
+ exports.WaveParser = WaveParser;
@@ -1,14 +1,14 @@
1
- import { BasicParser } from '../common/BasicParser';
2
- /**
3
- * WavPack Parser
4
- */
5
- export declare class WavPackParser extends BasicParser {
6
- private audioDataSize;
7
- parse(): Promise<void>;
8
- parseWavPackBlocks(): Promise<void>;
9
- /**
10
- * Ref: http://www.wavpack.com/WavPack5FileFormat.pdf, 3.0 Metadata Sub-blocks
11
- * @param remainingLength
12
- */
13
- private parseMetadataSubBlock;
14
- }
1
+ import { BasicParser } from '../common/BasicParser';
2
+ /**
3
+ * WavPack Parser
4
+ */
5
+ export declare class WavPackParser extends BasicParser {
6
+ private audioDataSize;
7
+ parse(): Promise<void>;
8
+ parseWavPackBlocks(): Promise<void>;
9
+ /**
10
+ * Ref: http://www.wavpack.com/WavPack5FileFormat.pdf, 3.0 Metadata Sub-blocks
11
+ * @param remainingLength
12
+ */
13
+ private parseMetadataSubBlock;
14
+ }