Currently, I am building a project that involves playing a MIDI, showing the animation of the piano alongside the metronome. I found that there are some synchronization issues if I use Tone.Transport.scheduleOnce. Specifically:
If I use synth.triggerAttackRelease(note.name, note.duration, note.time + now, note.velocity) to play a series of notes start from now, they will be played on time.
In my project, I would like to show some animation (e.g. highlight piano key) when playing the note. I implement that via:
Tone.Transport.scheduleOnce(time => { myAnimationCode() }, now + note.time);
However, I found that there would be a ~0.1 second of delay for Tone.Transport.scheduleOnce. That is, it will be triggered later than the designated time.
The effect in 2# is more obvious if I use Tone.Transport.scheduleOnce to play a note:
Tone.Transport.scheduleOnce(time => { synth.triggerAttackRelease(note.name, note.duration, time, note.velocity); }, now + note.time);
I would like to know then what is the right way to run some code that is synchronized to synth.triggerAttackRelease? Many thanks in advance!
Hi,
First, thanks for much for the great library!
Currently, I am building a project that involves playing a MIDI, showing the animation of the piano alongside the metronome. I found that there are some synchronization issues if I use
Tone.Transport.scheduleOnce
. Specifically:synth.triggerAttackRelease(note.name, note.duration, note.time + now, note.velocity)
to play a series of notes start fromnow
, they will be played on time.Tone.Transport.scheduleOnce(time => { myAnimationCode() }, now + note.time);
However, I found that there would be a ~0.1 second of delay for
Tone.Transport.scheduleOnce
. That is, it will be triggered later than the designated time.Tone.Transport.scheduleOnce
to play a note:Tone.Transport.scheduleOnce(time => { synth.triggerAttackRelease(note.name, note.duration, time, note.velocity); }, now + note.time);
I would like to know then what is the right way to run some code that is synchronized to synth.triggerAttackRelease? Many thanks in advance!