Arduino Due Audio Generation/Playback

Hi all.

Working on a project revolving around an ILI9341 TFT with a menu system stored on an SD card. Wanted to get audible feedback since the Due has the DAC (and i figured I might as well if I'm using the Due since it has DMA transfers for the TFT), however using the Simple Audio Playback example, the output is frankly awful. It seems really distorted, muffled and pops on playback and finish and there seems to be little else in the way of examples or libraries.

I am thus tempting the idea of ditching WAV playback for generation instead but I dont know if this is a better choice if im running the TFT too.

Which would be the better option, to synthesize or use wave playback and for the latter, is there anything else out there for the Due?

Well I’ve been working on a DAC/ADC library for the Due, but right now it has just been released, and will probably provide about the same or worse results in your particular application, depending on how it is used.

It is a bit different, more of a raw interface to the DAC/ADC which I am thinking about using as a base for audio applications, particularly involving wireless/radio comms etc.

Also a bit odd because it adjusts the sample rate/timing automatically, but that can be disabled for many applications.

Between it and the general audio library, it might at least give you a good idea of how to setup and work directly with the DAC on the Due if not directly useful.

http://tmrh20.github.io/AAAudio
https://github.com/TMRh20/AutoAnalogAudio

There’s a simple synth library that works great on Uno, that I have modified a bit to run also on the leonardo/micro. It uses tables in progmem, output the sound on a PWM pin, and you just need a RC filter to smooth it.

I’ve started to work on a port for the Due, but for now it’s not usable.

Anyway, here is the original library: the synth
And here is my port.

The original didn’t work for me, and I’ve modified it to add things I needed. I’ve also ported the number of channel to 8, and that works.

I know you won’t be able to use it as is, but maybe you can find inspiration in it?

Thanks for the replies guys.

I was hoping for more of a complete solution as I have many things to learn about (TFT, CAN, the Due) and wanted to just be up and running lol. I think i will try the synth as I have used it before, just didnt want to sacrifice the DAC output. Needs and wants i guess. :smiley:

Maybe you don't need to sacrifice the DAC. A I said I haven't tried it yet on the Due, but as the sound was pretty good on the Uno and Micro, I suppose that it should be as good as that, or maybe better, on the due.
The PWM channels of the Due are 16 bits, so maybe the sound would be better on these pins with a low pass filter, than on the DAC ones? I'll surrely give it a try!

NaokiS:
I was hoping for more of a complete solution as I have many things to learn about (TFT, CAN, the Due) and wanted to just be up and running lol.

For the last couple years, I've been working on an audio library for Teensy which tries for "complete solution". Honestly though, the more audio features I implement, the more people request even more advanced stuff. I don't know if anything can ever be truly "complete".

But it does have SD card playing that works well with optimized ILI9431 TFT screen updates! About this time last year we made a nice tutorial video. Here's the link:

Near the end you can see it playing a stereo WAV file, while doing peak detection and rapidly updating a TFT display. Both the SD card and TFT share the SPI bus. Skip to 47:08 in the video if you want to see the TFT running while audio plays.

That's very interesting paul. But is it using a codec board or is this in software? If the latter i would be very interested as that seems to be exactly what I need for my project, even if you're using the teensy instead of the due.

Especially loving the TFT update rate

NaokiS:
But is it using a codec board or is this in software?

It's all in software. The codec just provides quality ADCs and DACs. The SD card is connected to the SPI pins. There's no connection between the SD card and codec chip. Full schematic is here:

http://www.pjrc.com/store/teensy3_audio.html

The audio library also supports I/O with the built-in 12 bit DAC. In fact, you can even use the codec and DAC together, for 3 outputs on Teensy 3.2 (only a single built in DAC) or 4 outputs on Teensy 3.5 & 3.6 (two built in DAC). The codec's DACs are higher quality 16 bits, but the 12 bit DACs still sound pretty good.

That's very interesting then. Sounds like it's exactly what I want, if not a bit overkill for my needs. :smiley:

I take it though its kinda of integral to the Teensy? Given the fact the teensy uses a freescale chip and not the SAM3X which the Due does.

NaokiS:
I take it though its kinda of integral to the Teensy?

Yes, very much so. There's extensive use of the Cortex-M4 DSP extension instructions, Freescale's DMA engine, and the SPI FIFO's chip select generation features. Highly optimized code that leverages these hardware specific features is how it achieves its performance.

NaokiS:
It seems really distorted, muffled and pops on playback and finish and there seems to be little else in the way of examples or libraries.

A couple notes on .wav files that might also help regardless of code:

  1. WAV files always start with a 44 byte header, so you want to start at least at byte 44 or you will be feeding the DAC data, which will make bad sounds/pops
  2. WAV files can also contain metadata (although not really supported in the format), which extends the data portion past the 44 byte mark. This will also result in popping and clicking. Audacity is a free program that can be used to remove the metadata.
  3. *.wav files should also start and end with silence.

I need stereo audio wave player. Is there any one help me out. I am using TMR20 auto analog audio. I could debug recording section to record stereo. That does great job. New I need stereo play back. I plays mono. The hardest part is I am unable to switch on two dac and feed them. I need help please help me put please give some clues. I shall be greatly thankful to every body on the block my email is sidhudalwimder8@GMAIL.COM.THANKS

Some advice.

  1. Do not resurrect old threads.
  2. Read the how to use this forum sticky post.
  3. Do not put your email on the open forum. No one is going to wast time on a technical problem just for you. The idea of this forum is to generate a resource for everyone, not just an individual.