Tools and Techniques for Musicians, Composers, and Tinkerers
Equalizer using Arduino Due
20 posts · 42217 views
by Vega » Fri Apr 05, 2013 07:42 UTC
Hello,
I'm looking to create a multiple-band EQ using the codec shield and an arduino due. I will use 16 bit faders as the input for the EQ values, and I'm wondering if anyone knows about the code for making an EQ. I'm an absolute beginner at this, any help will be much appreciated. Thank you :)
by guest » Fri Apr 05, 2013 17:31 UTC
the due uses a completely different processor than the uno or duemilanove, which is what the codec shield was designed for. as a result, the codec shield will not work with the due at this time.
by Vega » Fri Apr 05, 2013 22:25 UTC
okay, so which arduino should i use out of the uno or duemilanove? and then how would i go about writing the code for an eq?
by guest » Sat Apr 06, 2013 05:51 UTC
the leaflabs maple would probably be the best thing to use, as the uno or duemilanove can only do about a dozen multiplies per sample at 44ksps. that means only a second order filter per bandpass. i would reccomend an iir filter, as it requires fewer multiplies to accomplish the same task. there are discussions of it here:
http://www.mikroe.com/chapters/view/73/ ... r-filters/
i have only done a few simple filters.
is this something you want to control via usb? are there other inputs you want to take in? if all you need is a 6 band eq, an analog circut will do a better job.
by rup » Tue Apr 09, 2013 13:18 UTC
Hi !
I am currently trying to upgrade the library of the codec shield to the arduino due. I think it is much convenient to work with the due than with the mapple, but maybe a question of taste...
I worked on an equalizer (based on this :
http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt) on the due, and it works with integrated adc/dac, but I needed a better input and output (12bits is not enough), that's why I want to modify the library.
It didn't seemed too difficult, but I am not an pro, and I have a problem with the audio data transfert.
In the library when you send, it is writen :
while(!(SPSR & (1<<SPIF))){ // wait for data transfer to complete}
But in the due, those SPSR and SPIF don't exist the same way... Can anyone help me to find how to replace this ?
It looks like an SPI communication. Maybe we could use only the SPI library, which works with the due ?
Thx, Rup
by guest » Tue Apr 09, 2013 18:45 UTC
hey rup, that is awesome news!
i can help out a bit if you need it. it is probably better to look at the maple code as it is also an arm processor. its basically an spi transfer, but there is some finicky timing that has to go on, so i used low level commands rather than the spi library. there is a set of nops in there to get the timing just right.
by guest » Tue Apr 09, 2013 22:18 UTC
ok, the first hurdle is the fact that the pinout is completely different between the due and the uno. i dont know why arduino insists on doing this, but every time they make a new board, they move where the lines are.
neither the i2c or spi lines are on the right pins anymore, so they will have to be rewired to work. also, the potentiometers are tied to 5v, but the due only accepts 3.3v, so the 5v line will have to be cut out and bridged to the 3.3v bus.
by rup » Wed Apr 10, 2013 09:51 UTC
For the pinout and voltages, I don't care, because obviously the audio codec board can't work as a shield for the due, like you said. The due needs a custom shield.
I just want to be able to use the wm8731, in order to build my own shield for the due. Currently, I have a wm8731, and I work on a breadboard.
I saw these timming problems, but I am interrested if you can explain me in detail what does this part (where the data is sent and received) of uncommon code, wrote in inline assembly.
What it does seems simple, but I don't find how to tranlate them for the due. I checked also the code on the mapple library, and in both libraries, I think the same trick is used : a kind of spi hack, but with strange low level commands.
I can't find the equivalent commands for the due, so if you have any idea....
by guest » Wed Apr 10, 2013 13:07 UTC
in that case you can use the SSC (serial synchronous controller) in the due. it is intended to talk to codecs via I2S, which is the usual codec protocol. i was using SPI because there is no I2S on the uno. that will speed things up immensely, and make DMA possible. i have never used it before, but someone must have written a library for the chip. perhaps check atmels site for the SAM3X8E.
by rup » Thu Apr 11, 2013 12:49 UTC
Thanks, I found something really interresting, but it is not easy to understand all of what is done here, and how to use it with arduino environment, especialy when you never worked with atmel studio and true atmel arm code.
This is an example code to playback a wav from an sam3x to a wm8731:
http://asf.atmel.com/docs/latest/sam.co ... index.html
by guest » Thu Apr 11, 2013 17:51 UTC
thats a goldmine. awesome!
there are a lot of functions in there, but you can pick some out and start adding them to your files and see if they compile. i would aim to get the I2C (TWI) working first. that doesnt require the DMA, and you can test it by having the codec toggle between pass-through mode and off mode.
by rup » Mon Apr 15, 2013 20:11 UTC
Ok, first step, done.
The TWI interface works. I found also a library which allows you to change a lot of settings very easily.
https://github.com/hughpyle/machinesale ... ter/WM8731
it is very complete, but, there is a very little mistake: somewhere in the library, there is a "Wire.send", replace it by "Wire.write" and it works for the due.
So now, I have this (TAIJIUINO (DUE equivalent)+PROTO BOARD from Mikroe):
This table explains the wiring I will use for the audio interface:
https://dl.dropboxusercontent.com/u/278 ... inning.txt
The TWI inteface is connected to pin 20-21 on the DUE.
Now, I have to set up the audio interface, but I don't know where to start... between dma and ssc...
by guest » Tue Apr 16, 2013 14:36 UTC
great job!
i would say the ssc is the next thing to get going. you might just try adding the other library you found, and seeing if it compiles. otherwise you can dig into the .c files and see what the actual register settings are. the first thing to do is just get the direction on the io lines correct. i think setting up the wm8731 as ssc master would probably be the way to go.
by rup » Fri Apr 19, 2013 10:38 UTC
hey,
I didn't find out how to use the ssc library and exemples with the arduino IDE, so I moved to atmel studio 6.1.
I found how to compile exemples from atmel software frameworks, and upload them using bossa:
https://sites.google.com/site/arduinodu ... tudio/home
With this tool, you can use atmel studio environment and tools, and directly upload to the due, so it is perfect to start trying some stuff. Programming works, the due responds via serial, now I will try how to see how to set up the ssc.
by guest » Fri Apr 19, 2013 16:08 UTC
cool!
does atmel studio6.1 have a bootloader it uses, or do you need external hardware, like a jtag dongle? if so, which jtag thing are you using.
by rup » Fri Apr 19, 2013 17:17 UTC
I don't have any issues with bootloader.
I used the method described by the link in my last post, and It works.
The upload is done with the usual on-board programmer (So it is impossible to do ICD).
by Vega » Sun Apr 21, 2013 07:32 UTC
Hey, great work rup. As I'm an absolute beginner I've got a few questions for you if don't mind answering them :) You made you're own codec shield using the WM8731? Have you got an eagle file for that or a schematic?
And where does the mikroe proto board come into the mix?
You are programming your filters using the atmel environment?
Any other information would be of great help :)
Thanks for your time
by rup » Mon Apr 22, 2013 15:59 UTC
Hi!
My aim is to finally build my own shield, but at the moment, I am working with the Mikroe Audio codec proto board, which is more convenient to start. If you want to, I think you can do this very easily, using the eagle file from open music labs, and modify it. Schematics for the wm8731 is in the datasheet.
My filters are writen in C, in arduino IDE.
I was trying to use atmel studio beacause of the ssc, which is unknown from arduino community, but, finally, I came back to the arduino IDE, and imported from atmel studio the needed libraries.
If you check my previous posts, you will find some more information, but ask me if you need something else.
Right now, I am trying to make dma and ssc working, but it is not easy...
At the moment, I took and adapted the exemple file (play a wav) found in Atmel Software FrameWork, but i didn't reached to make it work yet.
by rup » Tue Jul 30, 2013 11:08 UTC
Hi !
I am back. I was travelling lasts months, that's why I wasn't active here.
I found something new to go forward for those who are interrested.
The problem of the ssc communication is allmost solved. A guy wrote a library that allows to transmit audio in I2S with the due via the ssc.
You can find it here :https://github.com/delsauce/ArduinoDueHiFi
I wrote a test code, but unfortunately (but as usual), it's not working at the first try. I have to verify that the wm8731 setup is fully correct for data transmission.
But I have no scope, so it is not easy to find the mistake.
I'll tell you as soon as I make this work.
by Palliser » Fri Aug 02, 2013 20:48 UTC
Hello rup!
I would like to know about your progress with the WM8731 audio codec example and Arduino Due. Can you play back a wav file? Thank you!