Connecting 2 teensy 4.0 with audio signals

Status
Not open for further replies.

DragonSF

Well-known member
What is is the easiest way to connect 2 Teensy (4.0 or 3.6) to stream audio from the first to the second without using any DAC/ADC in between. My Audio project becomes to complex to be handled by one T40, so my idea is to split the work between 2 T40s and pass the MIDI via OSC from 1st T40 to the second.
My idea is: connect SPDIF out of the first to SPDIF in to the second and the use the DAC of the second as Audio Out. I'm not sure, if that will work.
 
Curious if you had a plan to do SPDIF in. I could use this as well, but the audio library doesn't natively have an input module for SPDIF. I believe the only native ways to do that connection digitally are I2S and TDM, both of which require more pins and resources.

Bit of a bummer too, your idea would have helped me out immensely!

Update: I just noticed that you can't use I2S at the same time as the SPDIF output. So this would effectively knock it out for me as well. Ah well!
 
My Audio project becomes to complex to be handled by one T40

You might want to post exactly what the issue is, because it's almost certainly not too much for the T4. You would be surprised how powerful it is.

But, anyway, you could connect I2S out from one T4 to I2S in of another T4.
 
For me it’s not a processing issue, it’s a connection issue. I am hoping to make an interface that (among a few other functions) would connect to two separate computers for USB audio. My current thought is to use two Teensys that are linked to pass audio between them. I2S isn’t a great option as I’d already have (potentially) two audio shields on at least one of them. I don’t need a ton of extra processing so at this point I’m looking at Teensy 3.2 or 3.5.

Since the two units would be next to each other and on this interface would only be talking to each other, I could define a new way for them to exchange data. But...I’m not that smart. The key for me is that it can’t block any other transport that I’m going to use.
 
Hi Frank! Thanks for the quick reply.

I do know. I thought I read in the audio library that only one I2S object can be used at a time though. So it I were using one for the audio shields. I would not be able to use another for inter-Teensy transfer.

You would know better than I, does the SPDIF object block the use of either I2S port, or just one? I thought I read that the audio shields is out if using SPDIF.

There is also the issue of figuring out a SPDIF input module!
 
The audio GUI currently does not have separate object definitions for the different I2S interfaces. So you would manually edit the generated code to do that, which is not a big deal.

As long as your application doesn't care about phase / latency between the audio provided by the two Teensies, I don't see why you couldn't do such a thing.
 
On T4, SPDIF, if you use SPDIF3 (for output) it uses the inbuilt SPDIF hardware (I don't think it's tested very well - long Time ago that I wrote it and I found no indication that anyone uses it - there may be issues)
SPDIF-IN hardware does exists to, but is not in the library, at the moment. There is a pullrequest for that, but I have not tested it for a very long time now. Maybe it has issues, too.
Feel free to fix any issues, it's open source.
 
The audio GUI currently does not have separate object definitions for the different I2S interfaces. So you would manually edit the generated code to do that, which is not a big deal.

Ah, I thought there was a larger issue with using multiple interfaces. I didn’t realize it would be possible if I manually defined things. I will look into this, thank you!
 
On T4, SPDIF, if you use SPDIF3 (for output) it uses the inbuilt SPDIF hardware (I don't think it's tested very well - long Time ago that I wrote it and I found no indication that anyone uses it - there may be issues)
SPDIF-IN hardware does exists to, but is not in the library, at the moment. There is a pullrequest for that, but I have not tested it for a very long time now. Maybe it has issues, too.
Feel free to fix any issues, it's open source.

Is this on your github? I’ll take a look. I am not using T4 at the moment, but once USB audio is done I don’t see a reason not to switch to it. The advantage (as I see it) is that I should be able to get two channels bi-directional audio for only two pins on each side, which is nice. That said, I could just do a separate I2S connection and end up with 2, 4, or more channels for 3 pins.
 
You might want to post exactly what the issue is, because it's almost certainly not too much for the T4. You would be surprised how powerful it is.

But, anyway, you could connect I2S out from one T4 to I2S in of another T4.

I posted the issue somewhere else here. My project consists of 96 oscillators, 30 multipliers, 6 filters (heavy of CPU), echo delays (ext RAM),flanger and reverb. When I play 1 voice, there is no problem, but with more then 1 voice played simultaneously, I'm getting noise and other artifacts in the output.
 
You mean, the pins (14/15) are the same, but the object has different names?
 
Last edited:
OK, I got SPDIF out working and on SPDIF in I'm getting the SPDIF Signal, though I had to cut the pin, which goes to the audio shield. I can get the Sample Rate correctly, but no Audio. The signal looks OK to me on the scope.
Do I have to use more than 'begin()' as setup?
BTW: I have tested with analog connections and the systems runs as I hoped (i.e. without any noise or artifacts). This means 1 T40 for all the 6 voices and 1 T40 for effects only.
 
Thanks; I'll look tomorrow.

I appreciate that. Update: I'm getting some sound, but it's very distorted.
Edit: after some fiddling with the voices, the sound is now clear as expected.
Thanks for the SPDIF3 object.
 
Last edited:
I just realized, that what was accomplished here opens a new horizon. Now we can have virtually unlimited power bu connecting as many T40s as necessary to get extremely complex audio synthesis/processing. Latency is very low and the wiring is straightforward. Just one serial line from the first T40 (with MIDI IF) to the last (with OSC SlipSerial). Audio stream goes the same via SPDIF. So only the last T40 needs to have a DAC (even that is not required, if SPDIF out is enough).
 
I just realized, that what was accomplished here opens a new horizon. Now we can have virtually unlimited power bu connecting as many T40s as necessary to get extremely complex audio synthesis/processing. Latency is very low and the wiring is straightforward. Just one serial line from the first T40 (with MIDI IF) to the last (with OSC SlipSerial). Audio stream goes the same via SPDIF. So only the last T40 needs to have a DAC (even that is not required, if SPDIF out is enough).

btw, you can use all 3x SPDIF out.


You're right, something with spdif-in is not working.
I have sound, but very distorted. I'll try to fix that - wonder what the reason is..
 
Something with calling the Audio-Lib interna update() is wrong.

A workaround to make it work (I'm still searching for the reason):
Define the spdif_in after I2S - this way, I2S is responsible for calling the update():
Code:
#include <Audio.h>
#include <Wire.h>

AudioOutputI2S           i2s1;           //xy=427,178
AudioInputSPDIF3         spdif_in;   [COLOR=#ff0000][B] //AFTER AudioOutputI2S!![/B][/COLOR]
AudioConnection          patchCord2(spdif_in, 0, i2s1, 0);
AudioConnection          patchCord3(spdif_in, 1, i2s1, 1);
AudioControlSGTL5000     sgtl5000_1;

void setup() {
  AudioMemory(25);
  sgtl5000_1.enable();
  sgtl5000_1.volume(0.6);
  pinMode(13, 1);
}

void loop() {
  delay(150);
  Serial.println(spdif_in.pllLocked());
  Serial.println(spdif_in.sampleRate());
}

Edit: Then, there is a problem with the cache.
Workaround:
Edit startup.c in cores, and set the cache for RAM (AXI bus) to NOCACHE:
Code:
    SCB_MPU_RBAR = 0x20200000 | REGION(3); // RAM (AXI bus)
    SCB_MPU_RASR = [COLOR=#ff0000]MEM_NOCACHE[/COLOR] | READWRITE | NOEXEC | SIZE_1M;

I'll fix that... but not today.


Edit:
If someone is reading this who searches for SPDIF_IN:
- Sample-frequency must be 44100Hz. Audio-equipment often has 48Khz - this will _not_ work without switching the whole library to 48kHz.
- Input from a Teensy 3 SPDIF-Out (44117Hz) is not tested yet and may not work.
 
Last edited:
A little trick with the Teensy 4 Audioshield (REV-D):
If you remove the capacitor on Pin15, and solder a two-pin Pinheader to the GND+VOL pin on the audioshield, you have a nice connector for SPDIF-IN :)
 
That left me no peace.

Attached a working file (only very minor changes were needed). I can't update my original pullrequest - will do that tomorrow. Good night.
 

Attachments

  • input_spdif3.cpp
    6.5 KB · Views: 71
Last edited:
Status
Not open for further replies.
Back
Top