Last active
May 24, 2016 12:11
-
-
Save florianboudot/f236036caef0260513ba to your computer and use it in GitHub Desktop.
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
var updateVuMeter = function (peak_data, $elements, old_leds_total) { | |
var leds_total = Math.ceil((peak_data / 20) * 1.7); // between 1 and 5 | |
var is_going_up = leds_total > old_leds_total; | |
var start_led = is_going_up ? old_leds_total : leds_total; // default is 0 | |
var end_led = is_going_up ? leds_total : old_leds_total; | |
// lights on or off the leds | |
for (var i = start_led; i <= end_led; i++) { | |
$elements.eq(i)[is_going_up ? 'addClass' : 'removeClass']('active'); | |
} | |
// save old value | |
return leds_total; | |
}; | |
// et dans ma fonction qui tourne en meme temps que le son j'appelle comme ça : | |
var peak_data_left = parseInt(this.peakData.left * 100); | |
var peak_data_right = parseInt(this.peakData.right * 100); | |
save_peak_data_left = updateVuMeter(peak_data_left, $left_leds, save_peak_data_left); | |
save_peak_data_right = updateVuMeter(peak_data_right, $right_leds, save_peak_data_right); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment