Code Monkey home page Code Monkey logo

noise.js's Introduction

noise.js

noise.js is a library that provides noise generators for the Web Audio API. Currently, noise.js provides generators for white noise, pink noise, and brown noise.

Read the post on Noisehack for details and a simple demo.

Here's a more advanced demo demonstrating both noise modulating oscillators and oscillators modulating noise.

Usage

White Noise

Create a white noise generator and route it to the output:

var context = new webkitAudioContext();
var whiteNoise = context.createWhiteNoise();
whiteNoise.connect(context.destination);

Pink Noise

Create a pink noise generator and route it to the output:

var context = new webkitAudioContext();
var pinkNoise = context.createPinkNoise();
pinkNoise.connect(context.destination);

Modulate a sawtooth oscillator with filtered pink noise:

var context = new webkitAudioContext();
var pinkNoise = context.createPinkNoise();
var pinkGain = context.createGainNode();
var pinkFilter = context.createBiquadFilter();
pinkGain.gain.value = 100;
pinkFilter.frequency.value = 1.618;
pinkNoise.connect(pinkFilter);
pinkFilter.connect(pinkGain);

var saw = context.createOscillator();
saw.type = saw.SAWTOOTH;
saw.frequency.value = 440.0;
var sawGain = context.createGainNode();
sawGain.gain.value = 0.3;

saw.start(0);
saw.connect(sawGain);
pinkGain.connect(saw.frequency);
sawGain.connect(context.destination);

Brown Noise

Create a brown noise generator and route it to the output:

var context = new webkitAudioContext();
var brownNoise = context.createBrownNoise();
brownNoise.connect(context.destination);

Modulate the brown noise amplitude to simulate the sound of the ocean:

var context = new webkitAudioContext();
var brownNoise = context.createBrownNoise();
var brownGain = context.createGainNode();
brownGain.gain.value = 0.3;
brownNoise.connect(brownGain);

var lfo = context.createOscillator();
lfo.frequency.value = 0.1;
var lfoGain = context.createGainNode();
lfoGain.gain.value = 0.1;

lfo.start(0);
lfo.connect(lfoGain);
lfoGain.connect(brownGain.gain);
brownGain.connect(context.destination);

noise.js's People

Contributors

zacharydenton 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.