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.
Files changed (155) hide show
  1. package/LICENSE.txt +9 -9
  2. package/README.md +434 -434
  3. package/lib/ParserFactory.d.ts +48 -48
  4. package/lib/ParserFactory.js +252 -252
  5. package/lib/aiff/AiffParser.d.ts +14 -14
  6. package/lib/aiff/AiffParser.js +96 -84
  7. package/lib/aiff/AiffToken.d.ts +22 -22
  8. package/lib/aiff/AiffToken.js +48 -43
  9. package/lib/apev2/APEv2Parser.d.ts +30 -30
  10. package/lib/apev2/APEv2Parser.js +164 -164
  11. package/lib/apev2/APEv2TagMapper.d.ts +4 -4
  12. package/lib/apev2/APEv2TagMapper.js +86 -86
  13. package/lib/apev2/APEv2Token.d.ts +100 -100
  14. package/lib/apev2/APEv2Token.js +126 -126
  15. package/lib/asf/AsfObject.d.ts +319 -319
  16. package/lib/asf/AsfObject.js +381 -381
  17. package/lib/asf/AsfParser.d.ts +17 -17
  18. package/lib/asf/AsfParser.js +135 -135
  19. package/lib/asf/AsfTagMapper.d.ts +7 -7
  20. package/lib/asf/AsfTagMapper.js +95 -95
  21. package/lib/asf/AsfUtil.d.ts +13 -13
  22. package/lib/asf/AsfUtil.js +38 -38
  23. package/lib/asf/GUID.d.ts +84 -84
  24. package/lib/asf/GUID.js +121 -121
  25. package/lib/common/BasicParser.d.ts +17 -17
  26. package/lib/common/BasicParser.js +18 -18
  27. package/lib/common/CaseInsensitiveTagMap.d.ts +10 -10
  28. package/lib/common/CaseInsensitiveTagMap.js +21 -21
  29. package/lib/common/CombinedTagMapper.d.ts +19 -19
  30. package/lib/common/CombinedTagMapper.js +51 -51
  31. package/lib/common/FourCC.d.ts +6 -6
  32. package/lib/common/FourCC.js +28 -28
  33. package/lib/common/GenericTagMapper.d.ts +51 -51
  34. package/lib/common/GenericTagMapper.js +55 -55
  35. package/lib/common/GenericTagTypes.d.ts +33 -33
  36. package/lib/common/GenericTagTypes.js +131 -131
  37. package/lib/common/MetadataCollector.d.ts +76 -76
  38. package/lib/common/MetadataCollector.js +275 -275
  39. package/lib/common/RandomFileReader.d.ts +22 -22
  40. package/lib/common/RandomFileReader.js +34 -34
  41. package/lib/common/RandomUint8ArrayReader.d.ts +18 -18
  42. package/lib/common/RandomUint8ArrayReader.js +25 -25
  43. package/lib/common/Util.d.ts +57 -57
  44. package/lib/common/Util.js +157 -157
  45. package/lib/core.d.ts +48 -48
  46. package/lib/core.js +90 -90
  47. package/lib/dsdiff/DsdiffParser.d.ts +14 -14
  48. package/lib/dsdiff/DsdiffParser.js +143 -143
  49. package/lib/dsdiff/DsdiffToken.d.ts +9 -9
  50. package/lib/dsdiff/DsdiffToken.js +21 -21
  51. package/lib/dsf/DsfChunk.d.ts +86 -86
  52. package/lib/dsf/DsfChunk.js +54 -54
  53. package/lib/dsf/DsfParser.d.ts +9 -9
  54. package/lib/dsf/DsfParser.js +56 -56
  55. package/lib/flac/FlacParser.d.ts +28 -28
  56. package/lib/flac/FlacParser.js +175 -175
  57. package/lib/id3v1/ID3v1Parser.d.ts +13 -13
  58. package/lib/id3v1/ID3v1Parser.js +134 -134
  59. package/lib/id3v1/ID3v1TagMap.d.ts +4 -4
  60. package/lib/id3v1/ID3v1TagMap.js +22 -22
  61. package/lib/id3v2/AbstractID3Parser.d.ts +17 -17
  62. package/lib/id3v2/AbstractID3Parser.js +60 -60
  63. package/lib/id3v2/FrameParser.d.ts +31 -31
  64. package/lib/id3v2/FrameParser.js +329 -329
  65. package/lib/id3v2/ID3v22TagMapper.d.ts +9 -9
  66. package/lib/id3v2/ID3v22TagMapper.js +55 -55
  67. package/lib/id3v2/ID3v24TagMapper.d.ts +14 -14
  68. package/lib/id3v2/ID3v24TagMapper.js +193 -193
  69. package/lib/id3v2/ID3v2Parser.d.ts +28 -28
  70. package/lib/id3v2/ID3v2Parser.js +182 -182
  71. package/lib/id3v2/ID3v2Token.d.ts +73 -73
  72. package/lib/id3v2/ID3v2Token.js +106 -106
  73. package/lib/iff/index.d.ts +33 -33
  74. package/lib/iff/index.js +19 -19
  75. package/lib/index.d.ts +45 -45
  76. package/lib/index.js +74 -74
  77. package/lib/lyrics3/Lyrics3.d.ts +3 -3
  78. package/lib/lyrics3/Lyrics3.js +17 -17
  79. package/lib/matroska/MatroskaDtd.d.ts +8 -8
  80. package/lib/matroska/MatroskaDtd.js +279 -279
  81. package/lib/matroska/MatroskaParser.d.ts +37 -37
  82. package/lib/matroska/MatroskaParser.js +235 -235
  83. package/lib/matroska/MatroskaTagMapper.d.ts +4 -4
  84. package/lib/matroska/MatroskaTagMapper.js +35 -35
  85. package/lib/matroska/types.d.ts +175 -175
  86. package/lib/matroska/types.js +32 -32
  87. package/lib/mp4/Atom.d.ts +16 -16
  88. package/lib/mp4/Atom.js +70 -70
  89. package/lib/mp4/AtomToken.d.ts +395 -395
  90. package/lib/mp4/AtomToken.js +406 -406
  91. package/lib/mp4/MP4Parser.d.ts +30 -30
  92. package/lib/mp4/MP4Parser.js +511 -511
  93. package/lib/mp4/MP4TagMapper.d.ts +5 -5
  94. package/lib/mp4/MP4TagMapper.js +115 -115
  95. package/lib/mpeg/ExtendedLameHeader.d.ts +27 -27
  96. package/lib/mpeg/ExtendedLameHeader.js +31 -31
  97. package/lib/mpeg/MpegParser.d.ts +49 -49
  98. package/lib/mpeg/MpegParser.js +524 -524
  99. package/lib/mpeg/ReplayGainDataFormat.d.ts +55 -55
  100. package/lib/mpeg/ReplayGainDataFormat.js +69 -69
  101. package/lib/mpeg/XingTag.d.ts +45 -45
  102. package/lib/mpeg/XingTag.js +69 -69
  103. package/lib/musepack/index.d.ts +5 -5
  104. package/lib/musepack/index.js +32 -32
  105. package/lib/musepack/sv7/BitReader.d.ts +13 -13
  106. package/lib/musepack/sv7/BitReader.js +54 -54
  107. package/lib/musepack/sv7/MpcSv7Parser.d.ts +8 -8
  108. package/lib/musepack/sv7/MpcSv7Parser.js +46 -46
  109. package/lib/musepack/sv7/StreamVersion7.d.ts +28 -28
  110. package/lib/musepack/sv7/StreamVersion7.js +41 -41
  111. package/lib/musepack/sv8/MpcSv8Parser.d.ts +6 -6
  112. package/lib/musepack/sv8/MpcSv8Parser.js +55 -55
  113. package/lib/musepack/sv8/StreamVersion8.d.ts +40 -40
  114. package/lib/musepack/sv8/StreamVersion8.js +80 -80
  115. package/lib/ogg/Ogg.d.ts +72 -72
  116. package/lib/ogg/Ogg.js +2 -2
  117. package/lib/ogg/OggParser.d.ts +23 -23
  118. package/lib/ogg/OggParser.js +126 -126
  119. package/lib/ogg/opus/Opus.d.ts +48 -48
  120. package/lib/ogg/opus/Opus.js +28 -28
  121. package/lib/ogg/opus/OpusParser.d.ts +25 -25
  122. package/lib/ogg/opus/OpusParser.js +56 -56
  123. package/lib/ogg/speex/Speex.d.ts +36 -36
  124. package/lib/ogg/speex/Speex.js +31 -31
  125. package/lib/ogg/speex/SpeexParser.d.ts +22 -22
  126. package/lib/ogg/speex/SpeexParser.js +35 -35
  127. package/lib/ogg/theora/Theora.d.ts +20 -20
  128. package/lib/ogg/theora/Theora.js +23 -23
  129. package/lib/ogg/theora/TheoraParser.d.ts +28 -28
  130. package/lib/ogg/theora/TheoraParser.js +44 -44
  131. package/lib/ogg/vorbis/Vorbis.d.ts +69 -69
  132. package/lib/ogg/vorbis/Vorbis.js +78 -78
  133. package/lib/ogg/vorbis/VorbisDecoder.d.ts +12 -12
  134. package/lib/ogg/vorbis/VorbisDecoder.js +32 -32
  135. package/lib/ogg/vorbis/VorbisParser.d.ts +36 -36
  136. package/lib/ogg/vorbis/VorbisParser.js +128 -128
  137. package/lib/ogg/vorbis/VorbisTagMapper.d.ts +7 -7
  138. package/lib/ogg/vorbis/VorbisTagMapper.js +132 -132
  139. package/lib/riff/RiffChunk.d.ts +16 -16
  140. package/lib/riff/RiffChunk.js +32 -32
  141. package/lib/riff/RiffInfoTagMap.d.ts +10 -10
  142. package/lib/riff/RiffInfoTagMap.js +37 -37
  143. package/lib/type.d.ts +592 -592
  144. package/lib/type.js +5 -5
  145. package/lib/wav/BwfChunk.d.ts +17 -17
  146. package/lib/wav/BwfChunk.js +29 -28
  147. package/lib/wav/WaveChunk.d.ts +64 -64
  148. package/lib/wav/WaveChunk.js +65 -65
  149. package/lib/wav/WaveParser.d.ts +24 -24
  150. package/lib/wav/WaveParser.js +158 -156
  151. package/lib/wavpack/WavPackParser.d.ts +14 -14
  152. package/lib/wavpack/WavPackParser.js +99 -99
  153. package/lib/wavpack/WavPackToken.d.ts +64 -64
  154. package/lib/wavpack/WavPackToken.js +76 -76
  155. package/package.json +150 -150
@@ -1,84 +1,96 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AIFFParser = void 0;
4
- const Token = require("token-types");
5
- const debug_1 = require("debug");
6
- const strtok3 = require("strtok3/lib/core");
7
- const ID3v2Parser_1 = require("../id3v2/ID3v2Parser");
8
- const FourCC_1 = require("../common/FourCC");
9
- const BasicParser_1 = require("../common/BasicParser");
10
- const AiffToken = require("./AiffToken");
11
- const iff = require("../iff");
12
- const debug = (0, debug_1.default)('music-metadata:parser:aiff');
13
- /**
14
- * AIFF - Audio Interchange File Format
15
- *
16
- * Ref:
17
- * - http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/AIFF/AIFF.html
18
- * - http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/AIFF/Docs/AIFF-1.3.pdf
19
- */
20
- class AIFFParser extends BasicParser_1.BasicParser {
21
- async parse() {
22
- const header = await this.tokenizer.readToken(iff.Header);
23
- if (header.chunkID !== 'FORM')
24
- throw new Error('Invalid Chunk-ID, expected \'FORM\''); // Not AIFF format
25
- const type = await this.tokenizer.readToken(FourCC_1.FourCcToken);
26
- switch (type) {
27
- case 'AIFF':
28
- this.metadata.setFormat('container', type);
29
- this.isCompressed = false;
30
- break;
31
- case 'AIFC':
32
- this.metadata.setFormat('container', 'AIFF-C');
33
- this.isCompressed = true;
34
- break;
35
- default:
36
- throw Error('Unsupported AIFF type: ' + type);
37
- }
38
- this.metadata.setFormat('lossless', !this.isCompressed);
39
- try {
40
- while (!this.tokenizer.fileInfo.size || this.tokenizer.fileInfo.size - this.tokenizer.position >= iff.Header.len) {
41
- debug('Reading AIFF chunk at offset=' + this.tokenizer.position);
42
- const chunkHeader = await this.tokenizer.readToken(iff.Header);
43
- debug(`Chunk id=${chunkHeader.chunkID}`);
44
- const nextChunk = 2 * Math.round(chunkHeader.chunkSize / 2);
45
- const bytesRead = await this.readData(chunkHeader);
46
- await this.tokenizer.ignore(nextChunk - bytesRead);
47
- }
48
- }
49
- catch (err) {
50
- if (err instanceof strtok3.EndOfStreamError) {
51
- debug(`End-of-stream`);
52
- }
53
- else {
54
- throw err;
55
- }
56
- }
57
- }
58
- async readData(header) {
59
- switch (header.chunkID) {
60
- case 'COMM': // The Common Chunk
61
- const common = await this.tokenizer.readToken(new AiffToken.Common(header, this.isCompressed));
62
- this.metadata.setFormat('bitsPerSample', common.sampleSize);
63
- this.metadata.setFormat('sampleRate', common.sampleRate);
64
- this.metadata.setFormat('numberOfChannels', common.numChannels);
65
- this.metadata.setFormat('numberOfSamples', common.numSampleFrames);
66
- this.metadata.setFormat('duration', common.numSampleFrames / common.sampleRate);
67
- this.metadata.setFormat('codec', common.compressionName);
68
- return header.chunkSize;
69
- case 'ID3 ': // ID3-meta-data
70
- const id3_data = await this.tokenizer.readToken(new Token.Uint8ArrayType(header.chunkSize));
71
- const rst = strtok3.fromBuffer(id3_data);
72
- await new ID3v2Parser_1.ID3v2Parser().parse(this.metadata, rst, this.options);
73
- return header.chunkSize;
74
- case 'SSND': // Sound Data Chunk
75
- if (this.metadata.format.duration) {
76
- this.metadata.setFormat('bitrate', 8 * header.chunkSize / this.metadata.format.duration);
77
- }
78
- return 0;
79
- default:
80
- return 0;
81
- }
82
- }
83
- }
84
- exports.AIFFParser = AIFFParser;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AIFFParser = void 0;
4
+ const Token = require("token-types");
5
+ const debug_1 = require("debug");
6
+ const strtok3 = require("strtok3/lib/core");
7
+ const ID3v2Parser_1 = require("../id3v2/ID3v2Parser");
8
+ const FourCC_1 = require("../common/FourCC");
9
+ const BasicParser_1 = require("../common/BasicParser");
10
+ const AiffToken = require("./AiffToken");
11
+ const iff = require("../iff");
12
+ const debug = (0, debug_1.default)('music-metadata:parser:aiff');
13
+ const compressionTypes = {
14
+ NONE: 'not compressed PCM Apple Computer',
15
+ sowt: 'PCM (byte swapped)',
16
+ fl32: '32-bit floating point IEEE 32-bit float',
17
+ fl64: '64-bit floating point IEEE 64-bit float Apple Computer',
18
+ alaw: 'ALaw 2:1 8-bit ITU-T G.711 A-law',
19
+ ulaw: 'µLaw 2:1 8-bit ITU-T G.711 µ-law Apple Computer',
20
+ ULAW: 'CCITT G.711 u-law 8-bit ITU-T G.711 µ-law',
21
+ ALAW: 'CCITT G.711 A-law 8-bit ITU-T G.711 A-law',
22
+ FL32: 'Float 32 IEEE 32-bit float '
23
+ };
24
+ /**
25
+ * AIFF - Audio Interchange File Format
26
+ *
27
+ * Ref:
28
+ * - http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/AIFF/AIFF.html
29
+ * - http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/AIFF/Docs/AIFF-1.3.pdf
30
+ */
31
+ class AIFFParser extends BasicParser_1.BasicParser {
32
+ async parse() {
33
+ const header = await this.tokenizer.readToken(iff.Header);
34
+ if (header.chunkID !== 'FORM')
35
+ throw new Error('Invalid Chunk-ID, expected \'FORM\''); // Not AIFF format
36
+ const type = await this.tokenizer.readToken(FourCC_1.FourCcToken);
37
+ switch (type) {
38
+ case 'AIFF':
39
+ this.metadata.setFormat('container', type);
40
+ this.isCompressed = false;
41
+ break;
42
+ case 'AIFC':
43
+ this.metadata.setFormat('container', 'AIFF-C');
44
+ this.isCompressed = true;
45
+ break;
46
+ default:
47
+ throw Error('Unsupported AIFF type: ' + type);
48
+ }
49
+ this.metadata.setFormat('lossless', !this.isCompressed);
50
+ try {
51
+ while (!this.tokenizer.fileInfo.size || this.tokenizer.fileInfo.size - this.tokenizer.position >= iff.Header.len) {
52
+ debug('Reading AIFF chunk at offset=' + this.tokenizer.position);
53
+ const chunkHeader = await this.tokenizer.readToken(iff.Header);
54
+ debug(`Chunk id=${chunkHeader.chunkID}`);
55
+ const nextChunk = 2 * Math.round(chunkHeader.chunkSize / 2);
56
+ const bytesRead = await this.readData(chunkHeader);
57
+ await this.tokenizer.ignore(nextChunk - bytesRead);
58
+ }
59
+ }
60
+ catch (err) {
61
+ if (err instanceof strtok3.EndOfStreamError) {
62
+ debug(`End-of-stream`);
63
+ }
64
+ else {
65
+ throw err;
66
+ }
67
+ }
68
+ }
69
+ async readData(header) {
70
+ var _a;
71
+ switch (header.chunkID) {
72
+ case 'COMM': // The Common Chunk
73
+ const common = await this.tokenizer.readToken(new AiffToken.Common(header, this.isCompressed));
74
+ this.metadata.setFormat('bitsPerSample', common.sampleSize);
75
+ this.metadata.setFormat('sampleRate', common.sampleRate);
76
+ this.metadata.setFormat('numberOfChannels', common.numChannels);
77
+ this.metadata.setFormat('numberOfSamples', common.numSampleFrames);
78
+ this.metadata.setFormat('duration', common.numSampleFrames / common.sampleRate);
79
+ this.metadata.setFormat('codec', (_a = common.compressionName) !== null && _a !== void 0 ? _a : compressionTypes[common.compressionType]);
80
+ return header.chunkSize;
81
+ case 'ID3 ': // ID3-meta-data
82
+ const id3_data = await this.tokenizer.readToken(new Token.Uint8ArrayType(header.chunkSize));
83
+ const rst = strtok3.fromBuffer(id3_data);
84
+ await new ID3v2Parser_1.ID3v2Parser().parse(this.metadata, rst, this.options);
85
+ return header.chunkSize;
86
+ case 'SSND': // Sound Data Chunk
87
+ if (this.metadata.format.duration) {
88
+ this.metadata.setFormat('bitrate', 8 * header.chunkSize / this.metadata.format.duration);
89
+ }
90
+ return 0;
91
+ default:
92
+ return 0;
93
+ }
94
+ }
95
+ }
96
+ exports.AIFFParser = AIFFParser;
@@ -1,22 +1,22 @@
1
- /// <reference types="node" />
2
- import { IGetToken } from 'strtok3';
3
- import * as iff from '../iff';
4
- /**
5
- * The Common Chunk.
6
- * Describes fundamental parameters of the waveform data such as sample rate, bit resolution, and how many channels of
7
- * digital audio are stored in the FORM AIFF.
8
- */
9
- export interface ICommon {
10
- numChannels: number;
11
- numSampleFrames: number;
12
- sampleSize: number;
13
- sampleRate: number;
14
- compressionType?: string;
15
- compressionName?: string;
16
- }
17
- export declare class Common implements IGetToken<ICommon> {
18
- private isAifc;
19
- len: number;
20
- constructor(header: iff.IChunkHeader, isAifc: boolean);
21
- get(buf: Buffer, off: number): ICommon;
22
- }
1
+ /// <reference types="node" />
2
+ import { IGetToken } from 'strtok3';
3
+ import * as iff from '../iff';
4
+ /**
5
+ * The Common Chunk.
6
+ * Describes fundamental parameters of the waveform data such as sample rate, bit resolution, and how many channels of
7
+ * digital audio are stored in the FORM AIFF.
8
+ */
9
+ export interface ICommon {
10
+ numChannels: number;
11
+ numSampleFrames: number;
12
+ sampleSize: number;
13
+ sampleRate: number;
14
+ compressionType?: string;
15
+ compressionName?: string;
16
+ }
17
+ export declare class Common implements IGetToken<ICommon> {
18
+ private isAifc;
19
+ len: number;
20
+ constructor(header: iff.IChunkHeader, isAifc: boolean);
21
+ get(buf: Buffer, off: number): ICommon;
22
+ }
@@ -1,43 +1,48 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Common = void 0;
4
- const Token = require("token-types");
5
- const FourCC_1 = require("../common/FourCC");
6
- class Common {
7
- constructor(header, isAifc) {
8
- this.isAifc = isAifc;
9
- const minimumChunkSize = isAifc ? 22 : 18;
10
- if (header.chunkSize < minimumChunkSize)
11
- throw new Error(`COMMON CHUNK size should always be at least ${minimumChunkSize}`);
12
- this.len = header.chunkSize;
13
- }
14
- get(buf, off) {
15
- // see: https://cycling74.com/forums/aiffs-80-bit-sample-rate-value
16
- const shift = buf.readUInt16BE(off + 8) - 16398;
17
- const baseSampleRate = buf.readUInt16BE(off + 8 + 2);
18
- const res = {
19
- numChannels: buf.readUInt16BE(off),
20
- numSampleFrames: buf.readUInt32BE(off + 2),
21
- sampleSize: buf.readUInt16BE(off + 6),
22
- sampleRate: shift < 0 ? baseSampleRate >> Math.abs(shift) : baseSampleRate << shift
23
- };
24
- if (this.isAifc) {
25
- res.compressionType = FourCC_1.FourCcToken.get(buf, off + 18);
26
- if (this.len > 22) {
27
- const strLen = buf.readInt8(off + 22);
28
- const padding = (strLen + 1) % 2;
29
- if (23 + strLen + padding === this.len) {
30
- res.compressionName = new Token.StringType(strLen, 'binary').get(buf, off + 23);
31
- }
32
- else {
33
- throw new Error('Illegal pstring length');
34
- }
35
- }
36
- }
37
- else {
38
- res.compressionName = 'PCM';
39
- }
40
- return res;
41
- }
42
- }
43
- exports.Common = Common;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Common = void 0;
4
+ const Token = require("token-types");
5
+ const FourCC_1 = require("../common/FourCC");
6
+ class Common {
7
+ constructor(header, isAifc) {
8
+ this.isAifc = isAifc;
9
+ const minimumChunkSize = isAifc ? 22 : 18;
10
+ if (header.chunkSize < minimumChunkSize)
11
+ throw new Error(`COMMON CHUNK size should always be at least ${minimumChunkSize}`);
12
+ this.len = header.chunkSize;
13
+ }
14
+ get(buf, off) {
15
+ // see: https://cycling74.com/forums/aiffs-80-bit-sample-rate-value
16
+ const shift = buf.readUInt16BE(off + 8) - 16398;
17
+ const baseSampleRate = buf.readUInt16BE(off + 8 + 2);
18
+ const res = {
19
+ numChannels: buf.readUInt16BE(off),
20
+ numSampleFrames: buf.readUInt32BE(off + 2),
21
+ sampleSize: buf.readUInt16BE(off + 6),
22
+ sampleRate: shift < 0 ? baseSampleRate >> Math.abs(shift) : baseSampleRate << shift
23
+ };
24
+ if (this.isAifc) {
25
+ res.compressionType = FourCC_1.FourCcToken.get(buf, off + 18);
26
+ if (this.len > 22) {
27
+ const strLen = buf.readInt8(off + 22);
28
+ if (strLen > 0) {
29
+ const padding = (strLen + 1) % 2;
30
+ if (23 + strLen + padding === this.len) {
31
+ res.compressionName = new Token.StringType(strLen, 'binary').get(buf, off + 23);
32
+ }
33
+ else {
34
+ throw new Error('Illegal pstring length');
35
+ }
36
+ }
37
+ else {
38
+ res.compressionName = undefined;
39
+ }
40
+ }
41
+ }
42
+ else {
43
+ res.compressionName = 'PCM';
44
+ }
45
+ return res;
46
+ }
47
+ }
48
+ exports.Common = Common;
@@ -1,30 +1,30 @@
1
- import * as strtok3 from 'strtok3/lib/core';
2
- import { IOptions, IRandomReader, IApeHeader } from '../type';
3
- import { INativeMetadataCollector } from '../common/MetadataCollector';
4
- import { BasicParser } from '../common/BasicParser';
5
- import { IFooter, IHeader } from './APEv2Token';
6
- export declare class APEv2Parser extends BasicParser {
7
- static tryParseApeHeader(metadata: INativeMetadataCollector, tokenizer: strtok3.ITokenizer, options: IOptions): Promise<void>;
8
- /**
9
- * Calculate the media file duration
10
- * @param ah ApeHeader
11
- * @return {number} duration in seconds
12
- */
13
- static calculateDuration(ah: IHeader): number;
14
- /**
15
- * Calculates the APEv1 / APEv2 first field offset
16
- * @param reader
17
- * @param offset
18
- */
19
- static findApeFooterOffset(reader: IRandomReader, offset: number): Promise<IApeHeader>;
20
- private static parseTagFooter;
21
- private ape;
22
- /**
23
- * Parse APEv1 / APEv2 header if header signature found
24
- */
25
- tryParseApeHeader(): Promise<void>;
26
- parse(): Promise<void>;
27
- parseTags(footer: IFooter): Promise<void>;
28
- private parseDescriptorExpansion;
29
- private parseHeader;
30
- }
1
+ import * as strtok3 from 'strtok3/lib/core';
2
+ import { IOptions, IRandomReader, IApeHeader } from '../type';
3
+ import { INativeMetadataCollector } from '../common/MetadataCollector';
4
+ import { BasicParser } from '../common/BasicParser';
5
+ import { IFooter, IHeader } from './APEv2Token';
6
+ export declare class APEv2Parser extends BasicParser {
7
+ static tryParseApeHeader(metadata: INativeMetadataCollector, tokenizer: strtok3.ITokenizer, options: IOptions): Promise<void>;
8
+ /**
9
+ * Calculate the media file duration
10
+ * @param ah ApeHeader
11
+ * @return {number} duration in seconds
12
+ */
13
+ static calculateDuration(ah: IHeader): number;
14
+ /**
15
+ * Calculates the APEv1 / APEv2 first field offset
16
+ * @param reader
17
+ * @param offset
18
+ */
19
+ static findApeFooterOffset(reader: IRandomReader, offset: number): Promise<IApeHeader>;
20
+ private static parseTagFooter;
21
+ private ape;
22
+ /**
23
+ * Parse APEv1 / APEv2 header if header signature found
24
+ */
25
+ tryParseApeHeader(): Promise<void>;
26
+ parse(): Promise<void>;
27
+ parseTags(footer: IFooter): Promise<void>;
28
+ private parseDescriptorExpansion;
29
+ private parseHeader;
30
+ }