Skip to content

tennisonchan/audio-visualizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Audio Visualizer

A plug-and-play audio visualizer

Frequency

Frequency

Wave

Wave

Usage

const visualizer = new AudioVisualizer('canvasId', {
  // optional
  type: 'wave',
  width: 700, height: 500,
  lineWidth: 2,
  backgroundColor: 'rgb(25, 25, 25)'
  strokeStyle: 'rgb(255, 255, 255)'
});

// Connect visualizer to an AnalyserNode which connected to the audio source
function getMediaStream (stream) {
  let source = audioContext.createMediaStreamSource(stream);
  let analyser = new AnalyserNode(audioContext);

  source.connect(analyser);
  visualizer.connect(analyser);
}