1.1.0 • Published 3 years ago

react-music-visualizer v1.1.0

Weekly downloads
33
License
MIT
Repository
github
Last release
3 years ago

React Music Visualizer

The intentions of this project is to expose a basic and flexible waveform audio/music visualizer as a modern functional react component. A resizable <Canvas /> component is also exposed.

Installation

npm install react-music-visualizer --save

The library is built using hooks so you will need to have react and react-dom version 16.8 or higher.

Usage

<Visualizer audioPreviewUrl='example.com/audio-url' />

Example

More examples on how to use the component can be found in the repo example page. You can run the example page locally by first running npm install and then npm run dev.

Visualizer Props

PropTypeDefaultNotes
audioPreviewUrlStringnull---
canvasWidthNumbernullWill resize when viewport is below this number
canvasHeightNumber540---
drawFuncFunctionnull---
drawOptionsObjectSee below---
fftSizeNumber128For an explanation check MDN

Default Drawing Options

OptionTypeDefaultNotes
canvasColorString'#000000'Background color
lineColorString'#7200ab'Color of drawn lines
lineAmountNumber16Amount of lines to sequentially draw
strokeWidthNumber3Width of each line
strokeTightnessNumber5Space between each line
mirroredBooleantrueIf visual peak is centered

Canvas Props

PropTypeDefaultNotes
heightNumbernull---
maxWidthNumber3840---
classNameStringnull---
...propsAnynullAny HTML canvas properties