Audio signal sampling

Status
Not open for further replies.

reginalStetson

Active member
What capabilities does the teensy have for sampling audio input?

Can it sample an audio signal and output it through PWM?

Can it sample two audio signals, mix them, and output the signal as PWM?

I've looked through the board and haven't found anything that appeals to my novice understanding of hardware/software audio sampling.

What I'm really trying to do is using the teensy to sample the output of two or more guitar pickups, mix them, and output them to a sound card. I want to control the mixing levels with the computer the teensy is plugged into.

I know Paul has been talking about the new audio interface hardware but I can't get a grasp of what exactly this hardware would do and exactly how it would extend the capabilities of audio sampling with the teensy.
 
Honestly, this audio stuff is at a pretty early stage of development. In time, hopefully by December, it will be at a 1.0 state with some reasonable documentation and the API stable, where "stable" means unlikely to incompatibly change. Long before then, there will be some alpha and beta releases, where "beta" means it's been pretty well tested and generally works.

Capability-wise, an audio shield is in the prototyping stage now. It will have stereo in and out, so you could bring 2 mono signals in, mix them and send to one or both (left+right) outputs.
 
What about using an analog pin to sample an audio signal? I'm envisioning a circuit that would offset the +/- signal so that it exists only in positive voltage, sampling that signal with an analog pin, and outputting it through PWM. It seems like this could be possible with the teensy. I don't need absolute hi/fi, just something decent I can play with.

I'm thinking of a timer interrupt that samples the voltage and a PWM that has the ability to replicate that signal, mixed with at least one other signal.

I'm confused about what exactly and audio shield does. If it inputs/outputs audio, how does it interface with the teensy? Does it have its own processor dedicated to sampling audio?

I'm not interested in playing audio files, I want to sample two or more signals and have the ability to mix them and output the result.
 
I'm confused about what exactly and audio shield does.

It provides high quality audio input and output. Or it will, when it's available. It will also have a SD card socket and maybe 1 or 2 locations to solder special memory chips. You won't need those, but other people do....

If it inputs/outputs audio, how does it interface with the teensy?

Using the I2S port, which is a special on-chip peripheral designed for high quality audio streaming. For all the gory details, see chapter 46 in the reference manual.

I2S signals aren't shown on the Teensy3 reference card. Digital audio transmits on pin 22, receives on pin 13, and pins 9, 11, and 23 are used for clocks (9=BCLK, 11=MCLK and 23=LRCLK).

Does it have its own processor dedicated to sampling audio?

No, there no other processor. The codec chip on the shield contains stereo a ADC and DAC which stream audio using the 5-wire I2S interface.

The I2S port integrates with the on-chip DMA controller (chapter 20 & 21), so incoming audio is very efficiently received & transmitted to/from buffers in memory. As each sample arrives, they go into a small FIFO in the I2S controller, and the DMA controller automatically takes them out of the FIFO and writes them into memory, without using any CPU cycles. The DMA does of course use bus transactions, but this chip has a switched bus matrix and 2 separate busses to the RAM, which dramatically lessens the chances for the DMA to force normal code execution to wait 1 extra cycle to access RAM. Execution of code from flash memory, and access to the heavily-used stack in RAM occur on separate busses within the chip which operate simultaneously while the DMA controller is automatically moving audio data to and from RAM. The CPU only gets involved for a very brief interrupt, when the buffers need to be updated.

The 8 bit AVR chips on normal Arduino boards require a very CPU-intensive design. Generally the AVR peripherals lack FIFOs or more than single or double byte buffer, and there's no DMA to automatically move data from peripherals to memory. If you're use to that type of architecture, you'll probably think in terms of an interrupt for each audio sample.

Teensy3 has dramatically more sophisticated peripherals and a highly flexible DMA controller and bus structure. It's possible to do I/O at incredible speeds that would be nearly impossible on AVR, with nearly zero CPU impact. Of course, these hardware features are very complex to use, which is why a good library is in the works....
 
Status
Not open for further replies.
Back
Top