I2S tone player
Posted: Tue Feb 15, 2022 6:36 am
Hi all,
This is a follow-up to my previous post about I2S Dac
I have been trying to play around with the I2S capabilities to play simple sine wave tones. This is possible, however, I have not been able to successfully add user input to this. Here are some of the things I tried:
1 - Using the I2S micropython examples, they show different ways to output sound through your DAC. There are several examples to play a wav file, either from the SD card or with a file in the flash memory. All of these examples work great! There is an example to play a sine wave tone, which became my main focus. The sine wave example shows how to continuously loop a sine wave at a given frequency, however, if I want to change the frequency of the sound, I need to stop the program and change the values and restart again.
2 - I have been trying to change the frequency of the sine wave with user input, using the example code as a base, but I have not been very successfully. I believe that to be able to do this, the code need to create a new array with the sine wave data on each while True: loop., which is not happening with the example code.
3 - I was wondering if we could just create a small array with sine wave values (1 period), and on the while True: loop we just change the frequency that the wave is repeated.
Maybe my approach to this is not the best one, but I am really interested to know if anyone has been working on this and can help me out?
Thanks.
This is a follow-up to my previous post about I2S Dac
I have been trying to play around with the I2S capabilities to play simple sine wave tones. This is possible, however, I have not been able to successfully add user input to this. Here are some of the things I tried:
1 - Using the I2S micropython examples, they show different ways to output sound through your DAC. There are several examples to play a wav file, either from the SD card or with a file in the flash memory. All of these examples work great! There is an example to play a sine wave tone, which became my main focus. The sine wave example shows how to continuously loop a sine wave at a given frequency, however, if I want to change the frequency of the sound, I need to stop the program and change the values and restart again.
2 - I have been trying to change the frequency of the sine wave with user input, using the example code as a base, but I have not been very successfully. I believe that to be able to do this, the code need to create a new array with the sine wave data on each while True: loop., which is not happening with the example code.
3 - I was wondering if we could just create a small array with sine wave values (1 period), and on the while True: loop we just change the frequency that the wave is repeated.
Maybe my approach to this is not the best one, but I am really interested to know if anyone has been working on this and can help me out?
Thanks.