You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 soundArr = ['A.wav', 'B.wav', 'C.wav', 'D.wav']; //Array of all of our sound files
var tempNum = 0; //Temporary number that is just used to figure out where we are
var buttonPressTime = 0; //In seconds, start as zero. This would be replaced with how long it would actually take
var buttonPress = function(buttonPressTime) { //Declare a function--not run--that does the following with the input of buttonPressTime
if(buttonPressTime < 1 ) { //if the value of buttonPressTime is less than 1 (second)
playSound(soundArr[tempNum]);
tempNum = tempNum + 1; //Take the variable tempNum, and set it equal to tempNum + 1 (current value, but one higher);
} else if (buttonPressTime >= 1) { //This is greater than 1s
tempNum = 0; //set the temporary variable back to zero (restart)
}
}
while(tempNum < soundArr.length) { //while our tempNum value is less than the value of soundArr.length (in this case, soundArr.length = 4 because there are four elements)
buttonPress(buttonPressTime); //Run the function buttonPress with an input of the buttonPressTime