Audio Codec with Teensy 3.0?

Audio Codec with Teensy 3.0?

Postby sdiedrichsen » Wed Feb 27, 2013 6:08 am

I just got 2 teensy 3.0 boards. They have a Cortex M4 from freescale running on 48 MHz and FPU!
Did anyone tried to connect a codec shield to a teensy?
sdiedrichsen
 
Posts: 3
Joined: Mon Feb 18, 2013 2:47 am

Re: Audio Codec with Teensy 3.0?

Postby guest » Thu Feb 28, 2013 2:12 am

that sounds cool. unfortunately, i havet heard of anyone doing that yet.
guest
Site Admin
 
Posts: 449
Joined: Thu May 20, 2010 11:58 pm

Re: Audio Codec with Teensy 3.0?

Postby PaulStoffregen » Wed Sep 11, 2013 2:03 am

I'm working on an audio library for Teensy3, planned for a first public release before the end of this year.

I recently posted a blog article about it on the DorkbotPDX website. Teensy3 generates MCLK (at 256*Fs), BCLK, and LRCLK, so you can connect virtually any I2S chip in slave mode. The first version of the library will have control objects for the WM8731 used on the codec shield, and a SGTL5000 chip that will on a much smaller Teensy-size shield. I've been testing with a Mikro WM8731 breakout board (with the crystal removed), but I plan to test the library on a real Open Music Labs Codec Shield before the first release. If you already have the Codec Shield, it should work once this library is released.

The library fully utilizes the DMA controller for efficient stereo input and output by I2S. It also has DMA-based input and output using the chip's ADC and PWM, which gives lower quality mono sound, but requires only adding a few resistors and capacitors. Streaming from I2S at 16 bit, 44.1 kHz stereo requires only a few percent of the CPU time, which leaves plenty available for the many audio processing objects....

I've been putting a LOT of work into designing this to make audio easy and fun for Arduino users. The library currently has 9 audio objects: I2S in, I2S out, ADC in, PWM out, WAV file from SD, raw data from SD, sine wave, frequency modulated sine wave, and a 4 channel mixer. I plan to add many more, for wavetables, modulation, FFT/analysis and lots of other stuff (in fact, I'm still working on the wish-list for audio objects). The first release might have only a few more objects, depending on how much time I have. My main focus is on the connection objects and common infrastructure that makes all this possible. That's the part I want to make sure is solid before a first release, so it doesn't all need to incompatibly change.

The library has "connection" objects, which automatically route the audio data between the audio objects. The idea is you can just create a collection of audio objects at the top of your sketch and connect them together however you like. It all flows automatically (actually, in 128 sample blocks), processed in the background by a low priority interrupt (leveraging the ARM's NVIC priority scheme). Then in loop(), you can call functions from the objects to modify how they work, like begin/pause/stop wav file playing, change the gain on mixer inputs, change oscillator frequency, etc. The library also has functions to report CPU usage, which the library automatically tracks for every object, so you can find out how much of the processor you're using and which objects are using too much.
PaulStoffregen
 
Posts: 4
Joined: Wed Sep 11, 2013 1:16 am

Re: Audio Codec with Teensy 3.0?

Postby PaulStoffregen » Wed Sep 11, 2013 6:33 am

Opps, looking more closely at the Codec Shield, the XTI/MCLK pin from the WM8731 doesn't come to any of the I/O locations, and the board has a crystal soldered.

To use it with Teensy3, you'll have to remove the crystal (X1) and capacitor (C20) and solder a wire from Teensy3's pin 11 (MCLK output) to XTI/MCLK, which is probably easiest to access on the large pad for crystal.

The entire board should be powered from only 3.3 volts for use with Teensy3. Both the 3.3 and 5V pins on the shield should connect the Teensy3's 3.3V pin. Nothing should actually connect to 5 volt power.
PaulStoffregen
 
Posts: 4
Joined: Wed Sep 11, 2013 1:16 am

Re: Audio Codec with Teensy 3.0?

Postby guest » Wed Sep 11, 2013 5:32 pm

hey paul, that all souds amazing. that is quite a contribution to the community.

as for the codecshield, the chip can run in slave mode with its own crystal, so it should be able to work fine. the processor should be able to take in data with the codec in master mode as well.
guest
Site Admin
 
Posts: 449
Joined: Thu May 20, 2010 11:58 pm

Re: Audio Codec with Teensy 3.0?

Postby PaulStoffregen » Wed Sep 11, 2013 6:15 pm

That's great news. I had no idea the WM8731 was capable of running with BCLK and LRCLK as inputs while using the crystal. I had just assumed it needed MCLK too, at an exact multiple of 32 or 64 times BCLK. To be honest, I've never even tried configuring it any other way.

I placed an order this morning for the codec shield bare board and the parts kit. Will build it up and test.

My library will not support running any codec in master mode. Even though the processor's I2S port has the capability to run in slave mode (receiving BCLK and LRCLK from the codec), my library requires the audio sample rate to the strictly synchronous to the CPU clock. It's entirely a software limitation.
PaulStoffregen
 
Posts: 4
Joined: Wed Sep 11, 2013 1:16 am

Re: Audio Codec with Teensy 3.0?

Postby guest » Wed Sep 11, 2013 9:58 pm

the codecshield also puts out its own clock, which is how it gets synchronised with the arduino. the arduino interrupts every 256 of these clocks and tranfers data. there is also the MIKROE-506 from mikroElektronika, which is much cheaper than the codecshield. the layout is a bit iffy, but ive heard it works fine.
guest
Site Admin
 
Posts: 449
Joined: Thu May 20, 2010 11:58 pm

Re: Audio Codec with Teensy 3.0?

Postby guest » Wed Sep 11, 2013 10:07 pm

also, i see what youre saying about keeping the microcontroller and codec synchronised. if your system cant take the external clock and interrupt on it for the I2S transfer, there will probably be an issue. i found the codec to be pretty robust to timing errors in SPI mode, but that was for small modulations around an operating point, not a continual drift.
guest
Site Admin
 
Posts: 449
Joined: Thu May 20, 2010 11:58 pm


Return to Audio Codec Shield

Who is online

Users browsing this forum: No registered users and 1 guest


cron