Increase number of I2S audio streams?

Status
Not open for further replies.
I'm working on my senior project in computer engineering at USC. It's a results oriented course where usually everyone makes a website, a small group of us decided we wanted to do something hardware oriented and petitioned the professor for a hardware challenge and we got ourselves in deep. Short description, an ethernet controlled HDMI switch with multiplexed audio and delay functionality. Teensy seemed perfect for the brain, but half way though the project the professor thought it would be a great idea if a 3rd audio channel could be added.

We can actually work around a software solution by adding in a few tristate mux Ics to the design, but ideally, we could just add another input.

TL; DR

Is it possible to extend the audio library to support 3 i2S inputs instead of 2?

I studied the differences between AudioInputI2S and AudioInputQuadI2S and I see that its loading 4 blocks instead of 2, but I can't really understand the pipeline.
A lot of the magic seems to come from DMAChannel but it's fairly hard to follow.
If it's possible, a point in the right direction would be appreciated.

Thanks
 
If you do not need the three inputs simultaneously, i think multiplexing would be easy with simple switches..
 
I don't *require* them simultaneously, but they are prefered to be simultaneous. Also, the entire project is network controlled so everything has to be digitally controlled, muxing is a possibility though if we have to, but there's already 16 ICs on this board I'd rather not put any more on unless we have to.
 
I'm working on my senior project in computer engineering at USC. It's a results oriented course where usually everyone makes a website, a small group of us decided we wanted to do something hardware oriented and petitioned the professor for a hardware challenge and we got ourselves in deep. Short description, an ethernet controlled HDMI switch with multiplexed audio and delay functionality. Teensy seemed perfect for the brain, but half way though the project the professor thought it would be a great idea if a 3rd audio channel could be added.

We can actually work around a software solution by adding in a few tristate mux Ics to the design, but ideally, we could just add another input.

TL; DR

Is it possible to extend the audio library to support 3 i2S inputs instead of 2?

I studied the differences between AudioInputI2S and AudioInputQuadI2S and I see that its loading 4 blocks instead of 2, but I can't really understand the pipeline.
A lot of the magic seems to come from DMAChannel but it's fairly hard to follow.
If it's possible, a point in the right direction would be appreciated.

Thanks

OK,
this sound interesting.
first, some notational clarification.
Teensy has one I2S engine with 2 I2S data ports. Each I2S port can handle 2 I2S devices (like in stereo, left-right channel). So, you can have in total 4 microphones and 4 speakers. In SAI (Synchronous Audio) protocol there are only two channels L/R per data port possible. So 4 SAI sensors is not an issue. Using the audio library, these 4 channels are only properly demultiplexed, for easy channel to channel processing. You must process each channel separately and/or pass them to a 4 channel IS output (for the four speakers).

Changing the protocol (i.e not SAI but TDM) then each I2S channel can handle up to 32 words (SAI is defined for 2 words). So if you daisy-chain your sensors (i.e ADC's) in such a way that after frame sync all ADC's shifting their data out sequentially, then you can have up to 32 ADC's on each I2S data port, so in total 64 ADC's / I2S.

Obviously, there are some caveats
The max data rate decreases a factor of 16 compared to SAI.
TDM is not foreseen in audio library.
External hardware must be build, e.g daisy-chaining multi ADC's. (but after all this is an hardware project). what this implies, have a look into some Analog Devices or TI ADC datasheets.
 
Just want to add here, that although an I2S cell can handle two stereo channels simultainiously, the channels share a CLK. So whatever audio you're feeding into them, must be synchronised, i.e. by the micro being the clock master. Please dont make the mistake of thinking you can push audio in by two different clock masters working at different rates or out of phase at the same rate.

Tell us a little more about what you expect this device to do from the user perspective. If they don't need to be synchronised at all, but you just need to switch between them, muxing is the way to go. I'd possibly suggest muxing three or four channels into a single I2S input. That makes your software simpler.

If any of the inputs are analogue, rather than I2S, then look at the Teensy Audio board (sgtl5000). That will mux between an I2S input and a sterero analogue input (doing the ADC stuff for you).
 
Thanks for the replies,

So WMXZ, what you're saying is there are 2 stereo I2S inputs and with proper multiplexing you can pipe the data into different buffers and effectively have more inputs at a slower rate?

At the root of the design 2 inputs will be from HDMI decoders as I2S streams and the third input will be either be from an external analog source, or from HDMI backfeed from the encoder (like when smart tvs have netflix apps, they can optionally pipe that audio back through the HDMI sources they aren't using in order to share audio)

The project in total has a 2 4 HDMI multiplexers that will choose which 2 inputs go into HDMI encoders which will provide I2S streams for the audio, which we will need to in put into the teensy, and provide delay control, volume control, and choose which analog output it gets mapped to. The professor who has us building this just decided that if we are going through all this trouble, he would like to be able to have a 3rd audio input that he could use for aux audio such as a bluetooth adapter.

The use of this device will actually be for controlling a "whole house" surround sound system that is currently working via a hodge podge of splitters, adapters, amplifiers, and IR repeaters. but has low utility because the audio is out of sync with the tvs.

To get the project done we may end up daisy chaining two teensies together, not the best design and comes with its own problems, but we only need to make 1 of these and the cost of the board is already upwards of $400
 
Not quite. If you're using I2S you can have two stereo inputs (or four mono inputs) at the same rate. There is only one master clock signal that clocks in both inputs together.

The slower data rate was only in reference to WXMZ's suggestion to use TDM and "daisy chain" devices together. That sounds interesting, but quite elaborate. I'm guessing there would be some logic devices there to make the shift regsiter?? Either way, I dont think that is what you need for your project.

Do you have a link to the datasheet for the HDMI multiplexers and encoders?

How many analogue outputs do you have? and what were you planning to use to turn the I2S back to analogue audio?
 
The project in total has a 2 4 HDMI multiplexers that will choose which 2 inputs go into HDMI encoders which will provide I2S streams for the audio, which we will need to in put into the teensy, and provide delay control, volume control, and choose which analog output it gets mapped to. The professor who has us building this just decided that if we are going through all this trouble, he would like to be able to have a 3rd audio input that he could use for aux audio such as a bluetooth adapter.

The two 4 HDMI multiplexers will take both I2S data ports.
If you need only additional audio, consider either the internal ADC's (there a lot of them, but limited to 13 bit quality, and the need for Antialiasing filter), or get you an external SPI ADC.
 
The decoder is http://www.analog.com/media/en/technical-documentation/data-sheets/ADV7611.pdf
But as WMXZ is saying, they output i2s and will consume both ports on the teensy.

using an ADC is definitely an option, though I do need 16 bit quality to make the professor happy.

I'm new to the teensy world and I don't quite understand using DMAChannel to read and write from pins. but if I had an I2C or SPI ADC I would just need to make an AudioStream class for it that would read the 16bit data for each channel and assign it to a "block" correct? How is all the timing handled?
 
Just a quick look at the ADV7611 seems to show it only works as an I2S master.

Teensy's quad channel (two stereo) I2S only works in master mode.
 
The slower data rate was only in reference to WXMZ's suggestion to use TDM and "daisy chain" devices together. That sounds interesting, but quite elaborate. I'm guessing there would be some logic devices there to make the shift regsiter?? Either way, I dont think that is what you need for your project.

Here is a link describing daisy-chaining for SPI devices https://www.maximintegrated.com/en/app-notes/index.mvp/id/3947
and here an ADC, the one I'm using in the moment, where in the text they describe how to daisy-chain multiple devices http://www.ti.com/lit/ds/symlink/ads8881.pdf (Figure 60)
 
Last edited:
Just a quick look at the ADV7611 seems to show it only works as an I2S master.

Teensy's quad channel (two stereo) I2S only works in master mode.

I was worried about that, but It seemed like it could be worked around, though I wasn't sure. I could just use 2 teensys but it still doesn't get me out of hot water.

Means, that DiamondDrake has to make a custom adaption. (editing only one line (AFAIR) should be not an issue, apart from testing)

Edit: There was some other thread on master slave https://forum.pjrc.com/threads/2707...-Teensy-3-x-help?p=97205&viewfull=1#post97205 .

if it's possible to make quad channel slave supported without much work I'm having a little trouble seeing how that works. I read the related thread but I wasn't quite sure what it was referring to it sounded like someone was saying you could just ignore the clocks, but i don't follow that. I'm having a hard time with the i2s section in the datasheet since i'm new to audio, I understand how audio serial data is sent, but the data sheet is a little hard to digest. It's not actually all that clear what pins are what.

it says there 2 data channels for receive, but there are 2 channels mixed together in I2S, alternating right left. Is this the 2 data channels? or are there LR and data clock inputs for each of 2 separate input pins.

Here is a link describing daisy-chaining for SPI devices https://www.maximintegrated.com/en/app-notes/index.mvp/id/3947
and here an ADC, the one I'm using in the moment, where in the text they describe how to daisy-chain multiple devices http://www.ti.com/lit/ds/symlink/ads8881.pdf (Figure 60)

This is some interesting reading, I see what you're going for here, taking samples at the same time and then clocking them in back to back. Assuming the ADCs had data in /out pass though capability, then you could latch 2 16 bit signals an then clock in 32 bits and you would have both samples. from the same point in time interleaved, you would just have to break them apart. Similar to now i2s already mixes two signals.


I come from the world of AVR micros, and this arm with dsp is a bit of a transition. I still don't understand all of what DMAChannel is doing, and how pins/registers are being accessed using it, but I'm trying to process it.


So what I'm taking away from this is, If i just want another input, I can use an external ADC (or two, that I can clock data in from) that will get me a third input assuming I don't actually need one to be i2S which technically I don't.

This does put in me in another state of concern, driving to slave I2s inputs, and 2 master I2S outputs, at the same time, with at least 1 ADC SPI based input. And making them all play nice together. Has anyone done this much with one teensy before?

Thank you for your time, I appreciate all the time you all have taken to help me on this.
 
This does put in me in another state of concern, driving to slave I2s inputs, and 2 master I2S outputs, at the same time, with at least 1 ADC SPI based input. And making them all play nice together. Has anyone done this much with one teensy before?

I believe you're not quite grasping the problem of both sides using master mode. Think of ordinary AC power cords. Plugs to into sockets. You can't connect 2 male plugs to each other, and even if you did somehow, nothing happens because they're both expecting to receive power from a socket.
 
I believe you're not quite grasping the problem of both sides using master mode. Think of ordinary AC power cords. Plugs to into sockets. You can't connect 2 male plugs to each other, and even if you did somehow, nothing happens because they're both expecting to receive power from a socket.

The master/slave relationship is just who is clocking who correct?

I guess I'm going to have to use a teensy for each I2s channel and then use muxes for routing the outputs to the desired locations. If anyone has any good suggestions as to another way I'm open to ideas
 
OK,
this sound interesting.
first, some notational clarification.
Teensy has one I2S engine with 2 I2S data ports. Each I2S port can handle 2 I2S devices (like in stereo, left-right channel). So, you can have in total 4 microphones and 4 speakers. In SAI (Synchronous Audio) protocol there are only two channels L/R per data port possible. So 4 SAI sensors is not an issue. Using the audio library, these 4 channels are only properly demultiplexed, for easy channel to channel processing. You must process each channel separately and/or pass them to a 4 channel IS output (for the four speakers).

Hi WMXZ,
If each i2s port can handle 2 devices, can I connect two 43434 mics with the same connections (CLK to pin 9, WS to pin 23 and SD to pin 13) for both, for simultaneous recording?
 
I believe the I2S quad mode might still be using BLCK/LRCLK ratio of 32 (it's on my todo list....). Those mics need the ratio to be 64.
 
I believe the I2S quad mode might still be using BLCK/LRCLK ratio of 32 (it's on my todo list....). Those mics need the ratio to be 64.

Thanks for the reply! Hmm so I am not able to connect 2 43434 mics to one teensy 3.2 board to record simultaneously?
 
You can connect two mics with the normal stereo I2S. Those mics have 1 pin which configures whether the mic transmits it data during the left channel or right channel. So two can be used on a single I2S data line.

The normal stereo I2S object does use the 64 ratio these mics require.
 
You can connect two mics with the normal stereo I2S. Those mics have 1 pin which configures whether the mic transmits it data during the left channel or right channel. So two can be used on a single I2S data line.

The normal stereo I2S object does use the 64 ratio these mics require.

Ohhh I see... Thanks a lot!
 
You can connect two mics with the normal stereo I2S. Those mics have 1 pin which configures whether the mic transmits it data during the left channel or right channel. So two can be used on a single I2S data line.

The normal stereo I2S object does use the 64 ratio these mics require.

Apart from the L and R connection, the connection for both mics to the teensy board are exactly to the same pins?
 
Noted, thanks! I tried it but my recorded waveform looks like this: photo_2018-03-12_22-50-20.jpg . The current code im using is:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioInputI2S i2s1; //xy=346,91
AudioOutputUSB usb1; //xy=530,91
AudioConnection patchCord1(i2s1, 0, usb1, 0);
AudioConnection patchCord2(i2s1, 1, usb1, 1);
// GUItool: end automatically generated code

void setup()
{
AudioMemory(8);

}

void loop()
{
}
 
Status
Not open for further replies.
Back
Top