Skip to content | Skip to navigation
Powered by RSPowered by RSPowered by RS

Ever used a microcontroller for audio DSP?

LStacey

United Kingdom

I just had a thought...

I was staring at my mbed microncotroller and wondered if I could use it to process audio. I was thinking that with an A to D on an input and a D to A on the output, it might be possible to do some pretty cool things.

Imagine making a guitar stomp box (that's an effect pedal for the uninitiated) based on an mbed. You could create a basic framework that allows you to upload custom DSP to the board and have your pedal be any effect you want.

So, the sub questions:

Would there be enough bandwidth to stream high quality audio in and out of the unit?

What would the latency be like?

Feel free to flame me if it's a silly idea and won't work.

Replies

jkvasan

India

1 year ago

Hi,

I was just wondering, if any of the Digital Potentiometer chips can do the job. Some are available from Microchip with SPI interface. SPI is faster mode of communication and all we need is a fast processor with audio in a memory chip. Feeling nostalgic about a projcet done years ago to generate a sine waveform of around 15 KHz for some application with one of those digi pots and a renesas chip.

 

 

 

 

 

 

 

LStacey

United Kingdom

1 year ago

Digital potentiometer?

willscottja ...

United Kingdom

1 year ago

If you want to make various effects I don't think it's too tricky, For something like a wah pedal I think you some how impose a phase shift on the input waveform. And distortion for rock and metal playing you impose a square wave on it. You could probably make your own sounds by just playing with the waveform. You'd probably have to do that before you convert it to a digital signal or after you convert it back to analogue to send into the speakers. 

 

I had a similar idea to do that kind of thing in labview, where the front panel is your stompbox and you get the code to grab an audio signal and then impose all sorts of things on it. But it only really stayed as an idea.

LStacey

United Kingdom

1 year ago

I've got no issues with the actual DSP code. Once I've got the sample value, it's just maths. Buffers (requitred for delay and time constants in filters) would be more of a challenge but I'm sure I could work it out.

The bit I would find most tricky is extracting the value of the samples, purely because I don't know the hardware that well but if it's already been done, that makes life a lot easier!

Ioannis Kedros

United Kingdom

1 year ago

I was working with an external audio DAC from TI a few weeks ago (http://focus.ti.com/docs/prod/folders/print/tlv320aic23b.html) together with an mbed. I think it is a perfect match for your project.

In my experiments, I was reading a wav file (16bit samples per channel @ 32 KHz, but you can go as high as 32bit samples and 96KHz) from an SD card that was hooked to an mbed. The samples were passed to the audio codec over the I2S protocol. The results were really impressive! You were able to hear proper music just like a high end portable MP3 player (http://mbed.org/blog/entry/spot-mbed-at-embedded-world/)!

For example the codec’s ADC can read your audio input (according to your desired resolution and sampling rate) and the mbed can easily handle the manipulation of the audio samples, like adding effects, delays, reconfigurable gain into a selection of samples or whatever you can imagine basically! Then, just pass the samples to the audio DAC of the codec and...  job done!

But the best part is that all of those can happen in a real time environment!

LStacey

United Kingdom

1 year ago

Wow. That sounds pretty impressive. Have you got any details on how you did it? I'd love to see the code.

Ioannis Kedros

United Kingdom

1 year ago

We will have a few blog posts soon... together with code examples, explanation of the code and libraries!

LStacey

United Kingdom

1 year ago

Awesome!

I look forward to that. Are you on Twitter? If you are, drop me a message @DesignSparkRS. I'm sure our Twitter followers would benefit from this.

Bill Marshall

United Kingdom

1 year ago

Depends on the 'quality' you require. CD quality (up to 20kHz analogue signal bandwidth) will require an ADC to be taking samples at 40 ksamples/sec at least - Nyquist criterion. In between sample taking, the MCU must perform whatever process is required on that and previous samples in order to produce an output to the DAC. You will need to run some test programs on the mbed to see just how fast the internal ADC can run. This will largely depend on how efficient the mbed driver routine is. You may also find that your effects 'algorithm' may need to written in assembler code to fit it in between samples. For an effects pedal much lower bandwidth may be acceptable, and some distortion may even be desirable!

 

LStacey

United Kingdom

1 year ago

I was thinking about this actually. I guess breaking up the samples and processing the value they hold is the tricky part.

Maybe I need to do a quick proof of concept first.

Any tips on what ADC/DAC I should go for?

Bill Marshall

United Kingdom

1 year ago

The LPC1768 mbed MCU chip has an 8-channel 12-bit ADC and a single channel 10-bit DAC on board. Worth checking these out as the mbed firmware contains the necessary drivers. If not fast enough then external ADC/DAC chips will be needed.

 

banjohat

Denmark

1 year ago

TI is very good at giving samples + they have a very nice search engine in their products.. go have a look at those :)

LStacey

United Kingdom

1 year ago

I was referring to samples in the data sense but you're right about TI's search engine. :)

banjohat

Denmark

1 year ago

I know :) The reference to the search engine was for your to add with the nyquist criterion. Then you should be able to find the right samplerate ;)

banjohat

Denmark

1 year ago

I would loveto see your work when (and if) you get i working. However I think that the latency is the biggest problem. While Arduino/MBed/others are very easy to code, I think that all the macros make some overhead that introduce latency in the system. It might be nothing - I don't know.

In the end it would depend on the speed of the AD/DA converters so it might just work fine :)

LStacey

United Kingdom

1 year ago

That's what I'm hoping. Latency really needs to be under 4ms to be passable so it's a pretty tall order.