I am trying to generate a tonal sound which changes in frequency and amplitude over time. The goal is to emulate an engine order during driving. So I don't know the frequencies and the amplitudes upfront. They depend on the driving situation. So far I managed to get it to work. However in the generated sound sometimes clicks occur. I think it happens when the amplitude changes too fast. As I can't control the amplitude I would like to know what I can do to prevent this clicking noise to happen?
Time are vectors with the engine speed and the corresponding time trace obviously.
In the following picture the blue curve is the generated sound pressure, while the red curve is the absolute value of the sound pressure and the green curve is the amplitude that I have to deal with. In black I have encircled where a step in sound pressure happens causing a clicking sound.
Any help is kindly appreciated!
Thank you for the good comments! k is an enumerator in case I want to emulate multiple Engine Orders. For this example k can be just 1. I think the hint to keep the argument between 0 and 2pi makes sense. Using cumtrapz is not good. I'll try to avoid that. Further I had the idea to smoothen the Amplitude with a lowpass filter. The lower the frequency I want to emulate the lower should be the stopband of that lowpass-filter. Steep changes in the amplitude combined with a low frequency lead to clicks I guess.