nodejs-audio-visualizer 5.5.2 → 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 (48) 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 -44
  6. package/dist/beats.js +220 -313
  7. package/dist/beats.js.map +1 -1
  8. package/dist/bpmEncoder.d.ts +14 -14
  9. package/dist/bpmEncoder.js +97 -97
  10. package/dist/config.d.ts +81 -80
  11. package/dist/config.js +392 -391
  12. package/dist/config.js.map +1 -1
  13. package/dist/dsp.d.ts +16 -16
  14. package/dist/dsp.js +76 -76
  15. package/dist/highlight.d.ts +91 -91
  16. package/dist/highlight.js +606 -606
  17. package/dist/image.d.ts +107 -97
  18. package/dist/image.js +614 -545
  19. package/dist/image.js.map +1 -1
  20. package/dist/index.d.ts +98 -96
  21. package/dist/index.js +673 -667
  22. package/dist/index.js.map +1 -1
  23. package/dist/subtitleConvert.d.ts +3 -3
  24. package/dist/subtitleConvert.js +61 -61
  25. package/dist/video.d.ts +171 -171
  26. package/dist/video.js +743 -743
  27. package/dist/waitForEventLoop.d.ts +1 -1
  28. package/dist/waitForEventLoop.js +5 -5
  29. package/package.json +62 -61
  30. package/src/audio.ts +129 -129
  31. package/src/beats.ts +279 -396
  32. package/src/bpmEncoder.ts +97 -97
  33. package/src/config.ts +504 -501
  34. package/src/dsp.ts +95 -95
  35. package/src/highlight.ts +617 -617
  36. package/src/image.ts +791 -707
  37. package/src/index.ts +896 -885
  38. package/src/subtitleConvert.ts +63 -63
  39. package/src/tests/audio.test.ts +102 -102
  40. package/src/tests/beats.test.ts +134 -134
  41. package/src/tests/config.test.ts +568 -553
  42. package/src/tests/dsp.test.ts +24 -24
  43. package/src/tests/highlight.test.ts +397 -397
  44. package/src/tests/image.test.ts +371 -319
  45. package/src/tests/index.test.ts +180 -180
  46. package/src/tests/subtitleConvert.test.ts +23 -23
  47. package/src/typings.d.ts +28 -6
  48. package/src/waitForEventLoop.ts +2 -2
@@ -1,98 +1,98 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var writeBmpHeader = function (buffer, width, height, rgbSize) {
4
- var headerInfoSize = 40;
5
- var offset = 54;
6
- var fileSize = rgbSize + offset;
7
- var pos = 0;
8
- buffer.write('BM', pos, 2);
9
- pos += 2;
10
- buffer.writeUInt32LE(fileSize, pos);
11
- pos += 4;
12
- buffer.writeUInt32LE(0, pos);
13
- pos += 4;
14
- buffer.writeUInt32LE(offset, pos);
15
- pos += 4;
16
- buffer.writeUInt32LE(headerInfoSize, pos);
17
- pos += 4;
18
- buffer.writeUInt32LE(width, pos);
19
- pos += 4;
20
- buffer.writeInt32LE(-height, pos);
21
- pos += 4;
22
- buffer.writeUInt16LE(1, pos);
23
- pos += 2;
24
- buffer.writeUInt16LE(24, pos);
25
- pos += 2;
26
- buffer.writeUInt32LE(0, pos);
27
- pos += 4;
28
- buffer.writeUInt32LE(rgbSize, pos);
29
- pos += 4;
30
- buffer.writeUInt32LE(0, pos);
31
- pos += 4;
32
- buffer.writeUInt32LE(0, pos);
33
- pos += 4;
34
- buffer.writeUInt32LE(0, pos);
35
- pos += 4;
36
- buffer.writeUInt32LE(0, pos);
37
- pos += 4;
38
- return offset;
39
- };
40
- exports.createBpmEncoder = function (imgData) {
41
- var width = imgData.width;
42
- var height = imgData.height;
43
- var extraBytes = width % 4;
44
- var rgbSize = height * (3 * width + extraBytes);
45
- var offset = 54;
46
- return function (buffer) {
47
- var tempBuffer = Buffer.alloc(offset + rgbSize);
48
- var pos = writeBmpHeader(tempBuffer, width, height, rgbSize);
49
- var i = 0;
50
- var rowBytes = 3 * width + extraBytes;
51
- for (var y = 0; y < height; y++) {
52
- for (var x = 0; x < width; x++) {
53
- var p = pos + y * rowBytes + x * 3;
54
- i++; // a
55
- tempBuffer[p] = buffer[i++]; // b
56
- tempBuffer[p + 1] = buffer[i++]; // g
57
- tempBuffer[p + 2] = buffer[i++]; // r
58
- }
59
- if (extraBytes > 0) {
60
- var fillOffset = pos + y * rowBytes + width * 3;
61
- tempBuffer.fill(0, fillOffset, fillOffset + extraBytes);
62
- }
63
- }
64
- return {
65
- shiftPos: pos,
66
- rowBytes: rowBytes,
67
- data: tempBuffer
68
- };
69
- };
70
- };
71
- exports.createBgrFrameEncoder = function (imgData) {
72
- var width = imgData.width;
73
- var height = imgData.height;
74
- var extraBytes = width % 4;
75
- var rowBytes = 3 * width + extraBytes;
76
- var rgbSize = height * rowBytes;
77
- var offset = 54;
78
- var tempBuffer = Buffer.alloc(offset + rgbSize);
79
- var pos = writeBmpHeader(tempBuffer, width, height, rgbSize);
80
- return function (bgrBuffer) {
81
- if (extraBytes === 0) {
82
- bgrBuffer.copy(tempBuffer, pos, 0, width * height * 3);
83
- }
84
- else {
85
- for (var y = 0; y < height; y++) {
86
- var srcOffset = y * width * 3;
87
- var dstOffset = pos + y * rowBytes;
88
- bgrBuffer.copy(tempBuffer, dstOffset, srcOffset, srcOffset + width * 3);
89
- }
90
- }
91
- return {
92
- shiftPos: pos,
93
- rowBytes: rowBytes,
94
- data: tempBuffer
95
- };
96
- };
97
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var writeBmpHeader = function (buffer, width, height, rgbSize) {
4
+ var headerInfoSize = 40;
5
+ var offset = 54;
6
+ var fileSize = rgbSize + offset;
7
+ var pos = 0;
8
+ buffer.write('BM', pos, 2);
9
+ pos += 2;
10
+ buffer.writeUInt32LE(fileSize, pos);
11
+ pos += 4;
12
+ buffer.writeUInt32LE(0, pos);
13
+ pos += 4;
14
+ buffer.writeUInt32LE(offset, pos);
15
+ pos += 4;
16
+ buffer.writeUInt32LE(headerInfoSize, pos);
17
+ pos += 4;
18
+ buffer.writeUInt32LE(width, pos);
19
+ pos += 4;
20
+ buffer.writeInt32LE(-height, pos);
21
+ pos += 4;
22
+ buffer.writeUInt16LE(1, pos);
23
+ pos += 2;
24
+ buffer.writeUInt16LE(24, pos);
25
+ pos += 2;
26
+ buffer.writeUInt32LE(0, pos);
27
+ pos += 4;
28
+ buffer.writeUInt32LE(rgbSize, pos);
29
+ pos += 4;
30
+ buffer.writeUInt32LE(0, pos);
31
+ pos += 4;
32
+ buffer.writeUInt32LE(0, pos);
33
+ pos += 4;
34
+ buffer.writeUInt32LE(0, pos);
35
+ pos += 4;
36
+ buffer.writeUInt32LE(0, pos);
37
+ pos += 4;
38
+ return offset;
39
+ };
40
+ exports.createBpmEncoder = function (imgData) {
41
+ var width = imgData.width;
42
+ var height = imgData.height;
43
+ var extraBytes = width % 4;
44
+ var rgbSize = height * (3 * width + extraBytes);
45
+ var offset = 54;
46
+ return function (buffer) {
47
+ var tempBuffer = Buffer.alloc(offset + rgbSize);
48
+ var pos = writeBmpHeader(tempBuffer, width, height, rgbSize);
49
+ var i = 0;
50
+ var rowBytes = 3 * width + extraBytes;
51
+ for (var y = 0; y < height; y++) {
52
+ for (var x = 0; x < width; x++) {
53
+ var p = pos + y * rowBytes + x * 3;
54
+ i++; // a
55
+ tempBuffer[p] = buffer[i++]; // b
56
+ tempBuffer[p + 1] = buffer[i++]; // g
57
+ tempBuffer[p + 2] = buffer[i++]; // r
58
+ }
59
+ if (extraBytes > 0) {
60
+ var fillOffset = pos + y * rowBytes + width * 3;
61
+ tempBuffer.fill(0, fillOffset, fillOffset + extraBytes);
62
+ }
63
+ }
64
+ return {
65
+ shiftPos: pos,
66
+ rowBytes: rowBytes,
67
+ data: tempBuffer
68
+ };
69
+ };
70
+ };
71
+ exports.createBgrFrameEncoder = function (imgData) {
72
+ var width = imgData.width;
73
+ var height = imgData.height;
74
+ var extraBytes = width % 4;
75
+ var rowBytes = 3 * width + extraBytes;
76
+ var rgbSize = height * rowBytes;
77
+ var offset = 54;
78
+ var tempBuffer = Buffer.alloc(offset + rgbSize);
79
+ var pos = writeBmpHeader(tempBuffer, width, height, rgbSize);
80
+ return function (bgrBuffer) {
81
+ if (extraBytes === 0) {
82
+ bgrBuffer.copy(tempBuffer, pos, 0, width * height * 3);
83
+ }
84
+ else {
85
+ for (var y = 0; y < height; y++) {
86
+ var srcOffset = y * width * 3;
87
+ var dstOffset = pos + y * rowBytes;
88
+ bgrBuffer.copy(tempBuffer, dstOffset, srcOffset, srcOffset + width * 3);
89
+ }
90
+ }
91
+ return {
92
+ shiftPos: pos,
93
+ rowBytes: rowBytes,
94
+ data: tempBuffer
95
+ };
96
+ };
97
+ };
98
98
  //# sourceMappingURL=bpmEncoder.js.map
package/dist/config.d.ts CHANGED
@@ -1,80 +1,81 @@
1
- import { Config } from './index';
2
- export declare const defaults: {
3
- fps: number;
4
- spectrumWidth: string;
5
- spectrumHeight: number;
6
- spectrumX: string;
7
- spectrumY: string;
8
- spectrumRotation: string;
9
- spectrumBusMargin: number;
10
- spectrumOpacity: string;
11
- polarX: string;
12
- polarY: string;
13
- polarInnerRadius: number;
14
- polarMaxBarLength: number;
15
- polarBarWidth: number;
16
- timeouts: {
17
- readVideoFrame: number;
18
- waitDrain: number;
19
- waitForProcessExit: number;
20
- };
21
- };
22
- export declare type SpectrumEffect = 'volume' | 'smooth';
23
- export declare const rotationAliasValues: readonly ["up", "down", "mirror"];
24
- export declare const checkIsPercentValue: (value: string) => boolean;
25
- export declare const getAudioFilePath: (config: Config) => string;
26
- export declare const getAudioAutoHighlight: (config: Config) => boolean;
27
- export declare const getAudioAutoHighlightCount: (config: Config) => number;
28
- export declare const getBackgroundImagePath: (config: Config) => string | undefined;
29
- export declare const getBackgroundVideoPaths: (config: Config) => string[] | undefined;
30
- export declare const getHookVideoPath: (config: Config) => string | undefined;
31
- export declare const getAutoEditVideo: (config: Config) => boolean;
32
- export declare const getCameraShakeEnabled: (config: Config) => boolean;
33
- export declare const getOutVideoPath: (config: Config) => string;
34
- export declare type SubtitleAlignment = 'top' | 'middle' | 'bottom';
35
- export declare type SubtitleRenderSpec = {
36
- source: {
37
- kind: 'file';
38
- path: string;
39
- } | {
40
- kind: 'inline';
41
- text: string;
42
- };
43
- alignment: SubtitleAlignment;
44
- };
45
- export declare const subtitleAlignmentToAss: (alignment: "top" | "middle" | "bottom") => number;
46
- export declare const getSubtitleRenderSpec: (config: Config) => SubtitleRenderSpec | undefined;
47
- export declare const getFPS: (config: Config) => number;
48
- export declare const getOutputResolution: (config: Config) => {
49
- width: number;
50
- height: number;
51
- } | undefined;
52
- export declare const getEnhanceFilters: (config: Config) => boolean;
53
- export declare const getSpectrumBusMargin: () => number;
54
- export declare const getSpectrumEffect: (config: Config) => "smooth" | "volume" | undefined;
55
- export declare const getSpectrumWidthAbsolute: (config: Config, backgroundImageWidth: number) => number;
56
- export declare const getSpectrumHeightAbsolute: (config: Config, backgroundImageHeight: number) => number;
57
- export declare const getSpectrumXAbsolute: (config: Config, spectrumWidth: number, backgroundImageWidth: number) => number;
58
- export declare const getSpectrumYAbsolute: (config: Config, spectrumHeight: number, backgroundImageHeight: number) => number;
59
- export declare const checkIsValidRotationAlias: (aliasName: string) => boolean;
60
- export declare const getSpectrumRotation: (config: Config) => "up" | "down" | "mirror";
61
- export declare const getSpectrumColor: (config: Config) => string | import("./image").Color | undefined;
62
- export declare const getSpectrumOpacity: (config: Config) => string;
63
- export declare const getSpectrumOpacityParsed: (config: Config) => number;
64
- export declare const getFfmpeg_cfr: (config: Config) => string | undefined;
65
- export declare const getFfmpeg_preset: (config: Config) => string | undefined;
66
- export declare const getFrame_processing_delay: (config: Config) => number | undefined;
67
- export declare const getVideoTimeouts: (config: Config) => {
68
- readVideoFrame: number;
69
- waitDrain: number;
70
- waitForProcessExit: number;
71
- };
72
- export declare const getPolarXAbsolute: (config: Config, backgroundImageWidth: number) => number;
73
- export declare const getPolarYAbsolute: (config: Config, backgroundImageHeight: number) => number;
74
- export declare const getPolarInnerRadius: (config: Config) => number;
75
- export declare const getPolarMaxBarLength: (config: Config) => number;
76
- export declare const getPolarBarWidth: (config: Config) => number;
77
- export declare const getPolarEffect: (config: Config) => "smooth" | "volume" | undefined;
78
- export declare const getPolarColor: (config: Config) => string | import("./image").Color | undefined;
79
- export declare const getPolarOpacity: (config: Config) => string;
80
- export declare const getPolarOpacityParsed: (config: Config) => number;
1
+ import { Config } from './index';
2
+ export declare const defaults: {
3
+ fps: number;
4
+ spectrumWidth: string;
5
+ spectrumHeight: number;
6
+ spectrumX: string;
7
+ spectrumY: string;
8
+ spectrumRotation: string;
9
+ spectrumBusMargin: number;
10
+ spectrumOpacity: string;
11
+ polarX: string;
12
+ polarY: string;
13
+ polarInnerRadius: number;
14
+ polarMaxBarLength: number;
15
+ polarBarWidth: number;
16
+ timeouts: {
17
+ readVideoFrame: number;
18
+ waitDrain: number;
19
+ waitForProcessExit: number;
20
+ };
21
+ };
22
+ export declare type SpectrumEffect = 'volume' | 'smooth';
23
+ export declare const rotationAliasValues: readonly ["up", "down", "mirror"];
24
+ export declare const checkIsPercentValue: (value: string) => boolean;
25
+ export declare const getAudioFilePath: (config: Config) => string;
26
+ export declare const getAudioAutoHighlight: (config: Config) => boolean;
27
+ export declare const getAudioAutoHighlightCount: (config: Config) => number;
28
+ export declare const getBackgroundImagePath: (config: Config) => string | undefined;
29
+ export declare const getBackgroundVideoPaths: (config: Config) => string[] | undefined;
30
+ export declare const getHookVideoPath: (config: Config) => string | undefined;
31
+ export declare const getAutoEditVideo: (config: Config) => boolean;
32
+ export declare const getCameraShakeEnabled: (config: Config) => boolean;
33
+ export declare const getCutZoomEnabled: (config: Config) => boolean;
34
+ export declare const getOutVideoPath: (config: Config) => string;
35
+ export declare type SubtitleAlignment = 'top' | 'middle' | 'bottom';
36
+ export declare type SubtitleRenderSpec = {
37
+ source: {
38
+ kind: 'file';
39
+ path: string;
40
+ } | {
41
+ kind: 'inline';
42
+ text: string;
43
+ };
44
+ alignment: SubtitleAlignment;
45
+ };
46
+ export declare const subtitleAlignmentToAss: (alignment: "top" | "middle" | "bottom") => number;
47
+ export declare const getSubtitleRenderSpec: (config: Config) => SubtitleRenderSpec | undefined;
48
+ export declare const getFPS: (config: Config) => number;
49
+ export declare const getOutputResolution: (config: Config) => {
50
+ width: number;
51
+ height: number;
52
+ } | undefined;
53
+ export declare const getEnhanceFilters: (config: Config) => boolean;
54
+ export declare const getSpectrumBusMargin: () => number;
55
+ export declare const getSpectrumEffect: (config: Config) => "smooth" | "volume" | undefined;
56
+ export declare const getSpectrumWidthAbsolute: (config: Config, backgroundImageWidth: number) => number;
57
+ export declare const getSpectrumHeightAbsolute: (config: Config, backgroundImageHeight: number) => number;
58
+ export declare const getSpectrumXAbsolute: (config: Config, spectrumWidth: number, backgroundImageWidth: number) => number;
59
+ export declare const getSpectrumYAbsolute: (config: Config, spectrumHeight: number, backgroundImageHeight: number) => number;
60
+ export declare const checkIsValidRotationAlias: (aliasName: string) => boolean;
61
+ export declare const getSpectrumRotation: (config: Config) => "up" | "down" | "mirror";
62
+ export declare const getSpectrumColor: (config: Config) => string | import("./image").Color | undefined;
63
+ export declare const getSpectrumOpacity: (config: Config) => string;
64
+ export declare const getSpectrumOpacityParsed: (config: Config) => number;
65
+ export declare const getFfmpeg_cfr: (config: Config) => string | undefined;
66
+ export declare const getFfmpeg_preset: (config: Config) => string | undefined;
67
+ export declare const getFrame_processing_delay: (config: Config) => number | undefined;
68
+ export declare const getVideoTimeouts: (config: Config) => {
69
+ readVideoFrame: number;
70
+ waitDrain: number;
71
+ waitForProcessExit: number;
72
+ };
73
+ export declare const getPolarXAbsolute: (config: Config, backgroundImageWidth: number) => number;
74
+ export declare const getPolarYAbsolute: (config: Config, backgroundImageHeight: number) => number;
75
+ export declare const getPolarInnerRadius: (config: Config) => number;
76
+ export declare const getPolarMaxBarLength: (config: Config) => number;
77
+ export declare const getPolarBarWidth: (config: Config) => number;
78
+ export declare const getPolarEffect: (config: Config) => "smooth" | "volume" | undefined;
79
+ export declare const getPolarColor: (config: Config) => string | import("./image").Color | undefined;
80
+ export declare const getPolarOpacity: (config: Config) => string;
81
+ export declare const getPolarOpacityParsed: (config: Config) => number;