Skip to content

Sambego/oscilloscope.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

13 Commits

Repository files navigation

oscilloscope.js

A small javascript plugin to create an oscilloscope of an audio-context. You can see an example here

Install

bower install oscilloscope.js 

Basic setup

// Create an audio-contextvaraudioContext=newwindow.AudioContext(),oscillator=audioContext.createOscillator();oscillator.type='sine';oscillator.frequency.value=400;oscillator.start();// Create an Oscilloscope instance// Parameters:// - The container in which the oschilloscope gets created// - an optional audio-context on which the oscilloscope creates an analyser-node,// and can connect to the destination.// If no audio-context is specified, a new one will be created created.varoscilloscope=newOscilloscope('.js-oscilloscope',audioContext);// Connect the oscillator-node to the oscilloscopeoscillator.connect(oscilloscope.analyserNode);// Start the oscilloscopeoscilloscope.start();

API

Properties

Oscilloscope.target// ContainerOscilloscope.width// The oscilloscope' widthOscilloscope.height// The oscilloscope' heightOscilloscope.svg// The svg-element in which we draw the oscilloscopeOscilloscope.wave// The path svg-element which represents the audio waveOscilloscope.audioContext// The oscilloscope' audio-contextOscilloscope.running// Indicates if the oscilloscope is runningOscilloscope.hasAudio// Indicates if the oscilloscope is connected to the audio-context' destination

Methods

/** * Start the oscilloscope */Oscilloscope.start();/** * Stop the oscilloscope */Oscilloscope.stop();/** * Connect the analyser-node to another audio-node * @param{audioNode} node An audio-node to connect to */Oscilloscope.connect(audioNode);/** * Connect the analyser-node to the audio-context' destination */Oscilloscope.toggleAudio();

License

Oscilloscope.js is licensed under the MIT license.

About

A small javascript plugin to create an oscilloscope of an audio-context

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published