music-metadata 7.11.3 → 7.11.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/README.md +432 -432
  2. package/lib/ParserFactory.d.ts +49 -49
  3. package/lib/ParserFactory.js +251 -251
  4. package/lib/aiff/AiffParser.d.ts +15 -15
  5. package/lib/aiff/AiffParser.js +85 -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 +162 -162
  10. package/lib/apev2/APEv2TagMapper.d.ts +4 -4
  11. package/lib/apev2/APEv2TagMapper.js +87 -86
  12. package/lib/apev2/APEv2Token.d.ts +100 -100
  13. package/lib/apev2/APEv2Token.js +127 -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 +96 -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 +86 -86
  23. package/lib/asf/GUID.js +123 -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 +22 -21
  28. package/lib/common/CombinedTagMapper.d.ts +19 -19
  29. package/lib/common/CombinedTagMapper.js +52 -51
  30. package/lib/common/FourCC.d.ts +6 -6
  31. package/lib/common/FourCC.js +29 -28
  32. package/lib/common/GenericTagMapper.d.ts +51 -51
  33. package/lib/common/GenericTagMapper.js +56 -55
  34. package/lib/common/GenericTagTypes.d.ts +33 -33
  35. package/lib/common/GenericTagTypes.js +132 -131
  36. package/lib/common/MetadataCollector.d.ts +76 -76
  37. package/lib/common/MetadataCollector.js +276 -274
  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 -57
  43. package/lib/common/Util.js +163 -169
  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 +23 -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 -323
  64. package/lib/id3v2/ID3v22TagMapper.d.ts +9 -9
  65. package/lib/id3v2/ID3v22TagMapper.js +56 -54
  66. package/lib/id3v2/ID3v24TagMapper.d.ts +14 -14
  67. package/lib/id3v2/ID3v24TagMapper.js +194 -193
  68. package/lib/id3v2/ID3v2Parser.d.ts +29 -29
  69. package/lib/id3v2/ID3v2Parser.js +194 -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 -34
  75. package/lib/index.js +74 -64
  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 -234
  82. package/lib/matroska/MatroskaTagMapper.d.ts +4 -4
  83. package/lib/matroska/MatroskaTagMapper.js +36 -35
  84. package/lib/matroska/types.d.ts +175 -175
  85. package/lib/matroska/types.js +32 -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 +116 -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 +529 -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 +79 -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 +133 -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 +38 -37
  142. package/lib/type.d.ts +599 -599
  143. package/lib/type.js +14 -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 +105 -105
  150. package/lib/wavpack/WavPackToken.d.ts +64 -64
  151. package/lib/wavpack/WavPackToken.js +76 -76
  152. package/package.json +142 -142
@@ -1,100 +1,100 @@
1
- import * as Token from 'token-types';
2
- import { IGetToken } from 'strtok3/lib/core';
3
- /**
4
- * APETag versionIndex history / supported formats
5
- *
6
- * 1.0 (1000) - Original APE tag spec. Fully supported by this code.
7
- * 2.0 (2000) - Refined APE tag spec (better streaming support, UTF StringEncoding). Fully supported by this code.
8
- *
9
- * Notes:
10
- * - also supports reading of ID3v1.1 tags
11
- * - all saving done in the APE Tag format using CURRENT_APE_TAG_VERSION
12
- *
13
- * APE File Format Overview: (pieces in order -- only valid for the latest versionIndex APE files)
14
- *
15
- * JUNK - any amount of "junk" before the APE_DESCRIPTOR (so people that put ID3v2 tags on the files aren't hosed)
16
- * APE_DESCRIPTOR - defines the sizes (and offsets) of all the pieces, as well as the MD5 checksum
17
- * APE_HEADER - describes all of the necessary information about the APE file
18
- * SEEK TABLE - the table that represents seek offsets [optional]
19
- * HEADER DATA - the pre-audio data from the original file [optional]
20
- * APE FRAMES - the actual compressed audio (broken into frames for seekability)
21
- * TERMINATING DATA - the post-audio data from the original file [optional]
22
- * TAG - describes all the properties of the file [optional]
23
- */
24
- export interface IDescriptor {
25
- ID: string;
26
- version: number;
27
- descriptorBytes: number;
28
- headerBytes: number;
29
- seekTableBytes: number;
30
- headerDataBytes: number;
31
- apeFrameDataBytes: number;
32
- apeFrameDataBytesHigh: number;
33
- terminatingDataBytes: number;
34
- fileMD5: Uint8Array;
35
- }
36
- /**
37
- * APE_HEADER: describes all of the necessary information about the APE file
38
- */
39
- export interface IHeader {
40
- compressionLevel: number;
41
- formatFlags: number;
42
- blocksPerFrame: number;
43
- finalFrameBlocks: number;
44
- totalFrames: number;
45
- bitsPerSample: number;
46
- channel: number;
47
- sampleRate: number;
48
- }
49
- export interface IFooter {
50
- ID: string;
51
- version: number;
52
- size: number;
53
- fields: number;
54
- flags: ITagFlags;
55
- }
56
- export declare enum DataType {
57
- text_utf8 = 0,
58
- binary = 1,
59
- external_info = 2,
60
- reserved = 3
61
- }
62
- /**
63
- * APE_DESCRIPTOR: defines the sizes (and offsets) of all the pieces, as well as the MD5 checksum
64
- */
65
- export declare const DescriptorParser: IGetToken<IDescriptor>;
66
- /**
67
- * APE_HEADER: describes all of the necessary information about the APE file
68
- */
69
- export declare const Header: IGetToken<IHeader>;
70
- /**
71
- * APE Tag Header/Footer Version 2.0
72
- * TAG: describes all the properties of the file [optional]
73
- */
74
- export declare const TagFooter: IGetToken<IFooter>;
75
- /**
76
- * APE Tag v2.0 Item Header
77
- */
78
- export interface ITagItemHeader {
79
- size: number;
80
- flags: ITagFlags;
81
- }
82
- /**
83
- * APE Tag v2.0 Item Header
84
- */
85
- export declare const TagItemHeader: IGetToken<ITagItemHeader>;
86
- export declare const TagField: (footer: any) => Token.Uint8ArrayType;
87
- export interface ITagFlags {
88
- containsHeader: boolean;
89
- containsFooter: boolean;
90
- isHeader: boolean;
91
- readOnly: boolean;
92
- dataType: DataType;
93
- }
94
- export declare function parseTagFlags(flags: any): ITagFlags;
95
- /**
96
- * @param num {number}
97
- * @param bit 0 is least significant bit (LSB)
98
- * @return {boolean} true if bit is 1; otherwise false
99
- */
100
- export declare function isBitSet(num: any, bit: any): boolean;
1
+ import * as Token from 'token-types';
2
+ import { IGetToken } from 'strtok3/lib/core';
3
+ /**
4
+ * APETag versionIndex history / supported formats
5
+ *
6
+ * 1.0 (1000) - Original APE tag spec. Fully supported by this code.
7
+ * 2.0 (2000) - Refined APE tag spec (better streaming support, UTF StringEncoding). Fully supported by this code.
8
+ *
9
+ * Notes:
10
+ * - also supports reading of ID3v1.1 tags
11
+ * - all saving done in the APE Tag format using CURRENT_APE_TAG_VERSION
12
+ *
13
+ * APE File Format Overview: (pieces in order -- only valid for the latest versionIndex APE files)
14
+ *
15
+ * JUNK - any amount of "junk" before the APE_DESCRIPTOR (so people that put ID3v2 tags on the files aren't hosed)
16
+ * APE_DESCRIPTOR - defines the sizes (and offsets) of all the pieces, as well as the MD5 checksum
17
+ * APE_HEADER - describes all of the necessary information about the APE file
18
+ * SEEK TABLE - the table that represents seek offsets [optional]
19
+ * HEADER DATA - the pre-audio data from the original file [optional]
20
+ * APE FRAMES - the actual compressed audio (broken into frames for seekability)
21
+ * TERMINATING DATA - the post-audio data from the original file [optional]
22
+ * TAG - describes all the properties of the file [optional]
23
+ */
24
+ export interface IDescriptor {
25
+ ID: string;
26
+ version: number;
27
+ descriptorBytes: number;
28
+ headerBytes: number;
29
+ seekTableBytes: number;
30
+ headerDataBytes: number;
31
+ apeFrameDataBytes: number;
32
+ apeFrameDataBytesHigh: number;
33
+ terminatingDataBytes: number;
34
+ fileMD5: Uint8Array;
35
+ }
36
+ /**
37
+ * APE_HEADER: describes all of the necessary information about the APE file
38
+ */
39
+ export interface IHeader {
40
+ compressionLevel: number;
41
+ formatFlags: number;
42
+ blocksPerFrame: number;
43
+ finalFrameBlocks: number;
44
+ totalFrames: number;
45
+ bitsPerSample: number;
46
+ channel: number;
47
+ sampleRate: number;
48
+ }
49
+ export interface IFooter {
50
+ ID: string;
51
+ version: number;
52
+ size: number;
53
+ fields: number;
54
+ flags: ITagFlags;
55
+ }
56
+ export declare enum DataType {
57
+ text_utf8 = 0,
58
+ binary = 1,
59
+ external_info = 2,
60
+ reserved = 3
61
+ }
62
+ /**
63
+ * APE_DESCRIPTOR: defines the sizes (and offsets) of all the pieces, as well as the MD5 checksum
64
+ */
65
+ export declare const DescriptorParser: IGetToken<IDescriptor>;
66
+ /**
67
+ * APE_HEADER: describes all of the necessary information about the APE file
68
+ */
69
+ export declare const Header: IGetToken<IHeader>;
70
+ /**
71
+ * APE Tag Header/Footer Version 2.0
72
+ * TAG: describes all the properties of the file [optional]
73
+ */
74
+ export declare const TagFooter: IGetToken<IFooter>;
75
+ /**
76
+ * APE Tag v2.0 Item Header
77
+ */
78
+ export interface ITagItemHeader {
79
+ size: number;
80
+ flags: ITagFlags;
81
+ }
82
+ /**
83
+ * APE Tag v2.0 Item Header
84
+ */
85
+ export declare const TagItemHeader: IGetToken<ITagItemHeader>;
86
+ export declare const TagField: (footer: any) => Token.Uint8ArrayType;
87
+ export interface ITagFlags {
88
+ containsHeader: boolean;
89
+ containsFooter: boolean;
90
+ isHeader: boolean;
91
+ readOnly: boolean;
92
+ dataType: DataType;
93
+ }
94
+ export declare function parseTagFlags(flags: any): ITagFlags;
95
+ /**
96
+ * @param num {number}
97
+ * @param bit 0 is least significant bit (LSB)
98
+ * @return {boolean} true if bit is 1; otherwise false
99
+ */
100
+ export declare function isBitSet(num: any, bit: any): boolean;
@@ -1,126 +1,127 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isBitSet = exports.parseTagFlags = exports.TagField = exports.TagItemHeader = exports.TagFooter = exports.Header = exports.DescriptorParser = exports.DataType = void 0;
4
- const Token = require("token-types");
5
- const FourCC_1 = require("../common/FourCC");
6
- var DataType;
7
- (function (DataType) {
8
- DataType[DataType["text_utf8"] = 0] = "text_utf8";
9
- DataType[DataType["binary"] = 1] = "binary";
10
- DataType[DataType["external_info"] = 2] = "external_info";
11
- DataType[DataType["reserved"] = 3] = "reserved";
12
- })(DataType = exports.DataType || (exports.DataType = {}));
13
- /**
14
- * APE_DESCRIPTOR: defines the sizes (and offsets) of all the pieces, as well as the MD5 checksum
15
- */
16
- exports.DescriptorParser = {
17
- len: 52,
18
- get: (buf, off) => {
19
- return {
20
- // should equal 'MAC '
21
- ID: FourCC_1.FourCcToken.get(buf, off),
22
- // versionIndex number * 1000 (3.81 = 3810) (remember that 4-byte alignment causes this to take 4-bytes)
23
- version: Token.UINT32_LE.get(buf, off + 4) / 1000,
24
- // the number of descriptor bytes (allows later expansion of this header)
25
- descriptorBytes: Token.UINT32_LE.get(buf, off + 8),
26
- // the number of header APE_HEADER bytes
27
- headerBytes: Token.UINT32_LE.get(buf, off + 12),
28
- // the number of header APE_HEADER bytes
29
- seekTableBytes: Token.UINT32_LE.get(buf, off + 16),
30
- // the number of header data bytes (from original file)
31
- headerDataBytes: Token.UINT32_LE.get(buf, off + 20),
32
- // the number of bytes of APE frame data
33
- apeFrameDataBytes: Token.UINT32_LE.get(buf, off + 24),
34
- // the high order number of APE frame data bytes
35
- apeFrameDataBytesHigh: Token.UINT32_LE.get(buf, off + 28),
36
- // the terminating data of the file (not including tag data)
37
- terminatingDataBytes: Token.UINT32_LE.get(buf, off + 32),
38
- // the MD5 hash of the file (see notes for usage... it's a little tricky)
39
- fileMD5: new Token.Uint8ArrayType(16).get(buf, off + 36)
40
- };
41
- }
42
- };
43
- /**
44
- * APE_HEADER: describes all of the necessary information about the APE file
45
- */
46
- exports.Header = {
47
- len: 24,
48
- get: (buf, off) => {
49
- return {
50
- // the compression level (see defines I.E. COMPRESSION_LEVEL_FAST)
51
- compressionLevel: Token.UINT16_LE.get(buf, off),
52
- // any format flags (for future use)
53
- formatFlags: Token.UINT16_LE.get(buf, off + 2),
54
- // the number of audio blocks in one frame
55
- blocksPerFrame: Token.UINT32_LE.get(buf, off + 4),
56
- // the number of audio blocks in the final frame
57
- finalFrameBlocks: Token.UINT32_LE.get(buf, off + 8),
58
- // the total number of frames
59
- totalFrames: Token.UINT32_LE.get(buf, off + 12),
60
- // the bits per sample (typically 16)
61
- bitsPerSample: Token.UINT16_LE.get(buf, off + 16),
62
- // the number of channels (1 or 2)
63
- channel: Token.UINT16_LE.get(buf, off + 18),
64
- // the sample rate (typically 44100)
65
- sampleRate: Token.UINT32_LE.get(buf, off + 20)
66
- };
67
- }
68
- };
69
- /**
70
- * APE Tag Header/Footer Version 2.0
71
- * TAG: describes all the properties of the file [optional]
72
- */
73
- exports.TagFooter = {
74
- len: 32,
75
- get: (buf, off) => {
76
- return {
77
- // should equal 'APETAGEX'
78
- ID: new Token.StringType(8, 'ascii').get(buf, off),
79
- // equals CURRENT_APE_TAG_VERSION
80
- version: Token.UINT32_LE.get(buf, off + 8),
81
- // the complete size of the tag, including this footer (excludes header)
82
- size: Token.UINT32_LE.get(buf, off + 12),
83
- // the number of fields in the tag
84
- fields: Token.UINT32_LE.get(buf, off + 16),
85
- // reserved for later use (must be zero),
86
- flags: parseTagFlags(Token.UINT32_LE.get(buf, off + 20))
87
- };
88
- }
89
- };
90
- /**
91
- * APE Tag v2.0 Item Header
92
- */
93
- exports.TagItemHeader = {
94
- len: 8,
95
- get: (buf, off) => {
96
- return {
97
- // Length of assigned value in bytes
98
- size: Token.UINT32_LE.get(buf, off),
99
- // reserved for later use (must be zero),
100
- flags: parseTagFlags(Token.UINT32_LE.get(buf, off + 4))
101
- };
102
- }
103
- };
104
- const TagField = footer => {
105
- return new Token.Uint8ArrayType(footer.size - exports.TagFooter.len);
106
- };
107
- exports.TagField = TagField;
108
- function parseTagFlags(flags) {
109
- return {
110
- containsHeader: isBitSet(flags, 31),
111
- containsFooter: isBitSet(flags, 30),
112
- isHeader: isBitSet(flags, 31),
113
- readOnly: isBitSet(flags, 0),
114
- dataType: (flags & 6) >> 1
115
- };
116
- }
117
- exports.parseTagFlags = parseTagFlags;
118
- /**
119
- * @param num {number}
120
- * @param bit 0 is least significant bit (LSB)
121
- * @return {boolean} true if bit is 1; otherwise false
122
- */
123
- function isBitSet(num, bit) {
124
- return (num & 1 << bit) !== 0;
125
- }
126
- exports.isBitSet = isBitSet;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isBitSet = exports.parseTagFlags = exports.TagField = exports.TagItemHeader = exports.TagFooter = exports.Header = exports.DescriptorParser = exports.DataType = void 0;
4
+ const Token = require("token-types");
5
+ const FourCC_1 = require("../common/FourCC");
6
+ var DataType;
7
+ (function (DataType) {
8
+ DataType[DataType["text_utf8"] = 0] = "text_utf8";
9
+ DataType[DataType["binary"] = 1] = "binary";
10
+ DataType[DataType["external_info"] = 2] = "external_info";
11
+ DataType[DataType["reserved"] = 3] = "reserved";
12
+ })(DataType = exports.DataType || (exports.DataType = {}));
13
+ /**
14
+ * APE_DESCRIPTOR: defines the sizes (and offsets) of all the pieces, as well as the MD5 checksum
15
+ */
16
+ exports.DescriptorParser = {
17
+ len: 52,
18
+ get: (buf, off) => {
19
+ return {
20
+ // should equal 'MAC '
21
+ ID: FourCC_1.FourCcToken.get(buf, off),
22
+ // versionIndex number * 1000 (3.81 = 3810) (remember that 4-byte alignment causes this to take 4-bytes)
23
+ version: Token.UINT32_LE.get(buf, off + 4) / 1000,
24
+ // the number of descriptor bytes (allows later expansion of this header)
25
+ descriptorBytes: Token.UINT32_LE.get(buf, off + 8),
26
+ // the number of header APE_HEADER bytes
27
+ headerBytes: Token.UINT32_LE.get(buf, off + 12),
28
+ // the number of header APE_HEADER bytes
29
+ seekTableBytes: Token.UINT32_LE.get(buf, off + 16),
30
+ // the number of header data bytes (from original file)
31
+ headerDataBytes: Token.UINT32_LE.get(buf, off + 20),
32
+ // the number of bytes of APE frame data
33
+ apeFrameDataBytes: Token.UINT32_LE.get(buf, off + 24),
34
+ // the high order number of APE frame data bytes
35
+ apeFrameDataBytesHigh: Token.UINT32_LE.get(buf, off + 28),
36
+ // the terminating data of the file (not including tag data)
37
+ terminatingDataBytes: Token.UINT32_LE.get(buf, off + 32),
38
+ // the MD5 hash of the file (see notes for usage... it's a little tricky)
39
+ fileMD5: new Token.Uint8ArrayType(16).get(buf, off + 36)
40
+ };
41
+ }
42
+ };
43
+ /**
44
+ * APE_HEADER: describes all of the necessary information about the APE file
45
+ */
46
+ exports.Header = {
47
+ len: 24,
48
+ get: (buf, off) => {
49
+ return {
50
+ // the compression level (see defines I.E. COMPRESSION_LEVEL_FAST)
51
+ compressionLevel: Token.UINT16_LE.get(buf, off),
52
+ // any format flags (for future use)
53
+ formatFlags: Token.UINT16_LE.get(buf, off + 2),
54
+ // the number of audio blocks in one frame
55
+ blocksPerFrame: Token.UINT32_LE.get(buf, off + 4),
56
+ // the number of audio blocks in the final frame
57
+ finalFrameBlocks: Token.UINT32_LE.get(buf, off + 8),
58
+ // the total number of frames
59
+ totalFrames: Token.UINT32_LE.get(buf, off + 12),
60
+ // the bits per sample (typically 16)
61
+ bitsPerSample: Token.UINT16_LE.get(buf, off + 16),
62
+ // the number of channels (1 or 2)
63
+ channel: Token.UINT16_LE.get(buf, off + 18),
64
+ // the sample rate (typically 44100)
65
+ sampleRate: Token.UINT32_LE.get(buf, off + 20)
66
+ };
67
+ }
68
+ };
69
+ /**
70
+ * APE Tag Header/Footer Version 2.0
71
+ * TAG: describes all the properties of the file [optional]
72
+ */
73
+ exports.TagFooter = {
74
+ len: 32,
75
+ get: (buf, off) => {
76
+ return {
77
+ // should equal 'APETAGEX'
78
+ ID: new Token.StringType(8, 'ascii').get(buf, off),
79
+ // equals CURRENT_APE_TAG_VERSION
80
+ version: Token.UINT32_LE.get(buf, off + 8),
81
+ // the complete size of the tag, including this footer (excludes header)
82
+ size: Token.UINT32_LE.get(buf, off + 12),
83
+ // the number of fields in the tag
84
+ fields: Token.UINT32_LE.get(buf, off + 16),
85
+ // reserved for later use (must be zero),
86
+ flags: parseTagFlags(Token.UINT32_LE.get(buf, off + 20))
87
+ };
88
+ }
89
+ };
90
+ /**
91
+ * APE Tag v2.0 Item Header
92
+ */
93
+ exports.TagItemHeader = {
94
+ len: 8,
95
+ get: (buf, off) => {
96
+ return {
97
+ // Length of assigned value in bytes
98
+ size: Token.UINT32_LE.get(buf, off),
99
+ // reserved for later use (must be zero),
100
+ flags: parseTagFlags(Token.UINT32_LE.get(buf, off + 4))
101
+ };
102
+ }
103
+ };
104
+ const TagField = footer => {
105
+ return new Token.Uint8ArrayType(footer.size - exports.TagFooter.len);
106
+ };
107
+ exports.TagField = TagField;
108
+ function parseTagFlags(flags) {
109
+ return {
110
+ containsHeader: isBitSet(flags, 31),
111
+ containsFooter: isBitSet(flags, 30),
112
+ isHeader: isBitSet(flags, 31),
113
+ readOnly: isBitSet(flags, 0),
114
+ dataType: (flags & 6) >> 1
115
+ };
116
+ }
117
+ exports.parseTagFlags = parseTagFlags;
118
+ /**
119
+ * @param num {number}
120
+ * @param bit 0 is least significant bit (LSB)
121
+ * @return {boolean} true if bit is 1; otherwise false
122
+ */
123
+ function isBitSet(num, bit) {
124
+ return (num & 1 << bit) !== 0;
125
+ }
126
+ exports.isBitSet = isBitSet;
127
+ //# sourceMappingURL=APEv2Token.js.map