Skip to content

Instantly share code, notes, and snippets.

@arisetyo
Created October 5, 2013 02:20
Show Gist options
  • Select an option

  • Save arisetyo/6835810 to your computer and use it in GitHub Desktop.

Select an option

Save arisetyo/6835810 to your computer and use it in GitHub Desktop.
Drawing a spectrum analyzer using Raphael.js
function drawSpectrum() {
//RESET
paper.clear();
var array = new Uint8Array(analyser.frequencyBinCount);
analyser.getByteFrequencyData(array);
audioAnimation = requestAnimationFrame(drawSpectrum);
var SPECTRUMLine = "";
for ( var i = 0; i < (array.length); i++ ){
SPECTRUMLine += " L"+(i+1)+" "+(100+(200-array[i]))/2+" ";
}
var line = paper.path("M0 150 "+SPECTRUMLine+" L256 150");
line.attr({
'stroke-dasharray': ["-"],
stroke: '#333333',
'stroke-width': 1
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment