You need to use a recursive function instead of loop:
function playNotes(notes) {
var i = 0;
playNextNote();
function playNextNote() {
if (i < notes.length) {
var value = notes[i];
var audioElement = document.createElement('audio');
audioElement.setAttribute('src', './audio/'+value.value+'.ogg');
audioElement.play();
i++;
setTimeout(playNextNote, value.duration);
}
}
}
In this way, the next note isn't triggered to start playing until the current note has completed.