nodejs-audio-visualizer 4.5.0 → 5.0.0
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.
- package/LICENSE +21 -21
- package/README.md +80 -80
- package/dist/audio.d.ts +12 -12
- package/dist/audio.js +120 -120
- package/dist/beats.d.ts +19 -19
- package/dist/beats.js +43 -43
- package/dist/bpmEncoder.d.ts +14 -14
- package/dist/bpmEncoder.js +97 -97
- package/dist/config.d.ts +77 -77
- package/dist/config.js +369 -369
- package/dist/dsp.d.ts +16 -16
- package/dist/dsp.js +76 -76
- package/dist/highlight.d.ts +32 -32
- package/dist/highlight.js +325 -325
- package/dist/image.d.ts +79 -79
- package/dist/image.js +458 -458
- package/dist/index.d.ts +79 -79
- package/dist/index.js +534 -531
- package/dist/index.js.map +1 -1
- package/dist/subtitleConvert.d.ts +3 -3
- package/dist/subtitleConvert.js +61 -61
- package/dist/video.d.ts +80 -80
- package/dist/video.js +434 -426
- package/dist/video.js.map +1 -1
- package/dist/waitForEventLoop.d.ts +1 -1
- package/dist/waitForEventLoop.js +5 -5
- package/package.json +61 -61
- package/src/audio.ts +120 -120
- package/src/beats.ts +68 -68
- package/src/bpmEncoder.ts +97 -97
- package/src/config.ts +476 -476
- package/src/dsp.ts +95 -95
- package/src/highlight.ts +284 -284
- package/src/image.ts +602 -602
- package/src/index.ts +718 -713
- package/src/subtitleConvert.ts +63 -63
- package/src/tests/audio.test.ts +96 -96
- package/src/tests/config.test.ts +496 -496
- package/src/tests/dsp.test.ts +24 -24
- package/src/tests/highlight.test.ts +178 -178
- package/src/tests/image.test.ts +222 -222
- package/src/tests/index.test.ts +180 -112
- package/src/tests/subtitleConvert.test.ts +23 -23
- package/src/tests/video.test.ts +285 -216
- package/src/typings.d.ts +6 -6
- package/src/video.ts +550 -542
- package/src/waitForEventLoop.ts +2 -2
package/src/tests/image.test.ts
CHANGED
|
@@ -1,222 +1,222 @@
|
|
|
1
|
-
import { expect } from 'chai';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import {
|
|
4
|
-
drawRect,
|
|
5
|
-
Color,
|
|
6
|
-
createSpectrumVisualizerFrameGenerator,
|
|
7
|
-
createPolarVisualizerFrameGenerator,
|
|
8
|
-
parseImage,
|
|
9
|
-
convertToBmp,
|
|
10
|
-
mixValues,
|
|
11
|
-
mixColors,
|
|
12
|
-
} from '../image';
|
|
13
|
-
import { createBpmEncoder } from '../bpmEncoder';
|
|
14
|
-
|
|
15
|
-
describe('image', function () {
|
|
16
|
-
it('mixValues', function () {
|
|
17
|
-
expect(mixValues(420, 0.69, 96)).equal(320);
|
|
18
|
-
expect(mixValues(420, 1, 96)).equal(420);
|
|
19
|
-
expect(mixValues(420, 0, 96)).equal(96);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('mixColors', function () {
|
|
23
|
-
const result1 = mixColors({
|
|
24
|
-
color: { red: 123, green: 69, blue: 96 },
|
|
25
|
-
colorOpacity: 0.24,
|
|
26
|
-
backgroundColor: { red: 69, green: 123, blue: 42 },
|
|
27
|
-
});
|
|
28
|
-
expect(result1).deep.equal({ red: 82, green: 110, blue: 55 });
|
|
29
|
-
|
|
30
|
-
const result2 = mixColors({
|
|
31
|
-
color: { red: 123, green: 69, blue: 96 },
|
|
32
|
-
colorOpacity: 0,
|
|
33
|
-
backgroundColor: { red: 69, green: 123, blue: 42 },
|
|
34
|
-
});
|
|
35
|
-
expect(result2).deep.equal({ red: 69, green: 123, blue: 42 });
|
|
36
|
-
|
|
37
|
-
const result3 = mixColors({
|
|
38
|
-
color: { red: 123, green: 69, blue: 96 },
|
|
39
|
-
colorOpacity: 1,
|
|
40
|
-
backgroundColor: { red: 69, green: 123, blue: 42 },
|
|
41
|
-
});
|
|
42
|
-
expect(result3).deep.equal({ red: 123, green: 69, blue: 96 });
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('drawRect', function () {
|
|
46
|
-
const imageWidth = 10;
|
|
47
|
-
const imageHeight = 10;
|
|
48
|
-
const extraBytes = imageWidth % 4;
|
|
49
|
-
const rowBytes = 3 * imageWidth + extraBytes;
|
|
50
|
-
const imageDstBuffer = {
|
|
51
|
-
shiftPos: 54,
|
|
52
|
-
rowBytes,
|
|
53
|
-
width: imageWidth,
|
|
54
|
-
data: Array.from({ length: imageWidth * imageHeight * 4 }).fill(0)
|
|
55
|
-
};
|
|
56
|
-
const rectX = 4;
|
|
57
|
-
const rectY = 3;
|
|
58
|
-
const rectWidth = 4;
|
|
59
|
-
const rectHeight = 3;
|
|
60
|
-
const rectColor: Color = { red: 111, green: 112, blue: 123 };
|
|
61
|
-
|
|
62
|
-
const expectedImageData = Array.from({ length: imageWidth * imageWidth * 4 }).fill(0);
|
|
63
|
-
const imagePixelIndices = [162, 165, 168, 171, 194, 197, 200, 203, 226, 229, 232, 235];
|
|
64
|
-
imagePixelIndices.forEach((pixelIndex) => {
|
|
65
|
-
expectedImageData[pixelIndex] = rectColor.blue;
|
|
66
|
-
expectedImageData[pixelIndex + 1] = rectColor.green;
|
|
67
|
-
expectedImageData[pixelIndex + 2] = rectColor.red;
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
drawRect({
|
|
71
|
-
imageDstBuffer: imageDstBuffer as any,
|
|
72
|
-
position: { x: rectX, y: rectY },
|
|
73
|
-
size: { width: rectWidth, height: rectHeight },
|
|
74
|
-
color: rectColor,
|
|
75
|
-
opacity: 1
|
|
76
|
-
});
|
|
77
|
-
expect(imageDstBuffer.data).deep.equal(expectedImageData);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('createSpectrumVisualizerFrameGenerator', async function () {
|
|
81
|
-
const expectedImageLength = 6220854;
|
|
82
|
-
const backgroundImagePath = path.resolve('example/media/horses.png');
|
|
83
|
-
const backgroundImageBmpBuffer = await convertToBmp(backgroundImagePath);
|
|
84
|
-
const backgroundImage = parseImage(backgroundImageBmpBuffer);
|
|
85
|
-
const bpmEncoder = createBpmEncoder({ width: backgroundImage.width, height: backgroundImage.height });
|
|
86
|
-
const backgroundImageBuffer = bpmEncoder(backgroundImage.data);
|
|
87
|
-
const createVisualizerFrame = createSpectrumVisualizerFrameGenerator();
|
|
88
|
-
const frameSpectrumDown = createVisualizerFrame({
|
|
89
|
-
backgroundImageBuffer,
|
|
90
|
-
spectrum: [0.5, 0, 1],
|
|
91
|
-
size: { width: 15, height: 20 },
|
|
92
|
-
position: { x: 15, y: 0 },
|
|
93
|
-
rotation: 'down',
|
|
94
|
-
margin: 4,
|
|
95
|
-
color: { red: 1, green: 1, blue: 1 },
|
|
96
|
-
opacity: 1,
|
|
97
|
-
});
|
|
98
|
-
const resultSpectrumDown = frameSpectrumDown.data.toJSON().data;
|
|
99
|
-
expect(resultSpectrumDown).to.have.length(expectedImageLength);
|
|
100
|
-
|
|
101
|
-
const frameSpectrumUp = createVisualizerFrame({
|
|
102
|
-
backgroundImageBuffer,
|
|
103
|
-
spectrum: [0.1, 1, 0],
|
|
104
|
-
size: { width: 25, height: 23 },
|
|
105
|
-
position: { x: 10, y: 5 },
|
|
106
|
-
rotation: 'up',
|
|
107
|
-
margin: 4,
|
|
108
|
-
color: { red: 0, green: 123, blue: 69 },
|
|
109
|
-
opacity: 1,
|
|
110
|
-
});
|
|
111
|
-
const resultSpectrumUp = frameSpectrumUp.data.toJSON().data;
|
|
112
|
-
expect(resultSpectrumUp).to.have.length(expectedImageLength);
|
|
113
|
-
|
|
114
|
-
const frameSpectrumMirror = createVisualizerFrame({
|
|
115
|
-
backgroundImageBuffer,
|
|
116
|
-
spectrum: [0.1, 1, 0],
|
|
117
|
-
size: { width: 25, height: 23 },
|
|
118
|
-
position: { x: 10, y: 5 },
|
|
119
|
-
rotation: 'mirror',
|
|
120
|
-
margin: 4,
|
|
121
|
-
color: { red: 0, green: 123, blue: 69 },
|
|
122
|
-
opacity: 1,
|
|
123
|
-
});
|
|
124
|
-
const resultSpectrumMirror = frameSpectrumMirror.data.toJSON().data;
|
|
125
|
-
expect(resultSpectrumMirror).to.have.length(expectedImageLength);
|
|
126
|
-
|
|
127
|
-
const frameSpectrumUpOpacity50 = createVisualizerFrame({
|
|
128
|
-
backgroundImageBuffer,
|
|
129
|
-
spectrum: [0.1, 1, 0],
|
|
130
|
-
size: { width: 25, height: 23 },
|
|
131
|
-
position: { x: 10, y: 5 },
|
|
132
|
-
rotation: 'up',
|
|
133
|
-
margin: 4,
|
|
134
|
-
color: { red: 0, green: 123, blue: 69 },
|
|
135
|
-
opacity: 0.5,
|
|
136
|
-
});
|
|
137
|
-
const resultSpectrumUpOpacity50 = frameSpectrumUpOpacity50.data.toJSON().data;
|
|
138
|
-
expect(resultSpectrumUpOpacity50).to.have.length(expectedImageLength);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it('createPolarVisualizerFrameGenerator', async function () {
|
|
142
|
-
const expectedImageLength = 6220854;
|
|
143
|
-
const backgroundImagePath = path.resolve('example/media/horses.png');
|
|
144
|
-
const backgroundImageBmpBuffer = await convertToBmp(backgroundImagePath);
|
|
145
|
-
const backgroundImage = parseImage(backgroundImageBmpBuffer);
|
|
146
|
-
const bpmEncoder = createBpmEncoder({ width: backgroundImage.width, height: backgroundImage.height });
|
|
147
|
-
const backgroundImageBuffer = bpmEncoder(backgroundImage.data);
|
|
148
|
-
const createPolarVisualizerFrame = createPolarVisualizerFrameGenerator();
|
|
149
|
-
|
|
150
|
-
const framePolarBasic = createPolarVisualizerFrame({
|
|
151
|
-
backgroundImageBuffer,
|
|
152
|
-
spectrum: [0.5, 0.8, 0.3, 0.9, 0.6, 0.4, 0.7, 0.2],
|
|
153
|
-
centerX: 500,
|
|
154
|
-
centerY: 400,
|
|
155
|
-
innerRadius: 100,
|
|
156
|
-
maxBarLength: 150,
|
|
157
|
-
barWidth: 5,
|
|
158
|
-
color: { red: 255, green: 100, blue: 50 },
|
|
159
|
-
opacity: 1,
|
|
160
|
-
});
|
|
161
|
-
const resultPolarBasic = framePolarBasic.data.toJSON().data;
|
|
162
|
-
expect(resultPolarBasic).to.have.length(expectedImageLength);
|
|
163
|
-
|
|
164
|
-
const framePolarVolume = createPolarVisualizerFrame({
|
|
165
|
-
backgroundImageBuffer,
|
|
166
|
-
spectrum: [0.2, 0.5, 0.8, 0.3, 0.6, 0.9, 0.4, 0.7],
|
|
167
|
-
centerX: 500,
|
|
168
|
-
centerY: 400,
|
|
169
|
-
innerRadius: 80,
|
|
170
|
-
maxBarLength: 120,
|
|
171
|
-
barWidth: 4,
|
|
172
|
-
color: { red: 100, green: 200, blue: 255 },
|
|
173
|
-
opacity: 1,
|
|
174
|
-
spectrumEffect: 'volume',
|
|
175
|
-
});
|
|
176
|
-
const resultPolarVolume = framePolarVolume.data.toJSON().data;
|
|
177
|
-
expect(resultPolarVolume).to.have.length(expectedImageLength);
|
|
178
|
-
|
|
179
|
-
const framePolarSmooth = createPolarVisualizerFrame({
|
|
180
|
-
backgroundImageBuffer,
|
|
181
|
-
spectrum: [0.7, 0.4, 0.9, 0.2, 0.5, 0.8, 0.3, 0.6],
|
|
182
|
-
centerX: 500,
|
|
183
|
-
centerY: 400,
|
|
184
|
-
innerRadius: 90,
|
|
185
|
-
maxBarLength: 130,
|
|
186
|
-
barWidth: 6,
|
|
187
|
-
color: { red: 255, green: 255, blue: 0 },
|
|
188
|
-
opacity: 1,
|
|
189
|
-
spectrumEffect: 'smooth',
|
|
190
|
-
});
|
|
191
|
-
const resultPolarSmooth = framePolarSmooth.data.toJSON().data;
|
|
192
|
-
expect(resultPolarSmooth).to.have.length(expectedImageLength);
|
|
193
|
-
|
|
194
|
-
const framePolarOpacity50 = createPolarVisualizerFrame({
|
|
195
|
-
backgroundImageBuffer,
|
|
196
|
-
spectrum: [0.6, 0.3, 0.8, 0.5, 0.4, 0.7, 0.2, 0.9],
|
|
197
|
-
centerX: 500,
|
|
198
|
-
centerY: 400,
|
|
199
|
-
innerRadius: 100,
|
|
200
|
-
maxBarLength: 140,
|
|
201
|
-
barWidth: 5,
|
|
202
|
-
color: { red: 0, green: 255, blue: 128 },
|
|
203
|
-
opacity: 0.5,
|
|
204
|
-
});
|
|
205
|
-
const resultPolarOpacity50 = framePolarOpacity50.data.toJSON().data;
|
|
206
|
-
expect(resultPolarOpacity50).to.have.length(expectedImageLength);
|
|
207
|
-
|
|
208
|
-
const framePolarHexColor = createPolarVisualizerFrame({
|
|
209
|
-
backgroundImageBuffer,
|
|
210
|
-
spectrum: [0.5, 0.6, 0.7, 0.8, 0.9, 0.4, 0.3, 0.2],
|
|
211
|
-
centerX: 500,
|
|
212
|
-
centerY: 400,
|
|
213
|
-
innerRadius: 110,
|
|
214
|
-
maxBarLength: 160,
|
|
215
|
-
barWidth: 7,
|
|
216
|
-
color: '#FF5733',
|
|
217
|
-
opacity: 1,
|
|
218
|
-
});
|
|
219
|
-
const resultPolarHexColor = framePolarHexColor.data.toJSON().data;
|
|
220
|
-
expect(resultPolarHexColor).to.have.length(expectedImageLength);
|
|
221
|
-
});
|
|
222
|
-
});
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import {
|
|
4
|
+
drawRect,
|
|
5
|
+
Color,
|
|
6
|
+
createSpectrumVisualizerFrameGenerator,
|
|
7
|
+
createPolarVisualizerFrameGenerator,
|
|
8
|
+
parseImage,
|
|
9
|
+
convertToBmp,
|
|
10
|
+
mixValues,
|
|
11
|
+
mixColors,
|
|
12
|
+
} from '../image';
|
|
13
|
+
import { createBpmEncoder } from '../bpmEncoder';
|
|
14
|
+
|
|
15
|
+
describe('image', function () {
|
|
16
|
+
it('mixValues', function () {
|
|
17
|
+
expect(mixValues(420, 0.69, 96)).equal(320);
|
|
18
|
+
expect(mixValues(420, 1, 96)).equal(420);
|
|
19
|
+
expect(mixValues(420, 0, 96)).equal(96);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('mixColors', function () {
|
|
23
|
+
const result1 = mixColors({
|
|
24
|
+
color: { red: 123, green: 69, blue: 96 },
|
|
25
|
+
colorOpacity: 0.24,
|
|
26
|
+
backgroundColor: { red: 69, green: 123, blue: 42 },
|
|
27
|
+
});
|
|
28
|
+
expect(result1).deep.equal({ red: 82, green: 110, blue: 55 });
|
|
29
|
+
|
|
30
|
+
const result2 = mixColors({
|
|
31
|
+
color: { red: 123, green: 69, blue: 96 },
|
|
32
|
+
colorOpacity: 0,
|
|
33
|
+
backgroundColor: { red: 69, green: 123, blue: 42 },
|
|
34
|
+
});
|
|
35
|
+
expect(result2).deep.equal({ red: 69, green: 123, blue: 42 });
|
|
36
|
+
|
|
37
|
+
const result3 = mixColors({
|
|
38
|
+
color: { red: 123, green: 69, blue: 96 },
|
|
39
|
+
colorOpacity: 1,
|
|
40
|
+
backgroundColor: { red: 69, green: 123, blue: 42 },
|
|
41
|
+
});
|
|
42
|
+
expect(result3).deep.equal({ red: 123, green: 69, blue: 96 });
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('drawRect', function () {
|
|
46
|
+
const imageWidth = 10;
|
|
47
|
+
const imageHeight = 10;
|
|
48
|
+
const extraBytes = imageWidth % 4;
|
|
49
|
+
const rowBytes = 3 * imageWidth + extraBytes;
|
|
50
|
+
const imageDstBuffer = {
|
|
51
|
+
shiftPos: 54,
|
|
52
|
+
rowBytes,
|
|
53
|
+
width: imageWidth,
|
|
54
|
+
data: Array.from({ length: imageWidth * imageHeight * 4 }).fill(0)
|
|
55
|
+
};
|
|
56
|
+
const rectX = 4;
|
|
57
|
+
const rectY = 3;
|
|
58
|
+
const rectWidth = 4;
|
|
59
|
+
const rectHeight = 3;
|
|
60
|
+
const rectColor: Color = { red: 111, green: 112, blue: 123 };
|
|
61
|
+
|
|
62
|
+
const expectedImageData = Array.from({ length: imageWidth * imageWidth * 4 }).fill(0);
|
|
63
|
+
const imagePixelIndices = [162, 165, 168, 171, 194, 197, 200, 203, 226, 229, 232, 235];
|
|
64
|
+
imagePixelIndices.forEach((pixelIndex) => {
|
|
65
|
+
expectedImageData[pixelIndex] = rectColor.blue;
|
|
66
|
+
expectedImageData[pixelIndex + 1] = rectColor.green;
|
|
67
|
+
expectedImageData[pixelIndex + 2] = rectColor.red;
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
drawRect({
|
|
71
|
+
imageDstBuffer: imageDstBuffer as any,
|
|
72
|
+
position: { x: rectX, y: rectY },
|
|
73
|
+
size: { width: rectWidth, height: rectHeight },
|
|
74
|
+
color: rectColor,
|
|
75
|
+
opacity: 1
|
|
76
|
+
});
|
|
77
|
+
expect(imageDstBuffer.data).deep.equal(expectedImageData);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('createSpectrumVisualizerFrameGenerator', async function () {
|
|
81
|
+
const expectedImageLength = 6220854;
|
|
82
|
+
const backgroundImagePath = path.resolve('example/media/horses.png');
|
|
83
|
+
const backgroundImageBmpBuffer = await convertToBmp(backgroundImagePath);
|
|
84
|
+
const backgroundImage = parseImage(backgroundImageBmpBuffer);
|
|
85
|
+
const bpmEncoder = createBpmEncoder({ width: backgroundImage.width, height: backgroundImage.height });
|
|
86
|
+
const backgroundImageBuffer = bpmEncoder(backgroundImage.data);
|
|
87
|
+
const createVisualizerFrame = createSpectrumVisualizerFrameGenerator();
|
|
88
|
+
const frameSpectrumDown = createVisualizerFrame({
|
|
89
|
+
backgroundImageBuffer,
|
|
90
|
+
spectrum: [0.5, 0, 1],
|
|
91
|
+
size: { width: 15, height: 20 },
|
|
92
|
+
position: { x: 15, y: 0 },
|
|
93
|
+
rotation: 'down',
|
|
94
|
+
margin: 4,
|
|
95
|
+
color: { red: 1, green: 1, blue: 1 },
|
|
96
|
+
opacity: 1,
|
|
97
|
+
});
|
|
98
|
+
const resultSpectrumDown = frameSpectrumDown.data.toJSON().data;
|
|
99
|
+
expect(resultSpectrumDown).to.have.length(expectedImageLength);
|
|
100
|
+
|
|
101
|
+
const frameSpectrumUp = createVisualizerFrame({
|
|
102
|
+
backgroundImageBuffer,
|
|
103
|
+
spectrum: [0.1, 1, 0],
|
|
104
|
+
size: { width: 25, height: 23 },
|
|
105
|
+
position: { x: 10, y: 5 },
|
|
106
|
+
rotation: 'up',
|
|
107
|
+
margin: 4,
|
|
108
|
+
color: { red: 0, green: 123, blue: 69 },
|
|
109
|
+
opacity: 1,
|
|
110
|
+
});
|
|
111
|
+
const resultSpectrumUp = frameSpectrumUp.data.toJSON().data;
|
|
112
|
+
expect(resultSpectrumUp).to.have.length(expectedImageLength);
|
|
113
|
+
|
|
114
|
+
const frameSpectrumMirror = createVisualizerFrame({
|
|
115
|
+
backgroundImageBuffer,
|
|
116
|
+
spectrum: [0.1, 1, 0],
|
|
117
|
+
size: { width: 25, height: 23 },
|
|
118
|
+
position: { x: 10, y: 5 },
|
|
119
|
+
rotation: 'mirror',
|
|
120
|
+
margin: 4,
|
|
121
|
+
color: { red: 0, green: 123, blue: 69 },
|
|
122
|
+
opacity: 1,
|
|
123
|
+
});
|
|
124
|
+
const resultSpectrumMirror = frameSpectrumMirror.data.toJSON().data;
|
|
125
|
+
expect(resultSpectrumMirror).to.have.length(expectedImageLength);
|
|
126
|
+
|
|
127
|
+
const frameSpectrumUpOpacity50 = createVisualizerFrame({
|
|
128
|
+
backgroundImageBuffer,
|
|
129
|
+
spectrum: [0.1, 1, 0],
|
|
130
|
+
size: { width: 25, height: 23 },
|
|
131
|
+
position: { x: 10, y: 5 },
|
|
132
|
+
rotation: 'up',
|
|
133
|
+
margin: 4,
|
|
134
|
+
color: { red: 0, green: 123, blue: 69 },
|
|
135
|
+
opacity: 0.5,
|
|
136
|
+
});
|
|
137
|
+
const resultSpectrumUpOpacity50 = frameSpectrumUpOpacity50.data.toJSON().data;
|
|
138
|
+
expect(resultSpectrumUpOpacity50).to.have.length(expectedImageLength);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('createPolarVisualizerFrameGenerator', async function () {
|
|
142
|
+
const expectedImageLength = 6220854;
|
|
143
|
+
const backgroundImagePath = path.resolve('example/media/horses.png');
|
|
144
|
+
const backgroundImageBmpBuffer = await convertToBmp(backgroundImagePath);
|
|
145
|
+
const backgroundImage = parseImage(backgroundImageBmpBuffer);
|
|
146
|
+
const bpmEncoder = createBpmEncoder({ width: backgroundImage.width, height: backgroundImage.height });
|
|
147
|
+
const backgroundImageBuffer = bpmEncoder(backgroundImage.data);
|
|
148
|
+
const createPolarVisualizerFrame = createPolarVisualizerFrameGenerator();
|
|
149
|
+
|
|
150
|
+
const framePolarBasic = createPolarVisualizerFrame({
|
|
151
|
+
backgroundImageBuffer,
|
|
152
|
+
spectrum: [0.5, 0.8, 0.3, 0.9, 0.6, 0.4, 0.7, 0.2],
|
|
153
|
+
centerX: 500,
|
|
154
|
+
centerY: 400,
|
|
155
|
+
innerRadius: 100,
|
|
156
|
+
maxBarLength: 150,
|
|
157
|
+
barWidth: 5,
|
|
158
|
+
color: { red: 255, green: 100, blue: 50 },
|
|
159
|
+
opacity: 1,
|
|
160
|
+
});
|
|
161
|
+
const resultPolarBasic = framePolarBasic.data.toJSON().data;
|
|
162
|
+
expect(resultPolarBasic).to.have.length(expectedImageLength);
|
|
163
|
+
|
|
164
|
+
const framePolarVolume = createPolarVisualizerFrame({
|
|
165
|
+
backgroundImageBuffer,
|
|
166
|
+
spectrum: [0.2, 0.5, 0.8, 0.3, 0.6, 0.9, 0.4, 0.7],
|
|
167
|
+
centerX: 500,
|
|
168
|
+
centerY: 400,
|
|
169
|
+
innerRadius: 80,
|
|
170
|
+
maxBarLength: 120,
|
|
171
|
+
barWidth: 4,
|
|
172
|
+
color: { red: 100, green: 200, blue: 255 },
|
|
173
|
+
opacity: 1,
|
|
174
|
+
spectrumEffect: 'volume',
|
|
175
|
+
});
|
|
176
|
+
const resultPolarVolume = framePolarVolume.data.toJSON().data;
|
|
177
|
+
expect(resultPolarVolume).to.have.length(expectedImageLength);
|
|
178
|
+
|
|
179
|
+
const framePolarSmooth = createPolarVisualizerFrame({
|
|
180
|
+
backgroundImageBuffer,
|
|
181
|
+
spectrum: [0.7, 0.4, 0.9, 0.2, 0.5, 0.8, 0.3, 0.6],
|
|
182
|
+
centerX: 500,
|
|
183
|
+
centerY: 400,
|
|
184
|
+
innerRadius: 90,
|
|
185
|
+
maxBarLength: 130,
|
|
186
|
+
barWidth: 6,
|
|
187
|
+
color: { red: 255, green: 255, blue: 0 },
|
|
188
|
+
opacity: 1,
|
|
189
|
+
spectrumEffect: 'smooth',
|
|
190
|
+
});
|
|
191
|
+
const resultPolarSmooth = framePolarSmooth.data.toJSON().data;
|
|
192
|
+
expect(resultPolarSmooth).to.have.length(expectedImageLength);
|
|
193
|
+
|
|
194
|
+
const framePolarOpacity50 = createPolarVisualizerFrame({
|
|
195
|
+
backgroundImageBuffer,
|
|
196
|
+
spectrum: [0.6, 0.3, 0.8, 0.5, 0.4, 0.7, 0.2, 0.9],
|
|
197
|
+
centerX: 500,
|
|
198
|
+
centerY: 400,
|
|
199
|
+
innerRadius: 100,
|
|
200
|
+
maxBarLength: 140,
|
|
201
|
+
barWidth: 5,
|
|
202
|
+
color: { red: 0, green: 255, blue: 128 },
|
|
203
|
+
opacity: 0.5,
|
|
204
|
+
});
|
|
205
|
+
const resultPolarOpacity50 = framePolarOpacity50.data.toJSON().data;
|
|
206
|
+
expect(resultPolarOpacity50).to.have.length(expectedImageLength);
|
|
207
|
+
|
|
208
|
+
const framePolarHexColor = createPolarVisualizerFrame({
|
|
209
|
+
backgroundImageBuffer,
|
|
210
|
+
spectrum: [0.5, 0.6, 0.7, 0.8, 0.9, 0.4, 0.3, 0.2],
|
|
211
|
+
centerX: 500,
|
|
212
|
+
centerY: 400,
|
|
213
|
+
innerRadius: 110,
|
|
214
|
+
maxBarLength: 160,
|
|
215
|
+
barWidth: 7,
|
|
216
|
+
color: '#FF5733',
|
|
217
|
+
opacity: 1,
|
|
218
|
+
});
|
|
219
|
+
const resultPolarHexColor = framePolarHexColor.data.toJSON().data;
|
|
220
|
+
expect(resultPolarHexColor).to.have.length(expectedImageLength);
|
|
221
|
+
});
|
|
222
|
+
});
|