Код: Выделить всё
Play
$(document).ready(function () {
$("#playIt").click(function () {
if (Tone.context.state != "running") {
Tone.start();
}
playNotes();
});
});
const player = new Tone.Player({
url: "/tick.mp3",
loop: true,
autostart: false
}).toDestination();
Tone.Transport.bpm.value = 140;
// Schedule the player to start at specific times
Tone.Transport.schedule(time => {
player.start(time);
}, "0:0:0"); // Play at the start
Tone.Transport.schedule(time => {
player.start(time);
}, "0:1:0"); // Play at 1st measure
Tone.Transport.schedule(time => {
player.start(time);
}, "0:4:0"); // Play at 4th measure
async function playNotes() {
Tone.Transport.start();
}
< /code>
Если я отключаю цикл, он играет один раз, правильно. Когда он зацикливается, он играет правильно один раз, а затем воспроизводит тон в каждой мере.
Спасибо за помощь!
Подробнее здесь: https://stackoverflow.com/questions/794 ... -intervals