Tone.js: Starting transport with two synced Players starts them at the wrong time.

This might just be not understanding how Transports work, but I read the manual and the wiki (and a couple of bug reports here) and there’s nothing that makes me think I’m doing it wrong. If I am, sorry 😃

I have a Codesandbox to repro the code here.

What I’m trying to do is: having 2 Players, I want to schedule them (in TransportTime) within the Transport, then start the Transport at some point in time. I expect that, if I sync() the two Players, start() them with a startTime argument and finally start the Transport, they should be playing at their respectively correct startTime after I started the Transport. In other words, if I do:

    player1
      .toMaster()
      .sync()
      .start(1.555)

    player2
      .toMaster()
      .sync()
      .start(4.1)

    Tone.Transport.start("+0")

I expect player1 to play 1.555 seconds after the Transport is started, and player2 to play 4.1 seconds after the transport is started. For simplicity’s sake, in the example I start the Transport immediately (in Context time), but if I started it in +1 seconds, I’d expect to hear player1 2.555 seconds later and player2 5.1 seconds later.

What I hear, instead, are the two players starting at the same time, after some 12 - 13 seconds (again, see the example project here).

Is that a bug or am I getting it completely wrong?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (7 by maintainers)

Commits related to this issue

Most upvoted comments

This is the line which caused the error. You were right that it was clamping to the currentTime in this scenario. and that bug only appeared on refresh since on refresh Chrome’s autoplay policy probably allows it to set the clock to running if the page refreshes and the AudioContext was already running

@tambien - timing seems solid now. Many thanks again!

Late here and I’m afk already (typing from mobile), but will try first thing in the morning and confirm. Thanks!