0

I had a assignment for college where we needed to play a precompiled wav as integer array through the PWM and DAC. Now, I wanted more of a challenge, so I went out of my way and created a audio dac over usb using the micro controller in question: The STM32F051. It basically listens to my soundcard output using a wasapi loopback recorder, changes the resolution from 16 to 12 bit (since the dac on the stm32 only has a 12 bit resolution) and sends it over using usart using 10x sample rate as baud rate (in my case 960000). All done in C#.

On the microcontroller I simply use a interrupt for usart and push the received data to the dac.

It works pretty well, much better than PWM, and at a decent sample frequency of 48kHz.

But... here it comes.. When there is some (mostly) high pitch symphonic melody it starts to sound "wobbly".

Here a video where you can hear it: https://youtu.be/xD3uTP9etuA?t=88

I read up on the internet a bit about DIY dac's and someone somewhere (don't remember where) mentioned that MCU's in general have interrupt jitter. So may basic question is: Is interrupt jitter actually causing this? If so, are there ways to limit the jitter happening?

Or is this something entirely different?

I am thinking of trying to compact the pcm data send over serial (as said before, resolution of 12 bits, but are sent in packet of 2 8bits forming 16bits, hence twice the samplerate as the baud rate, so my plan is trying to shift 12 bits to the MSB and adding four bits of the next 12 bit value to the current 16 bit variable, hence only needing 12 transfers instead of 16 per 8 samples. Might read upon more efficient ways of compacting data for transport.), put the samples in a buffer and then use another timer that triggers at 48kHz for sending the samples to the dac. Would this concept work? Or would I just waste time?

For code, here is the project: https://github.com/EldinZenderink/SoundOverSerial

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • I didn't really pay attention to my usb to usart module, you would expcect a constantly lit led for the tx indicator, but it isn't everytime a wobble in the audio happens that led goes off, so there is some hickup there. I guess I really need to figure something out to compact the data ;) – eldin zenderink Oct 10 '17 at 19:46
  • if you can hear us delays. Take a look on the stm application note - and use dma for the transfers instead. Much easier. Two buufers - one sent to DAC another one loaded via UART. – 0___________ Oct 11 '17 at 14:40

0 Answers0