Best solution handling ADC-DAC for simple audio effects processor

tom303
Posts: 3
Joined: Mon May 27, 2019 7:25 pm

Best solution handling ADC-DAC for simple audio effects processor

Postby tom303 » Mon May 27, 2019 8:10 pm

Hi!

I'm trying to add a simple audio effects processor to my project. (mono in - stereo out - chorus effect)

Audio input via the onboard 12bit ADC, output via a stereo 12bit SPI DAC.
Sampling rate needs to be at least 32kHz, so there's about 31µs time for AD-conversion, processing and DA conversion.

Pseudo code:

loop @ 32kHz
{
adc_reading
audio processing
dac_writing
wait until 1/32000s are over
}

HSPI and VSPI are already in use for other things, so I tried to bitbang data to the DAC chip, which works fine and only takes about 6µs for sending out a set of stereo samples. The audio effect algorithm only takes a few µs either. So there's about 15µs left for ADC sampling.

My first approach was using a timer at 32kHz and to read single samples with "adc1_get_raw". However "adc1_get_raw" takes 40µs for one sample, which is too long unfortunately.

I am now looking into I2S and DMA, but I haven't found out how to make it work for my specific application.
I can make it work by accessing the DMA buffer, but since my loop and the i2s sampling rate are not perfectly in sync, I am having terrible jitter noise. I don't know how to sync my loop to the I2S sampling rate. I need some kind of trigger/interrupt for every input sample.

Ideally I'd want to use i2s_read to grab a single sample and let it controll the timing of my loop, but since I cannot set the buffer size to 1 sample, the only way to get samples is in packets of 8 or more.

Clearly I am lacking knowledge here :)

Any kind of help is much appreciated!
Thank you very much

tom303
Posts: 3
Joined: Mon May 27, 2019 7:25 pm

Re: Best solution handling ADC-DAC for simple audio effects processor

Postby tom303 » Tue May 28, 2019 7:49 am

I have just found out that while adc1_get_raw() takes 40µs, analogRead() only takes 10µs. So my effects processor is now working. :)

But maybe there's overall a better solution for what I'm trying to do.

best

chibill
Posts: 8
Joined: Wed Mar 27, 2019 2:48 pm

Re: Best solution handling ADC-DAC for simple audio effects processor

Postby chibill » Tue May 28, 2019 8:44 pm

https://docs.espressif.com/projects/esp ... s_source_t can be used to attach I2S to the ADC for sampling :) Hope this helps.

tom303
Posts: 3
Joined: Mon May 27, 2019 7:25 pm

Re: Best solution handling ADC-DAC for simple audio effects processor

Postby tom303 » Wed May 29, 2019 9:02 am

Unfortunately not, but thanks anyway. ;)

Who is online

Users browsing this forum: Baidu [Spider], Google [Bot], MSN [Bot] and 8 guests