I'm working on a Teensy 4.1 project that generates sine audio over a PWM pin using the audio library. The project aims to send Morse code based on the status of an input pin, alongside other network-related functions.
Speed is crucial; the loop's primary function is to monitor the input pin's status and perform actions accordingly. The transition between the sine wave turning on and off can be as short as 30 ms. However, controlling this transition with the amplitude() function, as reported already, generates clicks.
The Envelope object is unsuitable because it introduces too much delay and exhibits some strange behavior, sometimes not controlling the sinewave at all.
I tried several settings unsuccessfully.
I have achieved better results by controlling the ON/OFF status using the frequency() function. To stop the wave, I use frequency(0.0), and to start it, I use frequency(MyFrequency).
I'm not sure if this is best practice, but it is working to some extent.
Max
Speed is crucial; the loop's primary function is to monitor the input pin's status and perform actions accordingly. The transition between the sine wave turning on and off can be as short as 30 ms. However, controlling this transition with the amplitude() function, as reported already, generates clicks.
The Envelope object is unsuitable because it introduces too much delay and exhibits some strange behavior, sometimes not controlling the sinewave at all.
I tried several settings unsuccessfully.
I have achieved better results by controlling the ON/OFF status using the frequency() function. To stop the wave, I use frequency(0.0), and to start it, I use frequency(MyFrequency).
I'm not sure if this is best practice, but it is working to some extent.
Max