Code Monkey home page Code Monkey logo

vudio's Introduction

vudio license

Visualization audio using AudioContext and Canvas

Inspired and based on https://github.com/margox/vudio.js.git

Many visual effect:

多種視覺效果


Features:

  • Support effect and custom styles
  • Animation based on Canvas and requestAnimationFrame

Install and use

npm i vudio --save
# or install by yarn
yarn add vudio
import Vudio from 'vudio'

using CDN:

<script src="https://unpkg.com/[email protected]/umd/vudio.js"></script>

Use Vudio

var vudio = new Vudio(HTMLAudioElement | MediaStream, HTMLCanvasElement, [option]);
vudio.dance();

Examples

<canvas width="256px" height="100px" id="canvas"></canvas>
<audio src="./path/to/audio.mp3" controls id="audio"></audio>
<script src="path/to/vudio.js"></script>

Since AudioContext can NOT use CORS resource, so make sure you have fully control of audio resource

var audioObj = document.querySelector('#audio');
var canvasObj = document.querySelector('#canvas');
var vudio = new Vudio(audioObj, canvasObj, {
    effect : 'waveform', // waveform, circlewave, circlebar, lighting (4 visual effect)
    accuracy : 128, // number of freqBar, must be pow of 2.
    width : 256, // canvas width
    height : 100, // canvas height
    waveform : {
        maxHeight : 80, // max waveform bar height
        minHeight : 1, // min waveform bar height
        spacing: 1, // space between bars
        color : '#f00', // string | [string] color or waveform bars
        shadowBlur : 0, // blur of bars
        shadowColor : '#f00', 
        fadeSide : true, // fading tail
        horizontalAlign : 'center', // left/center/right, only effective in 'waveform'/'lighting'
        verticalAlign: 'middle' // top/middle/bottom, only effective in 'waveform'/'lighting'
    }
});

vudio.dance();

// pause as you wish
vudio.pause();

// change option reactively.
vudio.setOption({
    waveform : {
        color : '#06f',
        verticalAlign: 'bottom'
    }
});

Online Demo: https://alex2wong.github.io/vudio/

Related VSC extension

vscode extension

Listen netease music and watch visualization in VSCode :) Install by vsix file https://github.com/alex2wong/vsc-netease-music/releases

related issue: nondanee/vsc-netease-music#63

vudio's People

Contributors

alex2wong avatar margox avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.