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

Quantization is converted to AudioContext time instead of TransportTime #401

Open ricardomatias opened 5 years ago

ricardomatias commented 5 years ago

Here's a fiddle showing the current behavior.

Related forum post.

jackschaedler commented 4 years ago

It looks like I'm encountering the same behavior here (funnily enough, given the forum post) updating learningmusic to work with the latest Tone release. Sequence expects the time parameter to start() to be in TransportTime, but the following calls all end up yielding time in the AudioContext timeline:

Tone.Time("@1m").toSeconds()
Tone.TransportTime("@1m").toSeconds()
Tone.Transport.toSeconds("@1m")

It seems sort of possible to work around this by subtracting the "drift" between the two timelines to get a reasonable time that aligns with the Transport:

let drift = Tone.now() - Tone.Transport.seconds.

I suppose the quantization example is working well because triggerAttack... expects time in relation to the AudioContext and not the Transport.