audiomotion-analyzer 5.0.0-alpha.0 → 5.0.0-alpha.1
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/README.md +5 -5
- package/dist/index.js +15 -8
- package/package.json +3 -3
- package/src/audioMotion-analyzer.js +19 -8
package/README.md
CHANGED
|
@@ -80,11 +80,11 @@ const { AudioMotionAnalyzer } = require('audioMotion-analyzer');
|
|
|
80
80
|
|
|
81
81
|
### In the browser using native ES6 module (ESM) <!-- {docsify-ignore} -->
|
|
82
82
|
|
|
83
|
-
Load from
|
|
83
|
+
Load from jsDelivr CDN:
|
|
84
84
|
|
|
85
85
|
```html
|
|
86
86
|
<script type="module">
|
|
87
|
-
import AudioMotionAnalyzer from 'https://cdn.
|
|
87
|
+
import AudioMotionAnalyzer from 'https://cdn.jsdelivr.net/npm/audiomotion-analyzer@alpha/+esm';
|
|
88
88
|
// your code here
|
|
89
89
|
</script>
|
|
90
90
|
```
|
|
@@ -93,10 +93,10 @@ Or download the [latest version](https://github.com/hvianna/audioMotion-analyzer
|
|
|
93
93
|
|
|
94
94
|
### In the browser using global variable <!-- {docsify-ignore} -->
|
|
95
95
|
|
|
96
|
-
Load from
|
|
96
|
+
Load from jsDelivr CDN:
|
|
97
97
|
|
|
98
98
|
```html
|
|
99
|
-
<script src="https://
|
|
99
|
+
<script src="https://cdn.jsdelivr.net/npm/audiomotion-analyzer@alpha"></script>
|
|
100
100
|
<script>
|
|
101
101
|
// available as AudioMotionAnalyzer global
|
|
102
102
|
</script>
|
|
@@ -1865,7 +1865,7 @@ The `import` statement must be inside a `script` which has the `type="module"` p
|
|
|
1865
1865
|
|
|
1866
1866
|
```html
|
|
1867
1867
|
<script type="module">
|
|
1868
|
-
import AudioMotionAnalyzer from 'https://cdn.
|
|
1868
|
+
import AudioMotionAnalyzer from 'https://cdn.jsdelivr.net/npm/audiomotion-analyzer@alpha/+esm';
|
|
1869
1869
|
|
|
1870
1870
|
// your code here
|
|
1871
1871
|
</script>
|
package/dist/index.js
CHANGED
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
* audioMotion-analyzer
|
|
22
22
|
* High-resolution real-time graphic audio spectrum analyzer JS module
|
|
23
23
|
*
|
|
24
|
-
* @version 5.0.0-alpha.
|
|
24
|
+
* @version 5.0.0-alpha.1
|
|
25
25
|
* @author Henrique Avila Vianna <hvianna@gmail.com> <https://henriquevianna.com>
|
|
26
26
|
* @license AGPL-3.0-or-later
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
|
-
const VERSION = '5.0.0-alpha.
|
|
29
|
+
const VERSION = '5.0.0-alpha.1';
|
|
30
30
|
|
|
31
31
|
// internal constants
|
|
32
32
|
const PI = Math.PI,
|
|
@@ -2326,16 +2326,21 @@
|
|
|
2326
2326
|
_ctx.fill();
|
|
2327
2327
|
};
|
|
2328
2328
|
|
|
2329
|
-
// render a bar of LEDs where each element has a single color (uses: analyzerBottom, isLumi)
|
|
2329
|
+
// render a bar of LEDs where each element has a single color (uses: analyzerBottom, isLumi, ledGap)
|
|
2330
2330
|
const renderVintageLeds = (colorStops, barCenter, barHeight, barValue) => {
|
|
2331
2331
|
const colorIndex = isLumi ? 0 : colorStops.findLastIndex(item => ledUnits(barValue) <= ledUnits(item.level)),
|
|
2332
2332
|
savedStrokeStyle = _ctx.strokeStyle;
|
|
2333
|
-
let last = analyzerBottom;
|
|
2333
|
+
let last = [analyzerBottom, 0]; // lastBottom, lastLedTop
|
|
2334
|
+
|
|
2334
2335
|
for (let i = colorCount - 1; i >= colorIndex; i--) {
|
|
2336
|
+
let [lastBottom, lastLedTop] = last,
|
|
2337
|
+
ledTop = ledPosY(colorStops[i].level),
|
|
2338
|
+
topY = analyzerBottom - (i == colorIndex ? barHeight : ledTop);
|
|
2339
|
+
if (ledTop == lastLedTop) continue; // no room for this color, skip it (big leds and/or too many colorStops)
|
|
2340
|
+
|
|
2335
2341
|
_ctx.strokeStyle = colorStops[i].color;
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
last = y - ledGap;
|
|
2342
|
+
strokeBar(barCenter, lastBottom, topY);
|
|
2343
|
+
last = [topY - ledGap, ledTop]; // update last used values
|
|
2339
2344
|
}
|
|
2340
2345
|
_ctx.strokeStyle = savedStrokeStyle;
|
|
2341
2346
|
};
|
|
@@ -2602,9 +2607,11 @@
|
|
|
2602
2607
|
if (showPeakLine) {
|
|
2603
2608
|
_ctx[m](...(_radial ? radialXY(x, h) : [x, analyzerBottom - h]));
|
|
2604
2609
|
if (_radial && _mirror && !isDualHorizontal) points.push([x, h]);
|
|
2605
|
-
} else if (b.peak[channel] > 0)
|
|
2610
|
+
} else if (b.peak[channel] > 0) {
|
|
2606
2611
|
// note: `h` is negative in inner radial
|
|
2612
|
+
if (_peaks == PEAKS_FADE) _ctx.globalAlpha = b.alpha[channel];
|
|
2607
2613
|
radialPoly(x, h, 1, -2); // standard peaks (also does mirror)
|
|
2614
|
+
}
|
|
2608
2615
|
});
|
|
2609
2616
|
if (showPeakLine) {
|
|
2610
2617
|
let p;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "audiomotion-analyzer",
|
|
3
3
|
"description": "High-resolution real-time graphic audio spectrum analyzer JavaScript module with no dependencies.",
|
|
4
|
-
"version": "5.0.0-alpha.
|
|
4
|
+
"version": "5.0.0-alpha.1",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./src/audioMotion-analyzer.js",
|
|
7
7
|
"types": "./src/index.d.ts",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
},
|
|
44
44
|
"homepage": "https://audiomotion.dev",
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@babel/cli": "^7.
|
|
47
|
-
"@babel/core": "^7.
|
|
46
|
+
"@babel/cli": "^7.28.3",
|
|
47
|
+
"@babel/core": "^7.28.5",
|
|
48
48
|
"@babel/plugin-transform-modules-umd": "^7.27.1"
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* audioMotion-analyzer
|
|
3
3
|
* High-resolution real-time graphic audio spectrum analyzer JS module
|
|
4
4
|
*
|
|
5
|
-
* @version 5.0.0-alpha.
|
|
5
|
+
* @version 5.0.0-alpha.1
|
|
6
6
|
* @author Henrique Avila Vianna <hvianna@gmail.com> <https://henriquevianna.com>
|
|
7
7
|
* @license AGPL-3.0-or-later
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
const VERSION = '5.0.0-alpha.
|
|
10
|
+
const VERSION = '5.0.0-alpha.1';
|
|
11
11
|
|
|
12
12
|
// internal constants
|
|
13
13
|
const PI = Math.PI,
|
|
@@ -2378,18 +2378,25 @@ class AudioMotionAnalyzer {
|
|
|
2378
2378
|
_ctx.fill();
|
|
2379
2379
|
}
|
|
2380
2380
|
|
|
2381
|
-
// render a bar of LEDs where each element has a single color (uses: analyzerBottom, isLumi)
|
|
2381
|
+
// render a bar of LEDs where each element has a single color (uses: analyzerBottom, isLumi, ledGap)
|
|
2382
2382
|
const renderVintageLeds = ( colorStops, barCenter, barHeight, barValue ) => {
|
|
2383
2383
|
const colorIndex = isLumi ? 0 : colorStops.findLastIndex( item => ledUnits( barValue ) <= ledUnits( item.level ) ),
|
|
2384
2384
|
savedStrokeStyle = _ctx.strokeStyle;
|
|
2385
2385
|
|
|
2386
|
-
let last = analyzerBottom;
|
|
2386
|
+
let last = [ analyzerBottom, 0 ]; // lastBottom, lastLedTop
|
|
2387
2387
|
|
|
2388
2388
|
for ( let i = colorCount - 1; i >= colorIndex; i-- ) {
|
|
2389
|
+
let [ lastBottom, lastLedTop ] = last,
|
|
2390
|
+
ledTop = ledPosY( colorStops[ i ].level ),
|
|
2391
|
+
topY = analyzerBottom - ( i == colorIndex ? barHeight : ledTop );
|
|
2392
|
+
|
|
2393
|
+
if ( ledTop == lastLedTop )
|
|
2394
|
+
continue; // no room for this color, skip it (big leds and/or too many colorStops)
|
|
2395
|
+
|
|
2389
2396
|
_ctx.strokeStyle = colorStops[ i ].color;
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
last =
|
|
2397
|
+
strokeBar( barCenter, lastBottom, topY );
|
|
2398
|
+
|
|
2399
|
+
last = [ topY - ledGap, ledTop ]; // update last used values
|
|
2393
2400
|
}
|
|
2394
2401
|
|
|
2395
2402
|
_ctx.strokeStyle = savedStrokeStyle;
|
|
@@ -2695,8 +2702,12 @@ class AudioMotionAnalyzer {
|
|
|
2695
2702
|
if ( _radial && _mirror && ! isDualHorizontal )
|
|
2696
2703
|
points.push( [ x, h ] );
|
|
2697
2704
|
}
|
|
2698
|
-
else if ( b.peak[ channel ] > 0 ) // note: `h` is negative in inner radial
|
|
2705
|
+
else if ( b.peak[ channel ] > 0 ) { // note: `h` is negative in inner radial
|
|
2706
|
+
if ( _peaks == PEAKS_FADE )
|
|
2707
|
+
_ctx.globalAlpha = b.alpha[ channel ];
|
|
2708
|
+
|
|
2699
2709
|
radialPoly( x, h, 1, -2 ); // standard peaks (also does mirror)
|
|
2710
|
+
}
|
|
2700
2711
|
});
|
|
2701
2712
|
if ( showPeakLine ) {
|
|
2702
2713
|
let p;
|