audiomotion-analyzer 4.5.0-beta.0 → 4.5.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/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  **audioMotion-analyzer** is a high-resolution real-time audio spectrum analyzer built upon **Web Audio** and **Canvas** JavaScript APIs.
5
5
 
6
- It was originally conceived as part of my full-featured music player called [**audioMotion**](https://audiomotion.me), but I later decided
6
+ It was originally conceived as part of my full-featured media player called [**audioMotion**](https://audiomotion.app), but I later decided
7
7
  to make the spectrum analyzer available as a self-contained module, so other developers could use it in their own JS projects.
8
8
 
9
9
  My goal is to make this the best looking, most accurate and customizable spectrum analyzer around, in a small-footprint and high-performance package.
@@ -35,7 +35,7 @@ What users are saying:
35
35
  + Additional effects: LED bars, luminance bars, mirroring and reflection, radial spectrum
36
36
  + Choose from 5 built-in color gradients or easily add your own!
37
37
  + Fullscreen support, ready for retina / HiDPI displays
38
- + Zero-dependency native ES6+ module (ESM), \~25kB minified
38
+ + Zero-dependency native ES6+ module (ESM), \~30kB minified
39
39
 
40
40
  ## Online demos
41
41
 
@@ -57,7 +57,27 @@ What users are saying:
57
57
 
58
58
  ## Usage
59
59
 
60
- ### Native ES6 module (ESM)
60
+ ### Node.js project
61
+
62
+ Install via npm:
63
+
64
+ ```console
65
+ npm i audiomotion-analyzer
66
+ ```
67
+
68
+ Use ES6 import:
69
+
70
+ ```js
71
+ import AudioMotionAnalyzer from 'audiomotion-analyzer';
72
+ ```
73
+
74
+ Or CommonJS require:
75
+
76
+ ```js
77
+ const { AudioMotionAnalyzer } = require('audioMotion-analyzer');
78
+ ```
79
+
80
+ ### In the browser using native ES6 module (ESM)
61
81
 
62
82
  Load from Skypack CDN:
63
83
 
@@ -70,19 +90,17 @@ Load from Skypack CDN:
70
90
 
71
91
  Or download the [latest version](https://github.com/hvianna/audioMotion-analyzer/releases) and copy the `audioMotion-analyzer.js` file from the `src/` folder into your project folder.
72
92
 
73
- ### npm project
93
+ ### In the browser using global variable
74
94
 
75
- Install as a dependency:
95
+ Load from Unpkg CDN:
76
96
 
77
- ```console
78
- $ npm i audiomotion-analyzer
97
+ ```html
98
+ <script src="https://unpkg.com/audiomotion-analyzer/dist"></script>
99
+ <script>
100
+ // available as AudioMotionAnalyzer global
101
+ </script>
79
102
  ```
80
103
 
81
- Use ES6 import syntax:
82
-
83
- ```js
84
- import AudioMotionAnalyzer from 'audiomotion-analyzer';
85
- ```
86
104
 
87
105
  ## Constructor
88
106
 
@@ -133,6 +151,7 @@ options = {<br>
133
151
  &emsp;&emsp;[channelLayout](#channellayout-string): **'single'**,<br>
134
152
  &emsp;&emsp;[colorMode](#colormode-string): **'gradient'**,<br>
135
153
  &emsp;&emsp;[connectSpeakers](#connectspeakers-boolean): **true**, // constructor only<br>
154
+ &emsp;&emsp;[fadePeaks](#fadepeaks-boolean): **false**,<br>
136
155
  &emsp;&emsp;[fftSize](#fftsize-number): **8192**,<br>
137
156
  &emsp;&emsp;[fillAlpha](#fillalpha-number): **1**,<br>
138
157
  &emsp;&emsp;[frequencyScale](#frequencyscale-string): **'log'**,<br>
@@ -140,7 +159,7 @@ options = {<br>
140
159
  &emsp;&emsp;[gradient](#gradient-string): **'classic'**,<br>
141
160
  &emsp;&emsp;[gradientLeft](#gradientleft-string): *undefined*,<br>
142
161
  &emsp;&emsp;[gradientRight](#gradientright-string): *undefined*,<br>
143
- &emsp;&emsp;[gravity](#gravity-number): **1**,<br>
162
+ &emsp;&emsp;[gravity](#gravity-number): **3.8**,<br>
144
163
  &emsp;&emsp;[height](#height-number): *undefined*,<br>
145
164
  &emsp;&emsp;[ledBars](#ledbars-boolean): **false**,<br>
146
165
  &emsp;&emsp;[linearAmplitude](#linearamplitude-boolean): **false**,<br>
@@ -160,6 +179,8 @@ options = {<br>
160
179
  &emsp;&emsp;[onCanvasResize](#oncanvasresize-function): *undefined*,<br>
161
180
  &emsp;&emsp;[outlineBars](#outlinebars-boolean): **false**,<br>
162
181
  &emsp;&emsp;[overlay](#overlay-boolean): **false**,<br>
182
+ &emsp;&emsp;[peakFadeTime](#peakfadetime-number): **750**,<br>
183
+ &emsp;&emsp;[peakHoldTime](#peakholdtime-number): **500**,<br>
163
184
  &emsp;&emsp;[peakLine](#peakline-boolean): **false**,<br>
164
185
  &emsp;&emsp;[radial](#radial-boolean): **false**,<br>
165
186
  &emsp;&emsp;[radialInvert](#radialinvert-boolean): **false**,<br>
@@ -401,6 +422,18 @@ By default, **audioMotion-analyzer** is connected to the *AudioContext* `destina
401
422
 
402
423
  See also [`connectOutput()`](#connectoutput-node-).
403
424
 
425
+ ### `fadePeaks` *boolean*
426
+
427
+ *Available since v4.5.0*
428
+
429
+ When *true*, peaks fade out instead of falling down. It has no effect when [`peakLine`](#peakline-boolean) is active.
430
+
431
+ Fade time can be customized via [`peakFadeTime`](#peakfadetime-number).
432
+
433
+ See also [`peakHoldTime`](#peakholdtime-number) and [`showPeaks`](#showpeaks-boolean).
434
+
435
+ Defaults to **false**.
436
+
404
437
  ### `fftSize` *number*
405
438
 
406
439
  Number of samples used for the FFT performed by the [*AnalyzerNode*](https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode).
@@ -503,11 +536,17 @@ See also [`gradient`](#gradient-string) and [`splitGradient`](#splitgradient-boo
503
536
 
504
537
  *Available since v4.5.0*
505
538
 
506
- Controls the acceleration of [peaks](#showpeaks-boolean) falling down.
539
+ Customize the acceleration of falling peaks.
507
540
 
508
- It must be a number greater than zero. Invalid values are ignored and no error is thrown.
541
+ It must be a number **greater than zero,** representing _thousands of pixels per second squared_. Invalid values are ignored and no error is thrown.
509
542
 
510
- Defaults to **1**.
543
+ With the default value and analyzer height of 1080px, a peak at maximum amplitude takes approximately 750ms to fall to zero.
544
+
545
+ You can use the [peak drop analysis tool](/tools/peak-drop.html) to see the decay curve for different values of gravity.
546
+
547
+ See also [`peakHoldTime`](#peakholdtime-number) and [`showPeaks`](#showpeaks-boolean).
548
+
549
+ Defaults to **3.8**.
511
550
 
512
551
  ### `height` *number*
513
552
  ### `width` *number*
@@ -779,6 +818,30 @@ Defaults to **false**.
779
818
 
780
819
  ?> In order to keep elements other than the canvas visible in fullscreen, you'll need to set the [`fsElement`](#fselement-htmlelement-object) property in the [constructor](#constructor) options.
781
820
 
821
+ ### `peakFadeTime` *number*
822
+
823
+ *Available since v4.5.0*
824
+
825
+ Time in milliseconds for peaks to completely fade out, when [`fadePeaks`](#fadepeaks-boolean) is active.
826
+
827
+ It must be a number greater than or equal to zero. Invalid values are ignored and no error is thrown.
828
+
829
+ See also [`peakHoldTime`](#peakholdtime-number) and [`showPeaks`](#showpeaks-boolean).
830
+
831
+ Defaults to **750**.
832
+
833
+ ### `peakHoldTime` *number*
834
+
835
+ *Available since v4.5.0*
836
+
837
+ Time in milliseconds for peaks to hold their value before they begin to fall or fade.
838
+
839
+ It must be a number greater than or equal to zero. Invalid values are ignored and no error is thrown.
840
+
841
+ See also [`fadePeaks`](#fadepeaks-boolean), [`gravity`](#gravity-number), [`peakFadeTime`](#peakfadetime-number) and [`showPeaks`](#showpeaks-boolean).
842
+
843
+ Defaults to **500**.
844
+
782
845
  ### `peakLine` *boolean*
783
846
 
784
847
  *Available since v4.2.0*
@@ -919,7 +982,7 @@ and setting `showBgColor` to ***true*** will make the "unlit" LEDs visible inste
919
982
 
920
983
  *true* to show amplitude peaks.
921
984
 
922
- See also [`gravity`](#gravity-number) and [`peakLine`](#peakline-boolean).
985
+ See also [`gravity`](#gravity-number), [`peakFadeTime`](#peakfadetime-number), [`peakHoldTime`](#peakholdtime-number) and [`peakLine`](#peakline-boolean).
923
986
 
924
987
  Defaults to **true**.
925
988