nodejs-audio-visualizer 5.5.3 → 5.6.3

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 (49) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +84 -83
  3. package/dist/audio.d.ts +13 -13
  4. package/dist/audio.js +128 -128
  5. package/dist/beats.d.ts +39 -39
  6. package/dist/beats.js +220 -220
  7. package/dist/bpmEncoder.d.ts +14 -14
  8. package/dist/bpmEncoder.js +97 -97
  9. package/dist/config.d.ts +81 -80
  10. package/dist/config.js +392 -391
  11. package/dist/config.js.map +1 -1
  12. package/dist/dsp.d.ts +16 -16
  13. package/dist/dsp.js +76 -76
  14. package/dist/highlight.d.ts +91 -91
  15. package/dist/highlight.js +606 -606
  16. package/dist/image.d.ts +107 -97
  17. package/dist/image.js +614 -545
  18. package/dist/image.js.map +1 -1
  19. package/dist/index.d.ts +98 -96
  20. package/dist/index.js +673 -667
  21. package/dist/index.js.map +1 -1
  22. package/dist/subtitleConvert.d.ts +3 -3
  23. package/dist/subtitleConvert.js +61 -61
  24. package/dist/video.d.ts +171 -171
  25. package/dist/video.js +743 -743
  26. package/dist/waitForEventLoop.d.ts +1 -1
  27. package/dist/waitForEventLoop.js +5 -5
  28. package/package.json +62 -62
  29. package/src/audio.ts +129 -129
  30. package/src/beats.ts +279 -279
  31. package/src/bpmEncoder.ts +97 -97
  32. package/src/config.ts +504 -501
  33. package/src/dsp.ts +95 -95
  34. package/src/highlight.ts +617 -617
  35. package/src/image.ts +791 -707
  36. package/src/index.ts +896 -885
  37. package/src/subtitleConvert.ts +63 -63
  38. package/src/tests/audio.test.ts +102 -102
  39. package/src/tests/beats.test.ts +134 -134
  40. package/src/tests/config.test.ts +568 -553
  41. package/src/tests/dsp.test.ts +24 -24
  42. package/src/tests/highlight.test.ts +397 -397
  43. package/src/tests/image.test.ts +371 -319
  44. package/src/tests/index.test.ts +180 -180
  45. package/src/tests/subtitleConvert.test.ts +23 -23
  46. package/src/tests/video.test.ts +652 -652
  47. package/src/typings.d.ts +28 -28
  48. package/src/video.ts +947 -947
  49. package/src/waitForEventLoop.ts +2 -2
package/src/bpmEncoder.ts CHANGED
@@ -1,97 +1,97 @@
1
- export interface EncodedBmp {
2
- shiftPos: number;
3
- rowBytes: number;
4
- data: Buffer;
5
- }
6
-
7
- const writeBmpHeader = (buffer: Buffer, width: number, height: number, rgbSize: number) => {
8
- const headerInfoSize = 40;
9
- const offset = 54;
10
- const fileSize = rgbSize + offset;
11
-
12
- let pos = 0;
13
- buffer.write('BM', pos, 2); pos += 2;
14
- buffer.writeUInt32LE(fileSize, pos); pos += 4;
15
- buffer.writeUInt32LE(0, pos); pos += 4;
16
- buffer.writeUInt32LE(offset, pos); pos += 4;
17
-
18
- buffer.writeUInt32LE(headerInfoSize, pos); pos += 4;
19
- buffer.writeUInt32LE(width, pos); pos += 4;
20
- buffer.writeInt32LE(-height, pos); pos += 4;
21
- buffer.writeUInt16LE(1, pos); pos += 2;
22
- buffer.writeUInt16LE(24, pos); pos += 2;
23
- buffer.writeUInt32LE(0, pos); pos += 4;
24
- buffer.writeUInt32LE(rgbSize, pos); pos += 4;
25
- buffer.writeUInt32LE(0, pos); pos += 4;
26
- buffer.writeUInt32LE(0, pos); pos += 4;
27
- buffer.writeUInt32LE(0, pos); pos += 4;
28
- buffer.writeUInt32LE(0, pos); pos += 4;
29
-
30
- return offset;
31
- };
32
-
33
- export const createBpmEncoder = (imgData: { width: number; height: number; }) => {
34
- const width = imgData.width;
35
- const height = imgData.height;
36
- const extraBytes = width % 4;
37
- const rgbSize = height * (3 * width + extraBytes);
38
- const offset = 54;
39
-
40
- return (buffer: Buffer): EncodedBmp => {
41
- const tempBuffer = Buffer.alloc(offset + rgbSize);
42
- const pos = writeBmpHeader(tempBuffer, width, height, rgbSize);
43
-
44
- let i = 0;
45
- const rowBytes = 3 * width + extraBytes;
46
-
47
- for (let y = 0; y < height; y++) {
48
- for (let x = 0; x < width; x++) {
49
- const p = pos + y * rowBytes + x * 3;
50
- i++; // a
51
- tempBuffer[p] = buffer[i++]; // b
52
- tempBuffer[p + 1] = buffer[i++]; // g
53
- tempBuffer[p + 2] = buffer[i++]; // r
54
- }
55
- if (extraBytes > 0) {
56
- const fillOffset = pos + y * rowBytes + width * 3;
57
- tempBuffer.fill(0, fillOffset, fillOffset + extraBytes);
58
- }
59
- }
60
-
61
- return {
62
- shiftPos: pos,
63
- rowBytes,
64
- data: tempBuffer
65
- };
66
- };
67
- };
68
-
69
- export const createBgrFrameEncoder = (imgData: { width: number; height: number }) => {
70
- const width = imgData.width;
71
- const height = imgData.height;
72
- const extraBytes = width % 4;
73
- const rowBytes = 3 * width + extraBytes;
74
- const rgbSize = height * rowBytes;
75
- const offset = 54;
76
-
77
- const tempBuffer = Buffer.alloc(offset + rgbSize);
78
- const pos = writeBmpHeader(tempBuffer, width, height, rgbSize);
79
-
80
- return (bgrBuffer: Buffer): EncodedBmp => {
81
- if (extraBytes === 0) {
82
- bgrBuffer.copy(tempBuffer, pos, 0, width * height * 3);
83
- } else {
84
- for (let y = 0; y < height; y++) {
85
- const srcOffset = y * width * 3;
86
- const dstOffset = pos + y * rowBytes;
87
- bgrBuffer.copy(tempBuffer, dstOffset, srcOffset, srcOffset + width * 3);
88
- }
89
- }
90
-
91
- return {
92
- shiftPos: pos,
93
- rowBytes,
94
- data: tempBuffer
95
- };
96
- };
97
- };
1
+ export interface EncodedBmp {
2
+ shiftPos: number;
3
+ rowBytes: number;
4
+ data: Buffer;
5
+ }
6
+
7
+ const writeBmpHeader = (buffer: Buffer, width: number, height: number, rgbSize: number) => {
8
+ const headerInfoSize = 40;
9
+ const offset = 54;
10
+ const fileSize = rgbSize + offset;
11
+
12
+ let pos = 0;
13
+ buffer.write('BM', pos, 2); pos += 2;
14
+ buffer.writeUInt32LE(fileSize, pos); pos += 4;
15
+ buffer.writeUInt32LE(0, pos); pos += 4;
16
+ buffer.writeUInt32LE(offset, pos); pos += 4;
17
+
18
+ buffer.writeUInt32LE(headerInfoSize, pos); pos += 4;
19
+ buffer.writeUInt32LE(width, pos); pos += 4;
20
+ buffer.writeInt32LE(-height, pos); pos += 4;
21
+ buffer.writeUInt16LE(1, pos); pos += 2;
22
+ buffer.writeUInt16LE(24, pos); pos += 2;
23
+ buffer.writeUInt32LE(0, pos); pos += 4;
24
+ buffer.writeUInt32LE(rgbSize, pos); pos += 4;
25
+ buffer.writeUInt32LE(0, pos); pos += 4;
26
+ buffer.writeUInt32LE(0, pos); pos += 4;
27
+ buffer.writeUInt32LE(0, pos); pos += 4;
28
+ buffer.writeUInt32LE(0, pos); pos += 4;
29
+
30
+ return offset;
31
+ };
32
+
33
+ export const createBpmEncoder = (imgData: { width: number; height: number; }) => {
34
+ const width = imgData.width;
35
+ const height = imgData.height;
36
+ const extraBytes = width % 4;
37
+ const rgbSize = height * (3 * width + extraBytes);
38
+ const offset = 54;
39
+
40
+ return (buffer: Buffer): EncodedBmp => {
41
+ const tempBuffer = Buffer.alloc(offset + rgbSize);
42
+ const pos = writeBmpHeader(tempBuffer, width, height, rgbSize);
43
+
44
+ let i = 0;
45
+ const rowBytes = 3 * width + extraBytes;
46
+
47
+ for (let y = 0; y < height; y++) {
48
+ for (let x = 0; x < width; x++) {
49
+ const p = pos + y * rowBytes + x * 3;
50
+ i++; // a
51
+ tempBuffer[p] = buffer[i++]; // b
52
+ tempBuffer[p + 1] = buffer[i++]; // g
53
+ tempBuffer[p + 2] = buffer[i++]; // r
54
+ }
55
+ if (extraBytes > 0) {
56
+ const fillOffset = pos + y * rowBytes + width * 3;
57
+ tempBuffer.fill(0, fillOffset, fillOffset + extraBytes);
58
+ }
59
+ }
60
+
61
+ return {
62
+ shiftPos: pos,
63
+ rowBytes,
64
+ data: tempBuffer
65
+ };
66
+ };
67
+ };
68
+
69
+ export const createBgrFrameEncoder = (imgData: { width: number; height: number }) => {
70
+ const width = imgData.width;
71
+ const height = imgData.height;
72
+ const extraBytes = width % 4;
73
+ const rowBytes = 3 * width + extraBytes;
74
+ const rgbSize = height * rowBytes;
75
+ const offset = 54;
76
+
77
+ const tempBuffer = Buffer.alloc(offset + rgbSize);
78
+ const pos = writeBmpHeader(tempBuffer, width, height, rgbSize);
79
+
80
+ return (bgrBuffer: Buffer): EncodedBmp => {
81
+ if (extraBytes === 0) {
82
+ bgrBuffer.copy(tempBuffer, pos, 0, width * height * 3);
83
+ } else {
84
+ for (let y = 0; y < height; y++) {
85
+ const srcOffset = y * width * 3;
86
+ const dstOffset = pos + y * rowBytes;
87
+ bgrBuffer.copy(tempBuffer, dstOffset, srcOffset, srcOffset + width * 3);
88
+ }
89
+ }
90
+
91
+ return {
92
+ shiftPos: pos,
93
+ rowBytes,
94
+ data: tempBuffer
95
+ };
96
+ };
97
+ };