🎧 audio-visualization-toolkit
Lightweight and customizable audio visualization toolkit build up on web audio api.
A thin wrapper of Audio Element and Web Audio API.
It currently uses canvas2D as the graphic engine, I will implement the ability to use Three.js later.
Demo: https://eggtronic.github.io/web-audio-visualization-tool/
✨ Features
- 🌈 Customizable - provides lifecycle hooks for audio visualization and interaction.
- 🛡 Modularity - use imagination to create your own audio visualization or audio player.
- 📦 Lightweight - only few lines of code.
- 🎨 Ready to go - there are some ready to use hooks implemented for you.
✨ Useful Libraries
- 🌈 web-audio-beat-detector - use it to detect BPM of the audio
🖥 Environment Support
- Currently only support the latest browsers such as Chrome, but will implement the support for more browers in the future.
Firefox |
Chrome |
---|---|
latest versions | latest versions |
🔨 Development
- Run
npm install
- Run
npm run build
to build- Run
npm run dev
for development
✨ Basic Usage
You can install it from npm (unstable)
`npm install --save audio-visualization-tool`
You can also get it from cdn in script tag
<script src='https://cdn.jsdelivr.net/npm/audio-visualization-tool@0.0.1/lib/index.js'></script>
In your html body you need create 2 canvas element and 1 audio element.
- Create an example.js file and copy the js code below into it. (you can also use your own name)
- You will need to reference 2 canvas element id and 1 audio element id to init the AudioVisualizer.
- (optional) You can reference your own canvases.
- You can reuse my example style for a better preview (it's in the index.html)
window;
🔨 Create Your Own Audio Visualization
editing...
🤝 Contributing
I haven't specified an contributing guide, but I welcome all contributions. If you have any questions or ideas just email me.
📝 Here is my todo list (** means on going)
- ** NPM upload + cdn
- ** multiple audio source support
- ** Refactor to TypeScript
- ** design object modal for elements on canvas
- an example of ripple class
- create super class for dynamic elements
- create super class for static elements
- interface for handling mouse events
- interface for handling key events
- ** hover event cursor management
- ** size - autofit container
- using rollup to pack the tool
- audio load on fly support
- add another layer of canvas for rendering static elements
- class implementation
- include canvas2d as render engine
- split the lifecycle into serveral stages
- Hooks for lifecycle stages:
- init stage
- on start stage
- on pause stage
- on resume stage
- on end stage
- on volume change
- render frame stage
- add async loader for static rendering
- add some ready to use renderers (hooks)
- rounded frequency visualization
- time visualization
- progress visualization
- draggable seeking bar
- background_image
- volume control
- start/pause control
- next/previous song button
- Compatibility across different browsers
- adding ability to support Three.js
- typescript support