I'm trying to make a little script that will transform my text into morse, I've been able to do that pretty easily, however I'm trying to play the sounds but they are all stack up. I've been trying with addEventListener, but it is only working with the second sound and all the other one are getting "stacked". It is a little bit hard to explain, but how to make a sort of "queue" of sounds that are going to be played one after the other?
At this function, I'm getting the code in morse (eg: **** * *-** *-** ---), and it is reading the morse to make the sounds, but like I said, it is all "stacked".
function readMorse(){
traductionWord();
var int_position_morse;
int_position_morse = 0;
while (strCodeMorse.charAt(int_position_morse) != ""){
if (strCodeMorse.charAt(int_position_morse) == "*"){
playShortSnd();
int_position_morse++;
}
if (strCodeMorse.charAt(int_position_morse) == "-"){
playLongSnd();
int_position_morse++;
}
if (strCodeMorse.charAt(int_position_morse) == " "){
int_position_morse++;
}
}`
Sorry if it a bit unclear.
Thanks