How to control the amplitude and the frequency of the generator? #164
-
I would like to generate a sinus tone which works with below code : But how can I control the tone in amplitude and in frequency? Is that somewhere explained? What would be the max frequency possible? When I commented //AudioLogger::instance().begin(Serial, AudioLogger::Info); the sound was perfect, but uncommented I got a very disturbed sound. ( using PCM5102 module) Thanks for feedback! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I suggest that you check the class documentation and look up SineWaveGenerator. If you plan to change the parameters of a running tone I suggest that you use the SineFromTable instead as documented. Instead of changing the amplitude you might also consider to use the Volume Control as described in the Wiki You can comment out the log statement or set it to Warning as it is recommended in the Readme. Starting/Stopping can be done in many ways:
For the max frequency I am not sure. I would guess it is half the sampling rate ? Though I would expect that will not generate any nice sine wave and I am not sure if a regular speaker would be able to go above 20'000Hz |
Beta Was this translation helpful? Give feedback.
I suggest that you check the class documentation and look up SineWaveGenerator. If you plan to change the parameters of a running tone I suggest that you use the SineFromTable instead as documented.
Instead of changing the amplitude you might also consider to use the Volume Control as described in the Wiki
You can comment out the log statement or set it to Warning as it is recommended in the Readme.
Starting/Stopping can be done in many ways:
For the max frequency I am not sure. I would guess it is half the sampl…