Giter Site home page Giter Site logo

imclab / gl-audio-analyser Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stackgl/gl-audio-analyser

0.0 1.0 0.0 86 KB

Pull audio waveform/frequency data into WebGL for realtime audio visualisation

Home Page: http://stack.gl/gl-audio-analyser

License: Other

GLSL 12.74% JavaScript 53.74% HTML 33.52%

gl-audio-analyser's Introduction

gl-audio-analyser

experimental

Pull audio waveform/frequency data into WebGL for realtime audio visualisation!

This is a wrapper around the more generic/flexible web-audio-analyser that makes it easier to just drop into a new WebGL project and get up and running quickly.

Browser Usage

NPM

You can pull gl-audio-analyser into your project using browserify.

See demo/index.js for a full usage example.

analyser = require('gl-audio-analyser')(gl, audio, [ctx])

Creates a new audio analyser given the following arguments:

  • gl is the WebGL context you want to use.
  • audio is an audio node to analyse, be that an <audio> tag, MediaStream or AudioSourceNode.
  • ctx is an (optional) AudioContext instance to use. Note however there may only be one instance of this per page, and if not supplied one will be created for you.

Once created, you should then bind the waveform and/or frequency textures once per frame:

analyser.bindWaveform([index])

Uploads the audio's waveform data to a specific texture index, which defaults to 0, returning the bound GL texture index.

analyser.bindFrequencies([index])

Uploads the audio's frequency data to a specific texture index, which defaults to 0, returning the bound GL texture index.

GLSL Usage

You can then read the audio data from a texture. For your convenience, this module can also be used with glslify, though the GLSL module source is relatively short.

See demo/index.frag for an example.

analyse(sampler2D texture, float audioIndex)

uniform sampler2D audioTexture;

#pragma glslify: analyse = require(gl-audio-analyser)

void main() {
  float amplitude = analyse(audioTexture);

  gl_FragColor = vec4(vec3(amplitude), 1.0);
}

Contributing

See stackgl/contributing for details.

License

MIT. See LICENSE.md for details.

gl-audio-analyser's People

Contributors

hughsk avatar mattdesl avatar

Watchers

 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.