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,28 +1,28 @@
1
- /// <reference types="node" />
2
- import { ITokenizer } from 'strtok3/lib/core';
3
- import { IOptions } from '../../type';
4
- import { INativeMetadataCollector } from '../../common/MetadataCollector';
5
- import * as Ogg from '../Ogg';
6
- /**
7
- * Ref:
8
- * https://theora.org/doc/Theora.pdf
9
- */
10
- export declare class TheoraParser implements Ogg.IPageConsumer {
11
- private metadata;
12
- private tokenizer;
13
- constructor(metadata: INativeMetadataCollector, options: IOptions, tokenizer: ITokenizer);
14
- /**
15
- * Vorbis 1 parser
16
- * @param header Ogg Page Header
17
- * @param pageData Page data
18
- */
19
- parsePage(header: Ogg.IPageHeader, pageData: Buffer): void;
20
- flush(): void;
21
- calculateDuration(header: Ogg.IPageHeader): void;
22
- /**
23
- * Parse first Theora Ogg page. the initial identification header packet
24
- * @param {IPageHeader} header
25
- * @param {Buffer} pageData
26
- */
27
- protected parseFirstPage(header: Ogg.IPageHeader, pageData: Buffer): void;
28
- }
1
+ /// <reference types="node" />
2
+ import { ITokenizer } from 'strtok3/lib/core';
3
+ import { IOptions } from '../../type';
4
+ import { INativeMetadataCollector } from '../../common/MetadataCollector';
5
+ import * as Ogg from '../Ogg';
6
+ /**
7
+ * Ref:
8
+ * https://theora.org/doc/Theora.pdf
9
+ */
10
+ export declare class TheoraParser implements Ogg.IPageConsumer {
11
+ private metadata;
12
+ private tokenizer;
13
+ constructor(metadata: INativeMetadataCollector, options: IOptions, tokenizer: ITokenizer);
14
+ /**
15
+ * Vorbis 1 parser
16
+ * @param header Ogg Page Header
17
+ * @param pageData Page data
18
+ */
19
+ parsePage(header: Ogg.IPageHeader, pageData: Buffer): void;
20
+ flush(): void;
21
+ calculateDuration(header: Ogg.IPageHeader): void;
22
+ /**
23
+ * Parse first Theora Ogg page. the initial identification header packet
24
+ * @param {IPageHeader} header
25
+ * @param {Buffer} pageData
26
+ */
27
+ protected parseFirstPage(header: Ogg.IPageHeader, pageData: Buffer): void;
28
+ }
@@ -1,44 +1,44 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TheoraParser = void 0;
4
- const initDebug = require("debug");
5
- const Theora_1 = require("./Theora");
6
- const debug = initDebug('music-metadata:parser:ogg:theora');
7
- /**
8
- * Ref:
9
- * https://theora.org/doc/Theora.pdf
10
- */
11
- class TheoraParser {
12
- constructor(metadata, options, tokenizer) {
13
- this.metadata = metadata;
14
- this.tokenizer = tokenizer;
15
- }
16
- /**
17
- * Vorbis 1 parser
18
- * @param header Ogg Page Header
19
- * @param pageData Page data
20
- */
21
- parsePage(header, pageData) {
22
- if (header.headerType.firstPage) {
23
- this.parseFirstPage(header, pageData);
24
- }
25
- }
26
- flush() {
27
- debug('flush');
28
- }
29
- calculateDuration(header) {
30
- debug('duration calculation not implemented');
31
- }
32
- /**
33
- * Parse first Theora Ogg page. the initial identification header packet
34
- * @param {IPageHeader} header
35
- * @param {Buffer} pageData
36
- */
37
- parseFirstPage(header, pageData) {
38
- debug('First Ogg/Theora page');
39
- this.metadata.setFormat('codec', 'Theora');
40
- const idHeader = Theora_1.IdentificationHeader.get(pageData, 0);
41
- this.metadata.setFormat('bitrate', idHeader.nombr);
42
- }
43
- }
44
- exports.TheoraParser = TheoraParser;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TheoraParser = void 0;
4
+ const initDebug = require("debug");
5
+ const Theora_1 = require("./Theora");
6
+ const debug = initDebug('music-metadata:parser:ogg:theora');
7
+ /**
8
+ * Ref:
9
+ * https://theora.org/doc/Theora.pdf
10
+ */
11
+ class TheoraParser {
12
+ constructor(metadata, options, tokenizer) {
13
+ this.metadata = metadata;
14
+ this.tokenizer = tokenizer;
15
+ }
16
+ /**
17
+ * Vorbis 1 parser
18
+ * @param header Ogg Page Header
19
+ * @param pageData Page data
20
+ */
21
+ parsePage(header, pageData) {
22
+ if (header.headerType.firstPage) {
23
+ this.parseFirstPage(header, pageData);
24
+ }
25
+ }
26
+ flush() {
27
+ debug('flush');
28
+ }
29
+ calculateDuration(header) {
30
+ debug('duration calculation not implemented');
31
+ }
32
+ /**
33
+ * Parse first Theora Ogg page. the initial identification header packet
34
+ * @param {IPageHeader} header
35
+ * @param {Buffer} pageData
36
+ */
37
+ parseFirstPage(header, pageData) {
38
+ debug('First Ogg/Theora page');
39
+ this.metadata.setFormat('codec', 'Theora');
40
+ const idHeader = Theora_1.IdentificationHeader.get(pageData, 0);
41
+ this.metadata.setFormat('bitrate', idHeader.nombr);
42
+ }
43
+ }
44
+ exports.TheoraParser = TheoraParser;
@@ -1,79 +1,79 @@
1
- /// <reference types="node" />
2
- import { IPicture } from '../../type';
3
- import { IGetToken } from 'strtok3/lib/core';
4
- export interface IVorbisPicture extends IPicture {
5
- type: string;
6
- description: string;
7
- width: number;
8
- height: number;
9
- colour_depth: number;
10
- indexed_color: number;
11
- }
12
- /**
13
- * Interface to parsed result of METADATA_BLOCK_PICTURE
14
- * Ref: https://wiki.xiph.org/VorbisComment#METADATA_BLOCK_PICTURE
15
- * Ref: https://xiph.org/flac/format.html#metadata_block_picture
16
- */
17
- export interface IVorbisPicture {
18
- type: string;
19
- format: string;
20
- description: string;
21
- width: number;
22
- height: number;
23
- colour_depth: number;
24
- indexed_color: number;
25
- data: Buffer;
26
- }
27
- /**
28
- * Parse the METADATA_BLOCK_PICTURE
29
- * Ref: https://wiki.xiph.org/VorbisComment#METADATA_BLOCK_PICTURE
30
- * Ref: https://xiph.org/flac/format.html#metadata_block_picture
31
- * // ToDo: move to ID3 / APIC?
32
- */
33
- export declare class VorbisPictureToken implements IGetToken<IVorbisPicture> {
34
- len: any;
35
- static fromBase64(base64str: string): IVorbisPicture;
36
- static fromBuffer(buffer: Buffer): IVorbisPicture;
37
- constructor(len: any);
38
- get(buffer: Buffer, offset: number): IVorbisPicture;
39
- }
40
- /**
41
- * Vorbis 1 decoding tokens
42
- * Ref: https://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-620004.2.1
43
- */
44
- /**
45
- * Comment header interface
46
- * Ref: https://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-620004.2.1
47
- */
48
- export interface ICommonHeader {
49
- /**
50
- * Packet Type
51
- */
52
- packetType: number;
53
- /**
54
- * Should be 'vorbis'
55
- */
56
- vorbis: string;
57
- }
58
- /**
59
- * Comment header decoder
60
- * Ref: https://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-620004.2.1
61
- */
62
- export declare const CommonHeader: IGetToken<ICommonHeader>;
63
- /**
64
- * Identification header interface
65
- * Ref: https://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-630004.2.2
66
- */
67
- export interface IFormatInfo {
68
- version: number;
69
- channelMode: number;
70
- sampleRate: number;
71
- bitrateMax: number;
72
- bitrateNominal: number;
73
- bitrateMin: number;
74
- }
75
- /**
76
- * Identification header decoder
77
- * Ref: https://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-630004.2.2
78
- */
79
- export declare const IdentificationHeader: IGetToken<IFormatInfo>;
1
+ /// <reference types="node" />
2
+ import { IGetToken } from 'strtok3/lib/core';
3
+ import { IPicture } from '../../type';
4
+ export interface IVorbisPicture extends IPicture {
5
+ type: string;
6
+ description: string;
7
+ width: number;
8
+ height: number;
9
+ colour_depth: number;
10
+ indexed_color: number;
11
+ }
12
+ /**
13
+ * Interface to parsed result of METADATA_BLOCK_PICTURE
14
+ * Ref: https://wiki.xiph.org/VorbisComment#METADATA_BLOCK_PICTURE
15
+ * Ref: https://xiph.org/flac/format.html#metadata_block_picture
16
+ */
17
+ export interface IVorbisPicture {
18
+ type: string;
19
+ format: string;
20
+ description: string;
21
+ width: number;
22
+ height: number;
23
+ colour_depth: number;
24
+ indexed_color: number;
25
+ data: Buffer;
26
+ }
27
+ /**
28
+ * Parse the METADATA_BLOCK_PICTURE
29
+ * Ref: https://wiki.xiph.org/VorbisComment#METADATA_BLOCK_PICTURE
30
+ * Ref: https://xiph.org/flac/format.html#metadata_block_picture
31
+ * // ToDo: move to ID3 / APIC?
32
+ */
33
+ export declare class VorbisPictureToken implements IGetToken<IVorbisPicture> {
34
+ len: any;
35
+ static fromBase64(base64str: string): IVorbisPicture;
36
+ static fromBuffer(buffer: Buffer): IVorbisPicture;
37
+ constructor(len: any);
38
+ get(buffer: Buffer, offset: number): IVorbisPicture;
39
+ }
40
+ /**
41
+ * Vorbis 1 decoding tokens
42
+ * Ref: https://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-620004.2.1
43
+ */
44
+ /**
45
+ * Comment header interface
46
+ * Ref: https://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-620004.2.1
47
+ */
48
+ export interface ICommonHeader {
49
+ /**
50
+ * Packet Type
51
+ */
52
+ packetType: number;
53
+ /**
54
+ * Should be 'vorbis'
55
+ */
56
+ vorbis: string;
57
+ }
58
+ /**
59
+ * Comment header decoder
60
+ * Ref: https://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-620004.2.1
61
+ */
62
+ export declare const CommonHeader: IGetToken<ICommonHeader>;
63
+ /**
64
+ * Identification header interface
65
+ * Ref: https://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-630004.2.2
66
+ */
67
+ export interface IFormatInfo {
68
+ version: number;
69
+ channelMode: number;
70
+ sampleRate: number;
71
+ bitrateMax: number;
72
+ bitrateNominal: number;
73
+ bitrateMin: number;
74
+ }
75
+ /**
76
+ * Identification header decoder
77
+ * Ref: https://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-630004.2.2
78
+ */
79
+ export declare const IdentificationHeader: IGetToken<IFormatInfo>;
@@ -1,78 +1,78 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IdentificationHeader = exports.CommonHeader = exports.VorbisPictureToken = void 0;
4
- const Token = require("token-types");
5
- const ID3v2Token_1 = require("../../id3v2/ID3v2Token");
6
- /**
7
- * Parse the METADATA_BLOCK_PICTURE
8
- * Ref: https://wiki.xiph.org/VorbisComment#METADATA_BLOCK_PICTURE
9
- * Ref: https://xiph.org/flac/format.html#metadata_block_picture
10
- * // ToDo: move to ID3 / APIC?
11
- */
12
- class VorbisPictureToken {
13
- constructor(len) {
14
- this.len = len;
15
- }
16
- static fromBase64(base64str) {
17
- return this.fromBuffer(Buffer.from(base64str, 'base64'));
18
- }
19
- static fromBuffer(buffer) {
20
- const pic = new VorbisPictureToken(buffer.length);
21
- return pic.get(buffer, 0);
22
- }
23
- get(buffer, offset) {
24
- const type = ID3v2Token_1.AttachedPictureType[Token.UINT32_BE.get(buffer, offset)];
25
- const mimeLen = Token.UINT32_BE.get(buffer, offset += 4);
26
- const format = buffer.toString('utf-8', offset += 4, offset + mimeLen);
27
- const descLen = Token.UINT32_BE.get(buffer, offset += mimeLen);
28
- const description = buffer.toString('utf-8', offset += 4, offset + descLen);
29
- const width = Token.UINT32_BE.get(buffer, offset += descLen);
30
- const height = Token.UINT32_BE.get(buffer, offset += 4);
31
- const colour_depth = Token.UINT32_BE.get(buffer, offset += 4);
32
- const indexed_color = Token.UINT32_BE.get(buffer, offset += 4);
33
- const picDataLen = Token.UINT32_BE.get(buffer, offset += 4);
34
- const data = Buffer.from(buffer.slice(offset += 4, offset + picDataLen));
35
- return {
36
- type,
37
- format,
38
- description,
39
- width,
40
- height,
41
- colour_depth,
42
- indexed_color,
43
- data
44
- };
45
- }
46
- }
47
- exports.VorbisPictureToken = VorbisPictureToken;
48
- /**
49
- * Comment header decoder
50
- * Ref: https://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-620004.2.1
51
- */
52
- exports.CommonHeader = {
53
- len: 7,
54
- get: (buf, off) => {
55
- return {
56
- packetType: buf.readUInt8(off),
57
- vorbis: new Token.StringType(6, 'ascii').get(buf, off + 1)
58
- };
59
- }
60
- };
61
- /**
62
- * Identification header decoder
63
- * Ref: https://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-630004.2.2
64
- */
65
- exports.IdentificationHeader = {
66
- len: 23,
67
- get: (uint8Array, off) => {
68
- const dataView = new DataView(uint8Array.buffer, uint8Array.byteOffset);
69
- return {
70
- version: dataView.getUint32(off + 0, true),
71
- channelMode: dataView.getUint8(off + 4),
72
- sampleRate: dataView.getUint32(off + 5, true),
73
- bitrateMax: dataView.getUint32(off + 9, true),
74
- bitrateNominal: dataView.getUint32(off + 13, true),
75
- bitrateMin: dataView.getUint32(off + 17, true)
76
- };
77
- }
78
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IdentificationHeader = exports.CommonHeader = exports.VorbisPictureToken = void 0;
4
+ const Token = require("token-types");
5
+ const ID3v2Token_1 = require("../../id3v2/ID3v2Token");
6
+ /**
7
+ * Parse the METADATA_BLOCK_PICTURE
8
+ * Ref: https://wiki.xiph.org/VorbisComment#METADATA_BLOCK_PICTURE
9
+ * Ref: https://xiph.org/flac/format.html#metadata_block_picture
10
+ * // ToDo: move to ID3 / APIC?
11
+ */
12
+ class VorbisPictureToken {
13
+ constructor(len) {
14
+ this.len = len;
15
+ }
16
+ static fromBase64(base64str) {
17
+ return this.fromBuffer(Buffer.from(base64str, 'base64'));
18
+ }
19
+ static fromBuffer(buffer) {
20
+ const pic = new VorbisPictureToken(buffer.length);
21
+ return pic.get(buffer, 0);
22
+ }
23
+ get(buffer, offset) {
24
+ const type = ID3v2Token_1.AttachedPictureType[Token.UINT32_BE.get(buffer, offset)];
25
+ const mimeLen = Token.UINT32_BE.get(buffer, offset += 4);
26
+ const format = buffer.toString('utf-8', offset += 4, offset + mimeLen);
27
+ const descLen = Token.UINT32_BE.get(buffer, offset += mimeLen);
28
+ const description = buffer.toString('utf-8', offset += 4, offset + descLen);
29
+ const width = Token.UINT32_BE.get(buffer, offset += descLen);
30
+ const height = Token.UINT32_BE.get(buffer, offset += 4);
31
+ const colour_depth = Token.UINT32_BE.get(buffer, offset += 4);
32
+ const indexed_color = Token.UINT32_BE.get(buffer, offset += 4);
33
+ const picDataLen = Token.UINT32_BE.get(buffer, offset += 4);
34
+ const data = Buffer.from(buffer.slice(offset += 4, offset + picDataLen));
35
+ return {
36
+ type,
37
+ format,
38
+ description,
39
+ width,
40
+ height,
41
+ colour_depth,
42
+ indexed_color,
43
+ data
44
+ };
45
+ }
46
+ }
47
+ exports.VorbisPictureToken = VorbisPictureToken;
48
+ /**
49
+ * Comment header decoder
50
+ * Ref: https://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-620004.2.1
51
+ */
52
+ exports.CommonHeader = {
53
+ len: 7,
54
+ get: (buf, off) => {
55
+ return {
56
+ packetType: buf.readUInt8(off),
57
+ vorbis: new Token.StringType(6, 'ascii').get(buf, off + 1)
58
+ };
59
+ }
60
+ };
61
+ /**
62
+ * Identification header decoder
63
+ * Ref: https://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-630004.2.2
64
+ */
65
+ exports.IdentificationHeader = {
66
+ len: 23,
67
+ get: (uint8Array, off) => {
68
+ const dataView = new DataView(uint8Array.buffer, uint8Array.byteOffset);
69
+ return {
70
+ version: dataView.getUint32(off + 0, true),
71
+ channelMode: dataView.getUint8(off + 4),
72
+ sampleRate: dataView.getUint32(off + 5, true),
73
+ bitrateMax: dataView.getUint32(off + 9, true),
74
+ bitrateNominal: dataView.getUint32(off + 13, true),
75
+ bitrateMin: dataView.getUint32(off + 17, true)
76
+ };
77
+ }
78
+ };
@@ -1,12 +1,12 @@
1
- export declare class VorbisDecoder {
2
- private readonly data;
3
- private offset;
4
- constructor(data: Uint8Array, offset: any);
5
- readInt32(): number;
6
- readStringUtf8(): string;
7
- parseUserComment(): {
8
- key: string;
9
- value: string;
10
- len: number;
11
- };
12
- }
1
+ export declare class VorbisDecoder {
2
+ private readonly data;
3
+ private offset;
4
+ constructor(data: Uint8Array, offset: any);
5
+ readInt32(): number;
6
+ readStringUtf8(): string;
7
+ parseUserComment(): {
8
+ key: string;
9
+ value: string;
10
+ len: number;
11
+ };
12
+ }
@@ -1,32 +1,32 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VorbisDecoder = void 0;
4
- const Token = require("token-types");
5
- class VorbisDecoder {
6
- constructor(data, offset) {
7
- this.data = data;
8
- this.offset = offset;
9
- }
10
- readInt32() {
11
- const value = Token.UINT32_LE.get(this.data, this.offset);
12
- this.offset += 4;
13
- return value;
14
- }
15
- readStringUtf8() {
16
- const len = this.readInt32();
17
- const value = Buffer.from(this.data).toString('utf-8', this.offset, this.offset + len);
18
- this.offset += len;
19
- return value;
20
- }
21
- parseUserComment() {
22
- const offset0 = this.offset;
23
- const v = this.readStringUtf8();
24
- const idx = v.indexOf('=');
25
- return {
26
- key: v.slice(0, idx).toUpperCase(),
27
- value: v.slice(idx + 1),
28
- len: this.offset - offset0
29
- };
30
- }
31
- }
32
- exports.VorbisDecoder = VorbisDecoder;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VorbisDecoder = void 0;
4
+ const Token = require("token-types");
5
+ class VorbisDecoder {
6
+ constructor(data, offset) {
7
+ this.data = data;
8
+ this.offset = offset;
9
+ }
10
+ readInt32() {
11
+ const value = Token.UINT32_LE.get(this.data, this.offset);
12
+ this.offset += 4;
13
+ return value;
14
+ }
15
+ readStringUtf8() {
16
+ const len = this.readInt32();
17
+ const value = Buffer.from(this.data).toString('utf-8', this.offset, this.offset + len);
18
+ this.offset += len;
19
+ return value;
20
+ }
21
+ parseUserComment() {
22
+ const offset0 = this.offset;
23
+ const v = this.readStringUtf8();
24
+ const idx = v.indexOf('=');
25
+ return {
26
+ key: v.slice(0, idx).toUpperCase(),
27
+ value: v.slice(idx + 1),
28
+ len: this.offset - offset0
29
+ };
30
+ }
31
+ }
32
+ exports.VorbisDecoder = VorbisDecoder;
@@ -1,36 +1,36 @@
1
- /// <reference types="node" />
2
- import { IOptions } from '../../type';
3
- import { INativeMetadataCollector } from '../../common/MetadataCollector';
4
- import * as Ogg from '../Ogg';
5
- import { IVorbisPicture } from './Vorbis';
6
- /**
7
- * Vorbis 1 Parser.
8
- * Used by OggParser
9
- */
10
- export declare class VorbisParser implements Ogg.IPageConsumer {
11
- protected metadata: INativeMetadataCollector;
12
- protected options: IOptions;
13
- private pageSegments;
14
- constructor(metadata: INativeMetadataCollector, options: IOptions);
15
- /**
16
- * Vorbis 1 parser
17
- * @param header Ogg Page Header
18
- * @param pageData Page data
19
- */
20
- parsePage(header: Ogg.IPageHeader, pageData: Buffer): void;
21
- flush(): void;
22
- parseUserComment(pageData: Buffer, offset: number): number;
23
- addTag(id: string, value: string | IVorbisPicture): void;
24
- calculateDuration(header: Ogg.IPageHeader): void;
25
- /**
26
- * Parse first Ogg/Vorbis page
27
- * @param {IPageHeader} header
28
- * @param {Buffer} pageData
29
- */
30
- protected parseFirstPage(header: Ogg.IPageHeader, pageData: Buffer): void;
31
- protected parseFullPage(pageData: Buffer): void;
32
- /**
33
- * Ref: https://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-840005.2
34
- */
35
- protected parseUserCommentList(pageData: Buffer, offset: number): void;
36
- }
1
+ /// <reference types="node" />
2
+ import { IOptions } from '../../type';
3
+ import { INativeMetadataCollector } from '../../common/MetadataCollector';
4
+ import * as Ogg from '../Ogg';
5
+ import { IVorbisPicture } from './Vorbis';
6
+ /**
7
+ * Vorbis 1 Parser.
8
+ * Used by OggParser
9
+ */
10
+ export declare class VorbisParser implements Ogg.IPageConsumer {
11
+ protected metadata: INativeMetadataCollector;
12
+ protected options: IOptions;
13
+ private pageSegments;
14
+ constructor(metadata: INativeMetadataCollector, options: IOptions);
15
+ /**
16
+ * Vorbis 1 parser
17
+ * @param header Ogg Page Header
18
+ * @param pageData Page data
19
+ */
20
+ parsePage(header: Ogg.IPageHeader, pageData: Buffer): void;
21
+ flush(): void;
22
+ parseUserComment(pageData: Buffer, offset: number): number;
23
+ addTag(id: string, value: string | IVorbisPicture): void;
24
+ calculateDuration(header: Ogg.IPageHeader): void;
25
+ /**
26
+ * Parse first Ogg/Vorbis page
27
+ * @param {IPageHeader} header
28
+ * @param {Buffer} pageData
29
+ */
30
+ protected parseFirstPage(header: Ogg.IPageHeader, pageData: Buffer): void;
31
+ protected parseFullPage(pageData: Buffer): void;
32
+ /**
33
+ * Ref: https://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-840005.2
34
+ */
35
+ protected parseUserCommentList(pageData: Buffer, offset: number): void;
36
+ }