Closed mohammadalmalt closed 4 years ago
Use https://jsbin.com/?html to create working code. Place link to your code here.
Hello,
Here is the code: https://jsbin.com/zizovex/edit?html
read wiki at https://github.com/surikov/webaudiofont/wiki/2.1.-queueWaveTable fixed code
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src='https://surikov.github.io/webaudiofont/npm/dist/WebAudioFontPlayer.js'></script>
<script src='https://surikov.github.io/webaudiofontdata/sound/0000_Chaos_sf2_file.js'></script>
<script>
var instr = _tone_0000_Chaos_sf2_file;
var AudioContextFunc = window.AudioContext || window.webkitAudioContext;
var audioContext = new AudioContextFunc();
var player = new WebAudioFontPlayer();
player.loader.decodeAfterLoading(audioContext, '_tone_0000_Chaos_sf2_file');
var interval;
function playmulti(octave, notes, duration) {
var startTime=audioContext.currentTime+0.1;
for (let i = 0; i < notes.length; i++) {
player.queueWaveTable(audioContext, audioContext.destination
, instr, startTime+i/2, 12 * octave + notes[i], duration);
interval = setInterval(function () {
console.log("waiting");
clearInterval(interval);
}, duration);
}
return false;
}
</script>
</head>
<body>
<p><a href="#" onmousedown="playmulti(4, [0,4,7], 1);">Play three notes</a></p>
</body>
</html>
большое спасибо. я твой должник
Hello, I have written a function to play an array of notes, for example: [0, 4, 7] , and i added an interval but i seem to don't understand how to make a pause between the notes. All three notes get played at the same time, like a chord. I would appreciate any hint to point me in the right direction.
function playmulti(octave, notes, duration) { for (let i = 0; i < notes.length; i++) {
}