Tonejs / Tone.js

A Web Audio framework for making interactive music in the browser.
https://tonejs.github.io
MIT License
13.52k stars 983 forks source link

Looping does not work properly #918

Closed y-71 closed 3 years ago

y-71 commented 3 years ago

Describe the bug

I wanted to create a metronome but there is a problem with the clock, it's not quite my tempo image it's buffering for a reason I ignore.

To Reproduce

a simulation on the sandbox

Expected behavior Play the metronome at the right tempo

What I've tried I've looked on a JQuery implementation on codepen and it worked fine

Additional context Add any other context about the problem here.

tambien commented 3 years ago

Make sure you pass in the time variable provided by the scheduling callback, otherwise the timing will be wonky

 const loopA = new Tone.Loop((time) => {
      // use the 'time' variable to schedule the event precisely. 
      synth.triggerAttackRelease("D4", "8n", time /* here */ );
    }, "1n").start(0);