Tonejs / Tone.js

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

Various Tone.LFO issues #1220

Open tmhglnd opened 7 months ago

tmhglnd commented 7 months ago

Hi!

I'm using Tone.LFO() to modulate amplitude of a synth. When I use the sinewave at for example quarter notes, the frequency is correct, but the waveshape is not in sync (the phase is wrong, it looks about 90º off). I've tried setting the phase = 90 but this results in unexpected behaviour (please see the image below from a scope view in Max, looking at the sound coming directly from the browser via Loopback, the right output is a hihat sample using Tone.Loop() at quarter notes, the left is a synth with Tone.LFO() also at quarter notes). Because I think changing the phase actually doesn't wrap the phase so I lose a part from the waveform (see images below).

Screenshot 2023-12-10 at 14 29 20

Phase moved by phase = 90:

Screenshot 2023-12-10 at 14 47 07

Phase moved by phase = -90:

Screenshot 2023-12-10 at 14 48 18

When I change the LFO to use a squarewave with this._lfo.set({ type: 'square' }); the phase is actually correct! But the squarewave has another issue, it is not completely silence (so it's not going from 0 to 1) resulting in the synth still sounding a bit softly in the middle parts.

Screenshot 2023-12-10 at 14 35 56

Using a sawtooth LFO the phase is again off, but this time it looks to be off by 180º

Screenshot 2023-12-10 at 14 38 36

Is there anything that can be done to fix these phase offsetting issues? It would be great if the phases would be the same for every wavetype that can be selected. And if the squarewave can be silenced in the middle part. Thanks in advance for the help!