

with constant distance between neighbors you want to align objectsCount objects on the circular path In order to align objects on a circular path you need basic trigonometric functions (Cos & Sin are your friends!). This is still simple but a little more tricky. Making it more interesting – Radial Alignment In order to get things smoother I set the css transition property to 0.1s. A bar was a simple DOM node absolutely aligned on the bottom of the visualization area and as the frequencyData changed I updated the css height property of all nodes. I started with a barchart animation where each bar represented an index in the frequencyData array. There were a few entries that were always 0 – removing them would probably make sense for visual animation’s sake but we would loose information about the frequencies. I’ve tested multiple songs and noticed that the range of frequencyData is ⊂ ℕ – makes sense. render frame based on values in frequencyData Var frequencyData = new Uint8Array(equencyBinCount) Īnalyser.getByteFrequencyData(frequencyData) frequencyBinCount tells you how many values you'll receive from the analyser analyser.fftSize (for further infos read the spec) we have to connect the MediaElementSource with the analyser Var audioSrc = ctx.createMediaElementSource(audio) Var audio = document.getElementById('myAudio') Here’s how we get the data from the AnalyserNode Let’s see what we need to setup to get our data:Īt first we need to add an element to the document including the source path of the audio file we want to analyse/visualize. Read more about it in the w3c Web Audio Specs. The AnalyserNode will provide realtime frequency data for our visualization. We specifically need a thing called AnalyserNode. We’re lucky! Because Chrome’s Web Audio API has already support for various Web Audio features. Although the Math part was very easy here I really enjoyed understanding why things work the way they do.Īt first we need data to visualize. This experiment was particularily fun for me because it was the first time I was able to apply my knowledge from studying Mathematics. Although webgl or canvas2d looked very promising (and interesting, I’d love to learn more about webgl!) for such a task I decided to implement it with a DOM element renderer and animate with CSS transitions instead (but I’d love to port them in future). In this article I’ll explain what I did in order to build it. I recently got inspired by a beautiful youtube audio visualization and thought “Hey, why not create my own set of audio visualizations?”.Ĭheck out the Audio Visualizations! (Chrome only for now- sorry)
