Created
October 5, 2013 02:20
-
-
Save arisetyo/6835810 to your computer and use it in GitHub Desktop.
Drawing a spectrum analyzer using Raphael.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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