Code Monkey home page Code Monkey logo

bars.js's Introduction

bars.js

A lightweight JavaScript library which handles all the audio processing for a web music visualiser.

It's called bars.js as the library converts audio into its frequency spectrum representation: This frequency spectrum representation is sampled at even intervals, which is displayed as bars in many music visualisers.

The MusicVisualiser object has a property called bars - this is an array of bar heights, which is the primary data source for creating a music visualisation.

Full documentation of the library can be found on the wiki of this GitHub repository.

It includes the following sections:

Example Use of bars.js

HTML

<audio controls id="audioElementId"></audio>

JavaScript

let mV = new MusicVisualiser();

mV.audioPlayer = "audioElementId"; // Specifying where the audio is coming from.
mV.soundFileURL = "music.ogg";
mV.numberOfBars = 128;

function playSoundFile() {
  mV.playSoundFileFromURL();
}

// Any function that is called every frame.
function animate() { 
  mV.updateVisualiser(); // Updates the contents of the bars array.
  
  for (let i = 0; i < mV.bars.length; i++) {
    drawBar(i, mV.bars[i], mV.bars.length); // The bars are drawn to the screen.           
  }
}

A live demo with interactive code can be found on CodePen.

bars.js's People

Contributors

jhancock532 avatar

Stargazers

 avatar

Watchers

 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.