You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi could you please let me know how you chose the value 250 for this function in pico-pwm-audio.c pwm_config_set_wrap(&config, 250);
I can understand how your clock divider and other values ultimately set a sampling frequency of 11000 Hz for the clock frequency you have chosen, but I wanted to understand how you chose those specific values.
The reason I ask this is because I want to take audio input from a "line-out" audio signal attached to the ADC and play it back in PWM in real time. I don't have experience with generating audio using PWM and your code is also serving as a tutorial for me. The ADC audio samples are 12-bits and I am storing them in a uint16 and the ADC values that I am getting are in the range 2030 to 2090. Since they are all bigger than 250, using your code as it is now and just using my ADC data as input for the PWM output does not generate any PWM signal. I have tried changing the 12-bits of ADC to 8 [doing something like this in pwm_interrupt_handler()] pwm_set_gpio_level(AUDIO_PIN, (WAV_DATA[wav_position>>3]) >>4);
but that also adds a lot of noise to the output sound, so I think I may be going about this the wrong way.
So I am guessing it is better if I do not loose any bits of my audio samples and find out a way of playing them as 16 bit audio. Could you give me some ideas on how to do this, or at least what is the proper way to choose the pwm_config_set_wrap value, and the number of shifts in WAV_DATA[wav_position>>3]?
The text was updated successfully, but these errors were encountered:
Hi could you please let me know how you chose the value 250 for this function in pico-pwm-audio.c
pwm_config_set_wrap(&config, 250);
I can understand how your clock divider and other values ultimately set a sampling frequency of 11000 Hz for the clock frequency you have chosen, but I wanted to understand how you chose those specific values.
The reason I ask this is because I want to take audio input from a "line-out" audio signal attached to the ADC and play it back in PWM in real time. I don't have experience with generating audio using PWM and your code is also serving as a tutorial for me. The ADC audio samples are 12-bits and I am storing them in a uint16 and the ADC values that I am getting are in the range 2030 to 2090. Since they are all bigger than 250, using your code as it is now and just using my ADC data as input for the PWM output does not generate any PWM signal. I have tried changing the 12-bits of ADC to 8 [doing something like this in pwm_interrupt_handler()]
pwm_set_gpio_level(AUDIO_PIN, (WAV_DATA[wav_position>>3]) >>4);
but that also adds a lot of noise to the output sound, so I think I may be going about this the wrong way.
So I am guessing it is better if I do not loose any bits of my audio samples and find out a way of playing them as 16 bit audio. Could you give me some ideas on how to do this, or at least what is the proper way to choose the pwm_config_set_wrap value, and the number of shifts in WAV_DATA[wav_position>>3]?
The text was updated successfully, but these errors were encountered: