audiomotion-analyzer 3.6.0-beta.0 → 3.6.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 CHANGED
@@ -45,12 +45,11 @@ What users are saying:
45
45
  ## Live code examples
46
46
 
47
47
  - [Quick and easy spectrum analyzer](https://codepen.io/hvianna/pen/pobMLNL)
48
- - [Complete visualization options](https://codepen.io/hvianna/pen/LYREBYQ)
49
48
  - [Using microphone input](https://codepen.io/hvianna/pen/VwKZgEE)
50
- - [Custom callback function](https://codepen.io/hvianna/pen/LYZwdvG)
51
49
  - [Creating additional effects with `getEnergy()`](https://codepen.io/hvianna/pen/poNmVYo)
52
50
  - [No canvas example](https://codepen.io/hvianna/pen/ZEKWWJb) (create your own visualization using analyzer data)
53
51
  - [Integration with Pizzicato library](https://codesandbox.io/s/9y6qb) - see [this discussion](https://github.com/hvianna/audioMotion-analyzer/issues/10) for more info
52
+ - [See more code examples on CodePen](https://codepen.io/collection/ABbbKr)
54
53
 
55
54
  ## Usage
56
55
 
@@ -111,6 +110,7 @@ Valid properties and default values are shown below.
111
110
  Properties marked as *constructor only* can only be set by the constructor call, the others can also be set anytime via [`setOptions()`](#setoptions-options-) method.
112
111
 
113
112
  options = {<br>
113
+ &emsp;&emsp;[alphaBars](#alphabars-boolean): **false**,<br>
114
114
  &emsp;&emsp;[audioCtx](#audioctx-audiocontext-object): *undefined*, // constructor only<br>
115
115
  &emsp;&emsp;[barSpace](#barspace-number): **0.1**,<br>
116
116
  &emsp;&emsp;[bgAlpha](#bgalpha-number): **0.7**,<br>
@@ -120,6 +120,7 @@ options = {<br>
120
120
  &emsp;&emsp;[fsElement](#fselement-htmlelement-object): *undefined*, // constructor only<br>
121
121
  &emsp;&emsp;[gradient](#gradient-string): **'classic'**,<br>
122
122
  &emsp;&emsp;[height](#height-number): *undefined*,<br>
123
+ &emsp;&emsp;[ledBars](#ledbars-boolean): **false**,<br>
123
124
  &emsp;&emsp;[lineWidth](#linewidth-number): **0**,<br>
124
125
  &emsp;&emsp;[loRes](#lores-boolean): **false**,<br>
125
126
  &emsp;&emsp;[lumiBars](#lumibars-boolean): **false**,<br>
@@ -131,6 +132,7 @@ options = {<br>
131
132
  &emsp;&emsp;[mode](#mode-number): **0**,<br>
132
133
  &emsp;&emsp;[onCanvasDraw](#oncanvasdraw-function): *undefined*,<br>
133
134
  &emsp;&emsp;[onCanvasResize](#oncanvasresize-function): *undefined*,<br>
135
+ &emsp;&emsp;[outlineBars](#outlinebars-boolean): **false**,<br>
134
136
  &emsp;&emsp;[overlay](#overlay-boolean): **false**,<br>
135
137
  &emsp;&emsp;[radial](#radial-boolean): **false**,<br>
136
138
  &emsp;&emsp;[reflexAlpha](#reflexalpha-number): **0.15**,<br>
@@ -139,7 +141,7 @@ options = {<br>
139
141
  &emsp;&emsp;[reflexRatio](#reflexratio-number): **0**,<br>
140
142
  &emsp;&emsp;[showBgColor](#showbgcolor-boolean): **true**,<br>
141
143
  &emsp;&emsp;[showFPS](#showfps-boolean): **false**,<br>
142
- &emsp;&emsp;[showLeds](#showleds-boolean): **false**,<br>
144
+ &emsp;&emsp;[showLeds](#showleds-deprecated): **false**, // DEPRECATED - use ledBars instead<br>
143
145
  &emsp;&emsp;[showPeaks](#showpeaks-boolean): **true**,<br>
144
146
  &emsp;&emsp;[showScaleX](#showscalex-boolean): **true**,<br>
145
147
  &emsp;&emsp;[showScaleY](#showscaley-boolean): **false**,<br>
@@ -216,6 +218,20 @@ Defaults to **true**, so the analyzer will start running right after initializat
216
218
 
217
219
  ## Properties
218
220
 
221
+ ### `alphaBars` *boolean*
222
+
223
+ *Available since v3.6.0*
224
+
225
+ When set to *true* each bar's amplitude affects its opacity, i.e., higher bars are rendered more opaque while shorter bars are more transparent.
226
+
227
+ This is similar to the [`lumiBars`](#lumibars-boolean) effect, but bars' amplitudes are preserved and it also works on **Discrete** [mode](#mode-number) and [radial](#radial-boolean) visualization.
228
+
229
+ For effect priority when combined with other settings, see [`isAlphaBars`](#isalphabars-boolean-read-only).
230
+
231
+ Defaults to **false**.
232
+
233
+ !> [See related known issue](#alphabars-and-fillalpha-wont-work-with-radial-on-firefox)
234
+
219
235
  ### `audioCtx` *AudioContext object* *(Read only)*
220
236
 
221
237
  [*AudioContext*](https://developer.mozilla.org/en-US/docs/Web/API/AudioContext) used by **audioMotion-analyzer**.
@@ -247,7 +263,7 @@ See also the [fluid demo](/demo/fluid.html) and the [multi-instance demo](/demo/
247
263
 
248
264
  *Available since v2.0.0*
249
265
 
250
- Customize the spacing between bars in [octave bands modes](#mode-number).
266
+ Customize the spacing between bars in **octave bands** [modes](#mode-number).
251
267
 
252
268
  Use a value between 0 and 1 for spacing proportional to the band width. Values >= 1 will be considered as a literal number of pixels.
253
269
 
@@ -255,7 +271,7 @@ For example, `barSpace = 0.5` will use half the width available to each band for
255
271
  On the other hand, `barSpace = 2` will set a fixed spacing of 2 pixels, independent of the width of bars.
256
272
  Prefer proportional spacing to obtain consistent results among different resolutions and screen sizes.
257
273
 
258
- `barSpace = 0` will effectively show contiguous bars, except when [`showLeds`](#showleds-boolean) is *true*, in which case a minimum spacing is enforced
274
+ `barSpace = 0` will effectively show contiguous bars, except when [`ledBars`](#ledbars-boolean) is *true*, in which case a minimum spacing is enforced
259
275
  (this can be customized via [`setLedParams()`](#setledparams-params-) method).
260
276
 
261
277
  Defaults to **0.1**.
@@ -296,9 +312,7 @@ See also [`connectOutput()`](#connectoutput-node-).
296
312
 
297
313
  ### `energy` **(DEPRECATED)**
298
314
 
299
- **This property will be removed in version 4.0.0**
300
-
301
- Use [`getEnergy()`](#getenergy-preset-startfreq-endfreq-) instead.
315
+ **This property will be removed in version 4.0.0** - Use [`getEnergy()`](#getenergy-preset-startfreq-endfreq-) instead.
302
316
 
303
317
  ### `fftSize` *number*
304
318
 
@@ -313,15 +327,17 @@ Defaults to **8192**.
313
327
 
314
328
  *Available since v2.0.0*
315
329
 
316
- Opacity of the area fill in **Line / Area graph** visualization ([`mode`](#mode-number) 10).
330
+ Opacity of the area fill in **Graph** [mode](#mode-number), or inner fill of bars in **octave bands** modes when [`outlineBars`](#outlinebars-boolean) is *true*.
317
331
 
318
332
  It must be a number between 0 (completely transparent) and 1 (completely opaque).
319
333
 
320
- Please note that this affects only the area fill. The line (when [`lineWidth`](#linewidth-number) > 0) is always drawn at full opacity.
334
+ Please note that the line stroke (when [`lineWidth`](#linewidth-number) > 0) is always drawn at full opacity, regardless of the `fillAlpha` value.
335
+
336
+ Also, for octave bands modes, [`alphaBars`](#alphabars-boolean) set to *true* takes precedence over `fillAlpha`.
321
337
 
322
338
  Defaults to **1**.
323
339
 
324
- !> [See related known issue](#fillalpha-and-radial-mode-on-firefox)
340
+ !> [See related known issue](#alphabars-and-fillalpha-wont-work-with-radial-on-firefox)
325
341
 
326
342
  ### `fps` *number* *(Read only)*
327
343
 
@@ -355,47 +371,77 @@ Nominal dimensions of the analyzer.
355
371
 
356
372
  If one or both of these are `undefined`, the analyzer will try to adjust to the container's width and/or height.
357
373
  If the container's width and/or height are 0 (inline elements), a reference size of **640 x 270 pixels** will be used to replace the missing dimension(s).
358
- This should be considered the minimum dimensions for proper visualization of all available modes with the [LED effect](#showleds-boolean) on.
374
+ This should be considered the minimum dimensions for proper visualization of all available modes with the [LED effect](#ledbars-boolean) on.
359
375
 
360
376
  You can set both values at once using the [`setCanvasSize()`](#setcanvassize-width-height-) method.
361
377
 
362
378
  ?> You can read the actual canvas dimensions at any time directly from the [`canvas`](#canvas-htmlcanvaselement-object-read-only) object.
363
379
 
380
+ ### `isAlphaBars` *boolean* *(Read only)*
381
+
382
+ *Available since v3.6.0*
383
+
384
+ ***true*** when alpha bars are effectively being displayed, i.e., [`alphaBars`](#alphabars-boolean) is set to *true* and [`mode`](#mode-number) is set to discrete frequencies
385
+ or one of the octave bands modes, in which case [`lumiBars`](#lumibars-boolean) must be set to *false* or [`radial`](#radial-boolean) must be set to *true*.
386
+
364
387
  ### `isFullscreen` *boolean* *(Read only)*
365
388
 
366
- *true* when the analyzer is being displayed in fullscreen, or *false* otherwise.
389
+ ***true*** when the analyzer is being displayed in fullscreen, or ***false*** otherwise.
367
390
 
368
391
  See [`toggleFullscreen()`](#togglefullscreen).
369
392
 
370
- ### `isLedDisplay` *boolean* *(Read only)*
393
+ ### `isLedBars` *boolean* *(Read only)*
371
394
 
372
- *Available since v3.0.0*
395
+ *Available since v3.6.0* (formerly `isLedDisplay`)
396
+
397
+ ***true*** when LED bars are effectively being displayed, i.e., [`ledBars`](#ledBars-boolean) is set to *true* and [`mode`](#mode-number) is set to an octave bands mode and [`radial`](#radial-boolean) is *false*.
373
398
 
374
- *true* when the LED effect is effectively being displayed, i.e., [`showLeds`](#showleds-boolean) is set to *true* and [`mode`](#mode-number) is set to one of the octave bands modes and [`radial`](#radial-boolean) is *false*.
399
+ ### `isLedDisplay` **(DEPRECATED)**
400
+
401
+ **This property will be removed in version 4.0.0** - Use [`isLedBars`](#isledbars-boolean-read-only) instead.
375
402
 
376
403
  ### `isLumiBars` *boolean* *(Read only)*
377
404
 
378
405
  *Available since v3.0.0*
379
406
 
380
- *true* when the luminance bars effect is effectively being displayed, i.e., [`lumiBars`](#lumibars-boolean) is set to *true* and [`mode`](#mode-number) is set to one of the octave bands modes and [`radial`](#radial-boolean) is *false*.
407
+ ***true*** when luminance bars are effectively being displayed, i.e., [`lumiBars`](#lumibars-boolean) is set to *true* and [`mode`](#mode-number) is set to an octave bands mode and [`radial`](#radial-boolean) is *false*.
381
408
 
382
409
  ### `isOctaveBands` *boolean* *(Read only)*
383
410
 
384
411
  *Available since v3.0.0*
385
412
 
386
- *true* when [`mode`](#mode-number) is set to one of the octave bands modes.
413
+ ***true*** when [`mode`](#mode-number) is set to one of the octave bands modes.
387
414
 
388
415
  ### `isOn` *boolean* *(Read only)*
389
416
 
390
- *true* if the analyzer process is running, or *false* if it's stopped.
417
+ ***true*** if the analyzer process is running, or *false* if it's stopped.
391
418
 
392
419
  See [`toggleAnalyzer()`](#toggleanalyzer-boolean-).
393
420
 
421
+ ### `isOutlineBars` *boolean* *(Read only)*
422
+
423
+ *Available since v3.6.0*
424
+
425
+ ***true*** when outlined bars are effectively being displayed, i.e., [`outlineBars`](#outlinebars-boolean) is set to *true*, [`mode`](#mode-number) is set to
426
+ one of the octave bands modes and both [`ledBars`](#ledbars-boolean) and [`lumiBars`](#lumibars-boolean) are set to *false*, or [`radial`](#radial-boolean) is set to *true*.
427
+
428
+ ### `ledBars` *boolean*
429
+
430
+ *Available since v3.6.0* (formerly `showLeds`)
431
+
432
+ *true* to activate a vintage LEDs display effect. Only effective for **octave bands** [modes](#mode-number).
433
+
434
+ This effect can be customized via [`setLedParams()`](#setledparams-params-) method.
435
+
436
+ For effect priority when combined with other settings, see [`isLedBars`](#isledbars-boolean-read-only).
437
+
438
+ Defaults to **false**.
439
+
394
440
  ### `lineWidth` *number*
395
441
 
396
442
  *Available since v2.0.0*
397
443
 
398
- Line width for the **Line / Area graph** visualization ([`mode`](#mode-number) 10).
444
+ Line width for **Graph** [mode](#mode-number), or outline stroke in **octave bands** modes when [`outlineBars`](#outlinebars-boolean) is *true*.
399
445
 
400
446
  For the line to be distinguishable, set also [`fillAlpha`](#fillalpha-number) < 1.
401
447
 
@@ -422,10 +468,14 @@ This will prevent the canvas size from changing, when switching the low resoluti
422
468
 
423
469
  *Available since v1.1.0*
424
470
 
425
- This is only effective for [visualization modes](#mode-number) 1 to 8 (octave bands).
471
+ This is only effective for **octave bands** [modes](#mode-number).
426
472
 
427
473
  When set to *true* all analyzer bars will be displayed at full height with varying luminance (opacity, actually) instead.
428
474
 
475
+ `lumiBars` takes precedence over [`alphaBars`](#alphabars-boolean) and [`outlineBars`](#outlinebars-boolean), except in [`radial`](#radial-boolean) visualization.
476
+
477
+ For effect priority when combined with other settings, see [`isLumiBars`](#islumibars-boolean-read-only).
478
+
429
479
  Defaults to **false**.
430
480
 
431
481
  ### `maxDecibels` *number*
@@ -472,9 +522,9 @@ Defaults to **0**.
472
522
 
473
523
  Current visualization mode.
474
524
 
475
- + **Discrete frequencies** mode provides the highest resolution, allowing you to visualize individual frequencies provided by the [FFT](https://en.wikipedia.org/wiki/Fast_Fourier_transform);
525
+ + **Discrete** mode provides the highest resolution, allowing you to visualize individual frequencies amplitudes as provided by the [FFT](https://en.wikipedia.org/wiki/Fast_Fourier_transform) computation;
476
526
  + **Octave bands** modes display wider vertical bars, each one representing the *n*th part of an octave, based on a [24-tone equal tempered scale](https://en.wikipedia.org/wiki/Quarter_tone);
477
- + **Line / Area graph** mode uses the discrete frequencies data to draw a filled shape and/or a continuous line (see [`fillAlpha`](#fillalpha-number) and [`lineWidth`](#linewidth-number) properties).
527
+ + **Graph** mode uses the discrete data points to draw a continuous line and/or filled area graph (see [`fillAlpha`](#fillalpha-number) and [`lineWidth`](#linewidth-number) properties).
478
528
 
479
529
  mode | description | notes
480
530
  ------:|:-------------:|------
@@ -488,10 +538,20 @@ mode | description | notes
488
538
  7 | Half octave bands |
489
539
  8 | Full octave bands |
490
540
  9 | *(not valid)* | *reserved*
491
- 10 | Line / Area graph | *added in v1.1.0*
541
+ 10 | Graph | *added in v1.1.0*
492
542
 
493
543
  Defaults to **0**.
494
544
 
545
+ ### `outlineBars` *boolean*
546
+
547
+ *Available since v3.6.0*
548
+
549
+ When *true* and [`mode`](#mode-number) is set to one of the **octave bands** modes, draws outlined bars with customizable [`fillAlpha`](#fillalpha-number) and [`lineWidth`](#linewidth-number).
550
+
551
+ For effect priority when combined with other settings, see [`isOutlineBars`](#isoutlinebars-boolean-read-only).
552
+
553
+ Defaults to **false**.
554
+
495
555
  ### `overlay` *boolean*
496
556
 
497
557
  *Available since v2.2.0*
@@ -506,9 +566,7 @@ Defaults to **false**.
506
566
 
507
567
  ### `peakEnergy` **(DEPRECATED)**
508
568
 
509
- **This property will be removed in version 4.0.0**
510
-
511
- Use [`getEnergy('peak')`](#getenergy-preset-startfreq-endfreq-) instead.
569
+ **This property will be removed in version 4.0.0** - Use [`getEnergy('peak')`](#getenergy-preset-startfreq-endfreq-) instead.
512
570
 
513
571
  ### `pixelRatio` *number* *(Read only)*
514
572
 
@@ -525,14 +583,14 @@ When [`loRes`](#lores-boolean) is *true* `pixelRatio` is halved, i.e. **0.5** fo
525
583
 
526
584
  When *true*, the spectrum analyzer is rendered as a circle, with radial frequency bars spreading from the center of the canvas.
527
585
 
528
- When radial mode is active, [`lumiBars`](#lumibars-boolean) and [`showLeds`](#showleds-boolean) have no effect, and
529
- also [`showPeaks`](#showpeaks-boolean) has no effect in **Line / Area graph** mode.
586
+ When radial mode is active, [`ledBars`](#ledbars-boolean) and [`lumiBars`](#lumibars-boolean) have no effect, and
587
+ also [`showPeaks`](#showpeaks-boolean) has no effect in radial **Graph** mode.
530
588
 
531
589
  See also [`spinSpeed`](#spinspeed-number).
532
590
 
533
591
  Defaults to **false**.
534
592
 
535
- !> [See related known issue](#fillalpha-and-radial-mode-on-firefox)
593
+ !> [See related known issue](#alphabars-and-fillalpha-wont-work-with-radial-on-firefox)
536
594
 
537
595
  ### `reflexAlpha` *number*
538
596
 
@@ -589,20 +647,16 @@ or transparent when [`overlay`](#overlay-boolean) is ***true***.
589
647
 
590
648
  Defaults to **true**.
591
649
 
592
- ?> Please note that when [`overlay`](#overlay-boolean) is ***false*** and [`showLeds`](#showleds-boolean) is ***true***, the background color will always be black,
650
+ ?> Please note that when [`overlay`](#overlay-boolean) is ***false*** and [`ledBars`](#ledbars-boolean) is ***true***, the background color will always be black,
593
651
  and setting `showBgColor` to ***true*** will make the "unlit" LEDs visible instead.
594
652
 
595
653
  ### `showFPS` *boolean*
596
654
 
597
655
  *true* to display the current frame rate. Defaults to **false**.
598
656
 
599
- ### `showLeds` *boolean*
600
-
601
- *true* to activate a vintage LEDs display effect. Only effective for [visualization modes](#mode-number) 1 to 8 (octave bands).
657
+ ### `showLeds` **(DEPRECATED)**
602
658
 
603
- This effect can be customized via [`setLedParams()`](#setledparams-params-) method.
604
-
605
- Defaults to **false**.
659
+ **This property will be removed in version 4.0.0** - Use [`ledBars`](#ledbars-boolean) instead.
606
660
 
607
661
  ### `showPeaks` *boolean*
608
662
 
@@ -885,7 +939,8 @@ Use this method inside your callback function to create additional visual effect
885
939
 
886
940
  Registers a custom color gradient.
887
941
 
888
- `name` must be a non-empty *string* that will be used when setting the [`gradient`](#gradient-string) property. `options` must be an object as shown below:
942
+ `name` must be a non-empty *string* that will be used to select this gradient, via the [`gradient`](#gradient-string) property.
943
+ `options` must be an object as shown below:
889
944
 
890
945
  ```js
891
946
  const options = {
@@ -893,12 +948,21 @@ const options = {
893
948
  dir: 'h', // add this property to create a horizontal gradient (optional)
894
949
  colorStops: [ // list your gradient colors in this array (at least 2 entries are required)
895
950
  'red', // colors may be defined in any valid CSS format
896
- { pos: .6, color: '#ff0' }, // use an object to adjust the position (0 to 1) of a color
951
+ { pos: .6, color: '#ff0' }, // use an object to adjust the offset (0 to 1) of a colorStop
897
952
  'hsl( 120, 100%, 50% )' // colors may be defined in any valid CSS format
898
953
  ]
899
954
  }
900
955
 
901
- audioMotion.registerGradient( 'my-grad', options );
956
+ audioMotion.registerGradient( 'myGradient', options );
957
+ ```
958
+
959
+ !> In TypeScript projects make sure to import the `GradientOptions` definition and use it as the type of your object, like so:
960
+
961
+ ```js
962
+ import AudioMotionAnalyzer, { GradientOptions } from 'audiomotion-analyzer'
963
+
964
+ const options: GradientOptions = {
965
+
902
966
  ```
903
967
 
904
968
  Additional information about [gradient color-stops](https://developer.mozilla.org/en-US/docs/Web/API/CanvasGradient/addColorStop).
@@ -915,7 +979,7 @@ Sets the desired frequency range. Values are expressed in Hz (Hertz).
915
979
 
916
980
  *Available since v3.2.0*
917
981
 
918
- Customize parameters used to create the [LEDs display effect](#showleds-boolean).
982
+ Customize parameters used to create the [LEDs display effect](#ledbars-boolean).
919
983
 
920
984
  `params` should be an object with the following structure:
921
985
 
@@ -1002,9 +1066,9 @@ ERR_UNKNOWN_GRADIENT | User tried to [select a gradient](#gradient-string)
1002
1066
  [`reflexBright`](#reflexbright-number) feature relies on the [`filter`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/filter) property of the Canvas API,
1003
1067
  which is [currently not supported in some browsers](https://caniuse.com/#feat=mdn-api_canvasrenderingcontext2d_filter) (notably, Opera and Safari).
1004
1068
 
1005
- ### fillAlpha and radial mode on Firefox {docsify-ignore}
1069
+ ### alphaBars and fillAlpha won't work with Radial on Firefox {docsify-ignore}
1006
1070
 
1007
- On Firefox, [`fillAlpha`](#fillalpha-number) may not work properly for [`radial`](#radial-boolean) visualization, due to [this bug](https://bugzilla.mozilla.org/show_bug.cgi?id=1164912).
1071
+ On Firefox, [`alphaBars`](#alphaBars-boolean) and [`fillAlpha`](#fillalpha-number) won't work with [`radial`](#radial-boolean) visualization when using hardware acceleration, due to [this bug](https://bugzilla.mozilla.org/show_bug.cgi?id=1164912).
1008
1072
 
1009
1073
  ### Visualization of live streams won't work on Safari {docsify-ignore}
1010
1074
 
@@ -1030,13 +1094,15 @@ See [Changelog.md](Changelog.md)
1030
1094
 
1031
1095
  ## Get in touch!
1032
1096
 
1033
- If you create something cool with this project, or simply think it's useful, I would like to know! Please drop me an e-mail at hvianna@gmail.com
1097
+ If you create something cool with **audioMotion-analyzer**, or simply think it's useful, I would love to know! Please drop me an e-mail at hvianna@gmail.com
1034
1098
 
1035
- If you have a feature request or code suggestion, please see [CONTRIBUTING.md](CONTRIBUTING.md)
1099
+ For feature requests, suggestions or feedback, please see the [CONTRIBUTING.md](CONTRIBUTING.md) file.
1036
1100
 
1037
- And if you're feeling generous you can [buy me a coffee on Ko-fi](https://ko-fi.com/Q5Q6157GZ) :grin::coffee:
1101
+ And if you're feeling generous, maybe:
1038
1102
 
1039
- [![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/Q5Q6157GZ)
1103
+ * [Buy me a coffee](https://ko-fi.com/Q5Q6157GZ) on Ko-fi ☕😁
1104
+ * Gift me something from my [Bandcamp wishlist](https://bandcamp.com/henriquevianna/wishlist) 🎁🥰
1105
+ * Tip me via [Brave Rewards](https://brave.com/brave-rewards/) using Brave browser 🤓
1040
1106
 
1041
1107
 
1042
1108
  ## License
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": "3.6.0-beta.0",
4
+ "version": "3.6.1",
5
5
  "main": "./src/audioMotion-analyzer.js",
6
6
  "module": "./src/audioMotion-analyzer.js",
7
7
  "types": "./src/index.d.ts",
@@ -2,12 +2,12 @@
2
2
  * audioMotion-analyzer
3
3
  * High-resolution real-time graphic audio spectrum analyzer JS module
4
4
  *
5
- * @version 3.6.0-beta.0
5
+ * @version 3.6.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 = '3.6.0-beta.0';
10
+ const VERSION = '3.6.1';
11
11
 
12
12
  // internal constants
13
13
  const TAU = 2 * Math.PI,
package/src/index.d.ts CHANGED
@@ -82,8 +82,8 @@ export interface GradientOptions {
82
82
 
83
83
  export interface LedParameters {
84
84
  maxLeds: number;
85
- spaceVRatio: number;
86
- spaceHRatio: number;
85
+ spaceV: number;
86
+ spaceH: number;
87
87
  }
88
88
 
89
89
  declare class AudioMotionAnalyzer {
package/Changelog.md DELETED
@@ -1,292 +0,0 @@
1
- Changelog
2
- =========
3
-
4
- ## version 3.6.0-beta.0 (2021-10-05)
5
-
6
- ### Added: <!-- {docsify-ignore} -->
7
-
8
- + `alphaBars` effect, which is similar to `lumiBars` but preserves bars' amplitudes and also works on discrete frequencies mode and radial visualization;
9
- + `outlineBars` effect, which extends the usage of `lineWidth` and `fillAlpha` to octave bands modes;
10
- + `isAlphaBars` and `isOutlineBars` read-only properties.
11
-
12
- ### Changed: <!-- {docsify-ignore} -->
13
-
14
- + `showLeds` and `isLedDisplay` **have been deprecated** in favor of `ledBars` and `isLedBars`, for consistency.
15
-
16
- ### Fixed: <!-- {docsify-ignore} -->
17
-
18
- + [`getEnergy()`](README.md#getenergy-preset-startfreq-endfreq-) would not accept a fractionary starting frequency.
19
-
20
- ### Improved: <!-- {docsify-ignore} -->
21
-
22
- + Regenerate the current gradient if/when it is re-registered [(#21)](https://github.com/hvianna/audioMotion-analyzer/issues/21);
23
- + The fluid demo now shows the status of read-only flags (`isLedBars`, etc) for better visualization of the interactions between different options.
24
-
25
-
26
- ## version 3.5.1 (2021-09-10)
27
-
28
- + Removed named tuples from the TS type definitions file, for improved compatibility [(#20)](https://github.com/hvianna/audioMotion-analyzer/issues/20).
29
-
30
-
31
- ## version 3.5.0 (2021-07-15)
32
-
33
- ### Added: <!-- {docsify-ignore} -->
34
-
35
- + [`getBars()`](README.md#getbars) method, which provides real-time analyzer data;
36
- + [`useCanvas`](README.md#usecanvas-boolean) property to disable rendering to the canvas - thanks **@davay42** for [suggesting this feature](https://github.com/hvianna/audioMotion-analyzer/issues/19);
37
- + A tool to view/debug the generated octave bands - see the `/tools` folder.
38
-
39
- ### Improved: <!-- {docsify-ignore} -->
40
-
41
- + Fine-tuned generation of octave bands;
42
- + Improved FFT data interpolation;
43
- + Improved peak rendering when changing visualization modes;
44
- + Added a simple piano keyboard to the test tones section of the "fluid" demo;
45
- + Added search funcionality to the documentation website.
46
-
47
-
48
- ## version 3.4.0 (2021-05-29)
49
-
50
- ### Added: <!-- {docsify-ignore} -->
51
-
52
- + [`fsElement`](README.md#fselement-htmlelement-object) constructor option, for easily handling fullscreen on any element.
53
-
54
- ### Fixed and improved: <!-- {docsify-ignore} -->
55
-
56
- + Fixed radial analyzer too wide in vertical containers;
57
- + Fixed out of bounds bar in mode 0 (discrete frequencies) with `mirror` set to -1;
58
- + Improved fullscreen rendering in portrait orientation displays;
59
- + Improved font size adjustment for scale labels and FPS display on vertical containers.
60
-
61
-
62
- ## version 3.3.0 (2021-05-03)
63
-
64
- ### Added: <!-- {docsify-ignore} -->
65
-
66
- + New horizontal mirroring effect; see [`mirror`](README.md#mirror-number) property - thanks **@lexterror** for [suggesting this feature](https://github.com/hvianna/audioMotion-analyzer/issues/16).
67
-
68
- ### Improvements: <!-- {docsify-ignore} -->
69
-
70
- + `colorStops` type definition updated for improved compatibility ([see #17](https://github.com/hvianna/audioMotion-analyzer/pull/17)) - props to [@Staijn1](https://github.com/Staijn1).
71
-
72
-
73
- ## version 3.2.1 (2021-04-03)
74
-
75
- + Fixes an undefined property error.
76
-
77
-
78
- ## version 3.2.0 (2021-04-03)
79
-
80
- ### Added: <!-- {docsify-ignore} -->
81
-
82
- + [`getEnergy()`](README.md#getenergy-preset-startfreq-endfreq-) method - see it in action on [this pen](https://codepen.io/hvianna/pen/poNmVYo) - thanks **@Staijn1** for [suggesting this feature](https://github.com/hvianna/audioMotion.js/issues/12#issuecomment-733045035);
83
- + [`setLedParams()`](README.md#setledparams-params-) method, which allows you to customize the look of the LEDs - you can try it in the [fluid demo](https://audiomotion.dev/demo/fluid.html);
84
- + [`connectSpeakers`](README.md#connectspeakers-boolean) constructor option - thanks **@evoyy** for the [suggestion](https://github.com/hvianna/audioMotion-analyzer/issues/13);
85
- + [`connectedTo`](README.md#connectedto-array-read-only) read only property.
86
-
87
- ### Improvements: <!-- {docsify-ignore} -->
88
-
89
- + When passing an AudioNode in the `source` property of constructor, it's no longer necessary to explicitly provide the `audioCtx`, as it will be inferred from the source node - thanks [@evoyy](https://github.com/evoyy) for this idea;
90
- + Disconnecting the output from the speakers no longer prevents the analyzer from working on Chromium-based browsers;
91
- + Expose the `GradientOptions` TypeScript interface for user scripts (props to [@Staijn1](https://github.com/Staijn1));
92
- + Improved the look of the LEDs effect in very small containers (like in the [multi-instance demo](https://audiomotion.dev/demo/multi.html)), especially when `loRes` is active;
93
- + Refactored some code for improved legibility, performance and file size (still below 20kB minified! :sunglasses:);
94
- + Added compatibility with *standardized-audio-context* library - thanks [@richclingman](https://github.com/richclingman) for reporting this issue.
95
-
96
- ### Changed: <!-- {docsify-ignore} -->
97
-
98
- + `energy` and `peakEnergy` properties have been **deprecated and will be removed in the next major release** - use `getEnergy()` and `getEnergy('peak')` instead;
99
- + FPS display font size is now scaled relatively to the canvas height;
100
- + `pixelRatio` is now correctly reported for HiDPI devices with screen height <= 1080px.
101
-
102
-
103
- ## version 3.1.0 (2021-02-27)
104
-
105
- ### Added: <!-- {docsify-ignore} -->
106
-
107
- + TypeScript definition file (props to [@alex-greff](https://github.com/alex-greff)).
108
-
109
- ### Improvements: <!-- {docsify-ignore} -->
110
-
111
- + Generate only the currently selected gradient on mode/gradient changes.
112
-
113
-
114
- ## version 3.0.0 (2020-11-28)
115
-
116
- ### BREAKING CHANGES: <!-- {docsify-ignore} -->
117
-
118
- + The `analyzer` object is no longer exposed - use the new [`connectInput()`](README.md#connectinput-source-) method to connect all audio sources and [`connectOutput()`](README.md#connectoutput-node-) to connect the analyzer output to other nodes;
119
- + `audioSource` property has been renamed to [`connectedSources`](README.md#connectedsources-array), which now returns an **array** of all connected audio sources;
120
- + `binToFreq()` and `freqToBin()` methods have been removed;
121
- + `connectAudio()` method has been replaced by [`connectInput()`](README.md#connectinput-source-), which now accepts either an HTML media element or any instance of AudioNode;
122
- + `dataArray` property is no longer exposed;
123
- + `showScale` property has been renamed to [`showScaleX`](README.md#showscalex-boolean);
124
- + `version` is now a **static** property and should always be accessed as [`AudioMotionAnalyzer.version`](README.md#audiomotionanalyzerversion-string-read-only).
125
-
126
- ### New features: <!-- {docsify-ignore} -->
127
-
128
- + Dual channel (stereo) analyzer option;
129
- + Built-in volume control;
130
- + New methods for easy connection/disconnection of input and output nodes:
131
- + [`connectInput()`](README.md#connectinput-source-)
132
- + [`disconnectInput()`](README.md#disconnectinput-node-)
133
- + [`connectOutput()`](README.md#connectoutput-node-)
134
- + [`disconnectOutput()`](README.md#disconnectoutput-node-)
135
- + New properties:
136
- + [`isOctaveBands`](README.md#isoctavebands-boolean-read-only) (read only)
137
- + [`isLedDisplay`](README.md#isleddisplay-boolean-read-only) (read only)
138
- + [`isLumiBars`](README.md#islumibars-boolean-read-only) (read only)
139
- + [`stereo`](README.md#stereo-boolean)
140
- + [`splitGradient`](README.md#splitgradient-boolean)
141
- + [`volume`](README.md#volume-number)
142
-
143
- ### Improvements: <!-- {docsify-ignore} -->
144
-
145
- + Automatically unlock/resume the AudioContext on first user click, so you don't need to handle this in your code anymore;
146
- + Improved FFT data interpolation on low frequencies (especially noticeable in 1/12th and 1/24th octave bands);
147
- + Corrected initial amplitude of line / area graph.
148
-
149
- ### Fixed: <!-- {docsify-ignore} -->
150
-
151
- + A compatibility issue that could cause `reflexRatio` not to work in some environments.
152
-
153
-
154
- ## version 2.5.0 (2020-10-07)
155
-
156
- ### Improvements: <!-- {docsify-ignore} -->
157
-
158
- + Behavior of the [`onCanvasResize`](README.md#oncanvasresize-function) callback is now consistent across different browsers. Changes worth of note:
159
- 1. on fullscreen changes, **only a `'fschange'` *reason* will be reported** to the callback function - no more redundant `'resize'` calls;
160
- 2. the callback function is now executed **only when canvas dimensions effectively change** from the previous state - for example,
161
- setting [`loRes`](README.md#lores-boolean) or [`width`](README.md#width-number) to the same value they already have won't trigger a callback;
162
- + Canvas dimensions are now properly updated whenever the container element is resized, not only on window resize;
163
- + [`audioSource`](README.md#audiosource-mediaelementaudiosourcenode-object) now returns the first audio source connected via [`connectAudio()`](README.md#connectaudio-element-)
164
- method, if no source was provided during instantiation;
165
- + Size of scale labels on both axes is now scaled relatively to the canvas height;
166
- + Added a [new demo](https://audiomotion.dev/demo) with only the minimal code required to use audioMotion-analyzer;
167
- + Demo scripts are now loaded as native ES6 modules and no longer require bundling. See the [README file](demo/README.md) for instructions on running the demos locally.
168
-
169
-
170
- ## version 2.4.0 (2020-07-18)
171
-
172
- ### Added: <!-- {docsify-ignore} -->
173
-
174
- + New **Radial** visualization - see [`radial`](README.md#radial-boolean) and [`spinSpeed`](README.md#spinspeed-number) properties and try them in the [demos](https://audiomotion.dev/demo)! - thanks **@inglesuniversal** for [suggesting this feature](https://github.com/hvianna/audioMotion.js/issues/6);
175
- + [`showScaleY`](README.md#showscaley-boolean) property for displaying the level (dB) scale on the analyzer's vertical axis;
176
- + [`energy`](README.md#energy-number-read-only) and [`peakEnergy`](README.md#peakenergy-number-read-only) read-only properties;
177
- + [Known issues](README.md#known-issues) section added to the documentation.
178
-
179
- ### Changed: <!-- {docsify-ignore} -->
180
-
181
- + [`setOptions()`](README.md#setoptions-options-) called with no argument now **resets all configuration options to their default values** (it used to raise an error);
182
- + The LED effect code has been refactored to improve appearance and compatibility with other (future) effects;
183
- + "Unlit" LEDs are no longer displayed in **overlay mode** - see the notice in [`showBgColor`](README.md#showbgcolor-boolean) documentation;
184
- + Canvas `fillStyle` and `strokeStyle` properties are now set with the current gradient before calling the [`onCanvasDraw`](README.md#oncanvasdraw-function) callback function;
185
- + Updated all [demos](https://audiomotion.dev/demo) with more straightforward access to configuration options.
186
-
187
-
188
- ## version 2.3.0 (2020-06-08)
189
-
190
- ### Added: <!-- {docsify-ignore} -->
191
-
192
- + [`binToFreq()`](README.md#bintofreq-bin-) and [`freqToBin()`](README.md#freqtobin-frequency-rounding-) methods;
193
- + [`reflexBright`](README.md#reflexbright-number) property, which allows to adjust the brightness of the reflected image.
194
-
195
- ### Changed: <!-- {docsify-ignore} -->
196
-
197
- + Reverted the change to `reflexAlpha` introduced in [v2.2.1](https://github.com/hvianna/audioMotion-analyzer/releases/tag/2.2.1)
198
- + Removed the forced black layer off the reflection background.
199
-
200
-
201
- ## version 2.2.1 (2020-05-31)
202
-
203
- ### Changed: <!-- {docsify-ignore} -->
204
-
205
- + ~~Improved the Reflex effect in [`overlay`](README.md#overlay-boolean) mode - the [`reflexAlpha`](README.md#reflexalpha-number) property is
206
- now used to adjust the opacity of a dark layer applied *over* the reflection area, which prevents undesired transparency of the reflection itself
207
- and creates a consistent effect, whether overlay mode is on or off~~ **(reverted in v2.3.0)**;
208
-
209
- + The package source code has been moved from the `dist` to the `src` folder.
210
-
211
- ### Fixed: <!-- {docsify-ignore} -->
212
-
213
- + Prevent showing leds below the 0 level, when both reflex and overlay are active.
214
-
215
-
216
- ## version 2.2.0 (2020-05-19)
217
-
218
- ### Added: <!-- {docsify-ignore} -->
219
-
220
- + New [`overlay`](README.md#overlay-boolean) and [`bgAlpha`](README.md#bgalpha-number) properties allow displaying the analyzer over other contents.
221
- [Check out the new demo!](https://audiomotion.dev/demo/overlay.html)
222
-
223
- ### Changed: <!-- {docsify-ignore} -->
224
-
225
- + Corrected the documentation for the [`registerGradient()`](README.md#registergradient-name-options-) method, which stated the `bgColor` property was required (it has always been optional).
226
-
227
-
228
- ## version 2.1.0 (2020-04-06)
229
-
230
- ### Added: <!-- {docsify-ignore} -->
231
-
232
- + Customizable Reflex effect - see [`reflexRatio`](README.md#reflexratio-number) and try it in the [demo](https://audiomotion.dev/demo/fluid.html).
233
-
234
-
235
- ## version 2.0.0 (2020-03-24)
236
-
237
- ### Added: <!-- {docsify-ignore} -->
238
-
239
- + New [`lineWidth`](README.md#linewidth-number) and [`fillAlpha`](README.md#fillalpha-number) properties for [mode 10](README.md#mode-number) customization, so it can now work as an area graph (default), a line graph or a combination of both;
240
- + New [`barSpace`](README.md#barspace-number) property for customizable bar spacing in octave bands modes;
241
- + You can now provide an external AudioContext via `audioCtx` property in the [constructor's `options`](README.md#constructor), allowing you to share the same context among different instances;
242
- + Custom [error codes](README.md#custom-errors);
243
- + New [`version`](README.md#version-string-read-only) property;
244
-
245
- ### Changed: <!-- {docsify-ignore} -->
246
-
247
- + Increased default spacing between bars in octave bands modes - to get the previous look, set [`barSpace`](README.md#barspace-number) to **1**;
248
- + Improved accuracy when positioning the X-axis scale labels in octave bands modes;
249
- + Slightly improved vertical usage of canvas when the LED effect is active (removed the black line at the bottom of the screen);
250
- + Canvas context is now saved before calling the user callback function and restored afterwards, to avoid undesirable changes;
251
- + Several functions were refactored for improved legibility, memory usage and performance;
252
- + Improved documentation and demos;
253
-
254
- ### Fixed: <!-- {docsify-ignore} -->
255
-
256
- + The multi-instance demo should now work on browsers other than Firefox (it now uses a shared audio context);
257
- + `isFullscreen` property now correctly reads `false` (instead of `undefined`) when the analyzer is not in fullscreen (*potentially breaking change*);
258
- + Setting one of the callback functions to `undefined` with `setOptions()` now properly unregisters the callback (*potentially breaking change*);
259
-
260
- ### API breaking changes: <!-- {docsify-ignore} -->
261
-
262
- + `audioCtx`, `analyzer`, `canvas` and `canvasCtx` objects are now read-only (`canvasCtx` properties may be safely modified while inside the callback for `onCanvasDraw`);
263
- + `frame` and `time` properties are not exposed anymore, as they are intended for internal use only;
264
- + `registerGradient()` method now enforces the `name` argument being a non-empty `string` (throws an [error](README.md#custom-errors) otherwise);
265
- + Errors now return a custom object and some error messages have changed - use the new [`code` property](README.md#custom-errors) to identify errors in a reliable way.
266
-
267
-
268
- ## version 1.2.0 (2019-12-19)
269
-
270
- + Improves the look of bars at lower frequencies in octave bands modes (especially 1/12th and 1/24th);
271
- + Minor tweak to the "Rainbow" gradient to make cyan and blue shades a little more balanced.
272
-
273
-
274
- ## version 1.1.0 (2019-12-08)
275
-
276
- + New **Area fill** visualization mode (`mode: 10`), which uses the same full-frequency data of the *discrete frequencies* mode, but generates a brighter filled shape;
277
- + New **Luminance Bars** option (`lumiBars: <boolean>`) for octave bands modes, which displays analyzer bars always at full-height, with varying luminance instead.
278
-
279
-
280
- ## version 1.0.1 (2019-10-22)
281
-
282
- + Minor cleanup to optimize npm package size.
283
-
284
-
285
- ## version 1.0.0 (2019-10-07)
286
-
287
- + First stable release.
288
-
289
-
290
- ## version 1.0.0-rc.1 (2019-10-05)
291
-
292
- + Release candidate for v1.0.0