Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
numBars = 73
bars = [0..numBars-1].map -> 0
getDisplayBars = (audioData)->
deltaT = audioData.length/numBars
bars[0] = audioData[0]
for barNum in [1..numBars-1]
timeIndex = barNum*deltaT
leftIndex = Math.floor timeIndex
rightIndex = Math.ceil timeIndex
leftWeight = timeIndex%1
rightWeight = 1-leftWeight
leftValue = audioData[leftIndex]
rightValue = audioData[rightIndex]
bars[barNum] = leftValue*leftWeight + rightValue*rightWeight
bars
# set audioData to an array of random values between -1 and 1
audioData = [0..99].map -> Math.random()*2-1
getDisplayBars audioData
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.