magneto538
Product Engineer
Hello folks,
This is a math-related question.
I am using the majestic new Math features in Kontakt 5.6.5. Basically I am building an LFO using the script (so without the LFO module, which - for a number of reasons - is not an option in this case). I am using the sin() function to generate the wave - I am using the wave formula sin(2π*freq*time + phase) to accomplish this. This function is placed in the listener callback, so that a continuous sine wave is generated.
The sine wave is generated correctly. The problem occurs when I change the frequency of the wave with a slider: when the slider is moving, the value of the wave is forced to the current time, therefore clipping occurs. This happens because at a given time t the value of sin() is different for each frequency.
So I have a bunch of options here. The idea I had was to apply a phase shift in order to match the correct value of sin(), which means that when I am changing the frequency, the phase of the new wave is shifted so that at time t the value of sin() remains the same (which is the whole point of it actually). I am not sure how to accomplish this though.
I think that what I'm looking for is some kind of a 'smoothing' function. How can I accomplish this?
EDIT: attached is a GIF of the issue. When you see the weird stuff going on on the oscilloscope, that's when I am changing the frequency.
This is a math-related question.
I am using the majestic new Math features in Kontakt 5.6.5. Basically I am building an LFO using the script (so without the LFO module, which - for a number of reasons - is not an option in this case). I am using the sin() function to generate the wave - I am using the wave formula sin(2π*freq*time + phase) to accomplish this. This function is placed in the listener callback, so that a continuous sine wave is generated.
The sine wave is generated correctly. The problem occurs when I change the frequency of the wave with a slider: when the slider is moving, the value of the wave is forced to the current time, therefore clipping occurs. This happens because at a given time t the value of sin() is different for each frequency.
So I have a bunch of options here. The idea I had was to apply a phase shift in order to match the correct value of sin(), which means that when I am changing the frequency, the phase of the new wave is shifted so that at time t the value of sin() remains the same (which is the whole point of it actually). I am not sure how to accomplish this though.
I think that what I'm looking for is some kind of a 'smoothing' function. How can I accomplish this?
EDIT: attached is a GIF of the issue. When you see the weird stuff going on on the oscilloscope, that's when I am changing the frequency.