Skip to content

Instantly share code, notes, and snippets.

@Breefield
Created September 14, 2012 07:30
Show Gist options
  • Save Breefield/3720519 to your computer and use it in GitHub Desktop.
Save Breefield/3720519 to your computer and use it in GitHub Desktop.
soundmanager
soundManager.onready(function() {
hyperlips = soundManager.createSound({
id: 'hyperlips',
url: 'cathode_girls.mp3',
autoPlay: true,
volume: 50,
whileplaying: function() {
this.waveform = {points: [], total: 0};
var points = this.waveform.points;
for(var i = 0; i < 256; i++) {
var bucket = Math.round(i / 2);
var level = this.waveformData.left[i] / 2;
this.waveform.total += Math.abs(level);
points[bucket] = (typeof points[bucket] == 'undefined') ? level : points[bucket] + level;
}
this.waveform.total /= 256;
this.waveform.delta = Math.abs(this.waveform.prior - this.waveform.total);
this.waveform.prior = this.waveform.total;
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment