Go Down

Topic: Using STM32F103C8T6 as an audio amplifier controller (Read 850 times) previous topic - next topic

alexdev

Hello! I want to build a small 2.1 audio amplifier controller that can adjust the volume and render a bar VU meter on a 16x2 LCD display.

So I thought about using a STM32F103C8T6 for both sampling the audio and driving the display, then outputting the modified signals using PWM. This would give me 3 PWM channels: L, R and a subwoofer channel filtered using DSP, so the low pass filter is no longer needed. I still have to filter the square waves before going into the amplifier though...

How good the audio quality would be given the 12-bit resolution of the ADC?

Are 10k digital potentiometers a better idea?

Thanks.

MarkT

PWM can be amplified direct as class D without converting back to analog.  Many MOSFET motor drivers can actually do this!
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

DVDdoug

Quote
How good the audio quality would be given the 12-bit resolution of the ADC?
12-bits is "pretty good" but obviously not "CD quality"...  I'd be more worried about the PWM.  ;)

12-bits isn't a "standard" format but if you want to find out what it sounds like there is a "trick" you can use to reduce the bit depth by attenuating and then re-amplifying...

Have you ever used Audacity?  (An open source audio editor.)


- Each bit adds 6dB of dynamic range so going from 16 to 12 bits is a 24dB loss of dynamic range.

- Open a 16-bit file ripped from a CD (or a good quality MP3*) in Audacity.

- Use the Amplify  effect at -24dB to attenuate the file.

- Export the audio to 16-bit WAV** with a different file name so you don't overwrite the original file.  (After attenuation 4 bits are always zero so you only have 12 bits of information/resolution.)

- Open the attenuated file, Amplify  by +24dB, and listen.


"just for fun", you can try 48dB down-and-up to simulate 8-bits, or there is a way to export directly to an 8-bit WAV.    With 8-bits you should hear "quantization noise".   Quantization noise "rides on top" of the signal so like regular noise it's most noticeable during quiet parts, but unlike 'regular noise" it doesn't exist when the audio is totally silent.



NOTE -   You'll loose additional resolution if you don't feed the analog-to-digital converter a "full-volume signal".   i.e. If you are not using all 12-the bits.    And, it's standard practice to leave some "headroom" because with analog signals the exact voltage is usually unknown and it will vary with different recordings and it will vary if there is an analog volume control.   (Pros record at 24-bits and they generally leave lots of headroom.)

On the digital-side, the maximum (and reference) digital level is defined as 0dBFS (zero decibels full-scale) for whatever bit-depth you're using.     But, the actual analog voltage that corresponds to 0dBFS is determined by the particular ADC.     





* MP3 is lossy compression but it doesn't have a "bit depth" and you don't loose dynamic range.

** This step is important because Audacity uses floating-point internally and you don't use resolution by attenuating until you convert back to an integer format.

Go Up