Audio library compile problem

onehorse

Well-known member
I just got around to soldering up my audio board and was trying out the audio library for the first time. I downloaded the Audio.zip file, put it in the libraries section of my Arduino folder and tried to compile a very simple sketch:

Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>

// GUItool: begin automatically generated code
// GUItool: end automatically generated code

This is the compile error I got:

Code:
C:\Program Files\Arduino\hardware\tools\arm-none-eabi\bin\arm-none-eabi-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mcpu=cortex-m4 -DF_CPU=48000000 -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -mthumb -nostdlib -D__MK20DX256__ -DTEENSYDUINO=120 -fno-rtti -felide-constructors -std=gnu++0x -DUSB_SERIAL -DLAYOUT_US_ENGLISH -IC:\Program Files\Arduino\hardware\teensy\cores\teensy3 -IC:\Users\Pesky Products\Documents\Arduino\libraries\Audio -IC:\Program Files\Arduino\libraries\Wire -IC:\Program Files\Arduino\libraries\SPI -IC:\Program Files\Arduino\libraries\SD C:\Users\PESKYP~1\AppData\Local\Temp\build3634049013559787273.tmp\audio_INMP441_ino.cpp -o C:\Users\PESKYP~1\AppData\Local\Temp\build3634049013559787273.tmp\audio_INMP441_ino.cpp.o 
In file included from audio_INMP441_ino.ino:1:0:
C:\Users\Pesky Products\Documents\Arduino\libraries\Audio/Audio.h:39:2: error: #error "You need to update DMAChannel.h & DMAChannel.cpp"
C:\Users\Pesky Products\Documents\Arduino\libraries\Audio/Audio.h:40:2: error: #error "https://github.com/PaulStoffregen/cores/blob/master/teensy3/DMAChannel.h"
C:\Users\Pesky Products\Documents\Arduino\libraries\Audio/Audio.h:41:2: error: #error "https://github.com/PaulStoffregen/cores/blob/master/teensy3/DMAChannel.cpp"

I am sure I am doing (or not doing!) something dumb here. Could someone provide a clue to the clueless?
Do I have to download these github files?

I have a pair of digital INMP441 I2S microphones connected to Teensy 3.1 pins 9 (BCLK), 13 (SD), and 23 (WS) and I would like to get the serial data output from the mics sent to the headphone output so I can verify the mics work, and then later get the serial data in a form I can manipulate. I have the Audio board soldered to the Teensy, and I would like to use the Audio library to the fullest extent.

audioboard.jpg

I want to use the mics in master mode, where the Teensy 3.1 provides the clock signals and accepts the serial data from the mics as input. There is the problem of the 2 x 32 bits per cycle carrying 24-bit data words. I don't know how to finesse this issue other than rewriting parts of the audio library to accommodate this serial data structure. First things first, how can at least compile an audio sketch using the audio library?

Edit: I reinstalled Teensiduino 1.20 and now I can compile without error. It took a while but now my brand new Teensy is also recognized and I was able to upload the sketch that receives I2S audio from the audio shield line in pins and sends it to the headphones. I get nothing from a mono speaker attached to the headphones. Is the microphone serial data line connected to pin 13 of the Teensy 3.1 (soldered to the audio board) the same as line in here?

A comment from the wise would help here; I am going about this the wrong way or am I on the right path?
 
Last edited:
Yup, DMAChannel.h was modified for 1.20 final release, hence the error message. 1.20 also includes the Audio Library (if you choose to install it, that is) but installing from GitHub is fine too of course.

Since you are using a breadboard, be sure you have connected all the required pins. That includes the I2S, SPI and I2C pins; note that SPI is on the alternate pinout.
 
OK wait, that photo shows MEMS I2S microphones and a soldered Teensy 3.1+Audio board stack. OK so you are controlling tow I2S devices at one, one for input and one for output.

Suggest first uploading some sketch that uses just the Audio library and board (like the one that plays some music) to verify all is well. Then work on sharing the I2S (which is point to point, not a bus; I don't know if you need to configure the SGTL5000 DAC in to switch it off or something to allow your MEMS mics to be used instead).
 
be sure you have connected all the required pins. That includes the I2S, SPI and I2C pins

Since the Teensy 3.1 is soldered to the audio board, isn't this automatic?

Suggest first uploading some sketch that uses just the Audio library and board (like the one that plays some music) to verify all is well.

Good idea. I'll report when I get this far...
 
Code:
C:\Users\Pesky Products\Documents\Arduino\libraries\Audio/Audio.h:39:2: error: #error "You need to update DMAChannel.h & DMAChannel.cpp"

Delete your old copy of the audio library, which is in C:\Users\Pesky Products\Documents\Arduino\libraries\Audio

Install Teensyduino 1.20, which puts the latest audio library into Arduino's libraries directory.
 
Yes, and I admit to being somewhat confused by I2S particularly and audio processing in general simply from a lack of experience. I ganged the two mics, one left and one right, according to the INMP441 data sheet reference circuit. I think I got it right. The serial data out is connected to pin 13, which is the RX on the audio board. I am using pin 9 as the clock (BCLK) signal to the mic board and pin 23 as word select clock signal to the mic board. As far as I can tell, these are the correct connections, no? Of course, the mics output a 24-bit serial data word, which probably can't be parsed (correctly) by the audio library functions.

Delete your old copy of the audio library, which is in C:\Users\Pesky Products\Documents\Arduino\libraries\Audio

Install Teensyduino 1.20, which puts the latest audio library into Arduino's libraries directory.

Just did this again.
 
I uploaded the four .wav files onto an SD card, put it into the audio board SD slot,and ran the WavFilePlayer.ino sketch and am listening to some more or less good audio out of my $5 speaker connected with jumper wires to the audio board headphone outlet. Some of the .wav files seem to have more noise than others; I can't tell if it is my poor speaker/connection or inherent in the file. The last .wav file sounds just fine.

So it looks like the audio board works.

This is with the microphone board removed from the circuit.

Interesting that when I plug in my microphone board while the .wav audio is playing I hear a lot less music and a lot more clicking and noise.

Some questions from a newby:

Is there some way for me to tell whether the Teensy is outputting the proper clock signals to the microphone board short of hooking up a scope?

Do I have to put some function calls into a sketch in order to invoke the master I2S function, send clock signals to the mic board, get serial data out, etc?

What should happen if the Teensy receives 24-bit serial data and is expecting 16-bit? Noise and clicking I suppose!

Lastly, the audio board output is rather weak; is this because I don't have any volume control potentiometer on the audio board yet? Can I increase the volume by adding the pot? Or maybe I need to get a better speaker...
 
Last edited:
To address the last point, the "weakness" will not be helped with a potentiometer which is merely a resistive divider. Speakers need to be driven by amplifiers, to produce the voltage and current they require and to have a sufficiently low output impedance (damping factor) to force the speaker diaphragm to follow the musical waveform rather than the natural movement that its mechanical properties would tend to produce and to resist the input voltage (back EMF) generated by the speaker (which is a coil, a magnet, a mechanical compliance and a moving mass; thus, an electrical generator) as an input to the audo output.

In terms of your I2S mics, perhaps a sketch which does not use the Audio board DAC or ADC but recieves input from the mic and does something (store it, display an FFT, whatever) would let you separately establish compatibility of your mics with the Audio library independant of the issue of interaction between two different I2S devices on the same connection.
 
I was piping the audio board output directly into a 3 inch 8-Ohm speaker with no amplifying circuit, so I expected the sound volume to be low. I just naively thought for a second there might be an amplifier already on the audio board.

I think the last of four .wav samples is just fine and the noise on the other three is due either to poor recording or poor writing to the SD card, since it was reproducible and not random.

I think the next vis a vis the mics is to get the scope out and have a look. If I don't use the audio board/library, is there an easy way to configure the clocks as input to the I2S mics? I'll give this a try next.
 
The audio board has 2 stereo outputs, for line-level signals and headphones. Neither is capable of driving an 8 ohm speaker.

The headphone output is amplified enough to drive 32 ohm headphones. If you keep the signal level below 25%, it might work, but that's going to be just barely audible. The headphone output has overcurrent limiting, which temporarily shuts off the output. If you try driving an 8 ohm speaker directly, you'll almost certainly trigger the overcurrent shutoff circuit.

All four of those sample wav files sound great, when played properly. Before trying unusual stuff, I'd recommend plugging ordinary headphones into the audio board, just to make sure things are really working properly.
 
Regarding the I2S mics, some small changes are probably needed in the I2S code.

Currently, the audio library configures 32 clocks per LRCLK frame. This chip requires 64. Getting this working is probably going to involve a lot of fiddling with the values written to the 5 hardware config registers, probably using a scope or logic analyzer to check the waveforms. Freescale's documentation isn't perfectly clear (at least to me).
 
Thanks for the feedback Paul. Luckily for me my kids both got new headphones for Christmas so I will be able to verify that the .wav files sound great; the last one certainly did and I think you're right, my crude setup probably tested the limits of the audio board.

I am resigned to having to use the scope to sort out signals into and out of the mic board. I have a friend who can hack at the audio library once we figure out if the mic board is actually sending serial data in response to the Teensy clock signals. After that, I expect some hair pulling and head banging but I think we will sort it out in the end. I'll let you know what we come up with.

These 64-bit mics are really nice for sound detection, not music per se, but for building sound antennas and other beam forming applications. I sure hope it's not too much hassle to get the things to work.
 
Back
Top