Teensy 4.1 USB 4CH IN - 2 CH OUT Sync issue

VP.dplns

Member
Hi everyone,
I'm working on to make the teensy appearing like a 4 IN 4 OUT sound card.
The 4CH IN is working pretty well.
The next part I wanted to try is to send from a PC, 2CH of sound, duplicate them on 4CH in the teensy, recording it with the 4CH input from the teensy and send the 4CH in USB to the PC.
That part is kind of working and here is the waveform I'm obtaining by sending 50 and 100Hz of pure-tone :

4CH Waveform.jpg


We can observe there is a patern repeting an issue every 1280 samples.
The patern is composed of 896 of audio data the 128 samples of zeros, then the following 256 samples of the audio data shifted of 128 samples and the it drops to the actual audio signal and follow the same pattern.

Patern.PNG

If the audio was not shifted by the 128 samples of zeros we would have a perfect sinus.

Shifted.jpg

One thing I experienced is the teensy is playing sound correctly when I plug it into the PC and when I open the windows sound setting it starts being distorted and follow the previous pattern.
I think it's because it's starting to play and record at the same time. (Output device and Input device on the same window)

I also experienced that with the playrec function of matlab using asio to play and rec simultaneously. When I just play sound, the sound is clear. When I play and record at the same time the audio is distorted.
I don't know why but sometimes I can play and record at the same time with no issues and the next time I use it, it's distorted.
It make me think it's an issue about synchronization, maybe the feedback is not setting correctly or something like that.

I saw on the forum that someone has the same issue in the past :
https://forum.pjrc.com/threads/4711...tput-24bits-USB-soundcard?p=156973#post156973

That thread talk about a potential DMA setting.

Is anyone having any experience with that kind of issue ?
I think i'm not far away to have the 4IN 2OUT working but I start to run out of possible solution to solve the issue.

Thank you very much !
 
Hi everyone,

The 2CH OUT - 4CH IN seems to work now. (USB IN connected to USB OUT)

That was a part that I forgot to modify in AudioOutputUSB::update()

exactly :

Code:
if (ch3 == NULL) 
	{
		ch3 = allocate();
		if (ch3 == NULL) {
			release(ch1);
			release(ch2);
			release(ch4); //VP : Maybe we need to do if ch3 =0 and ch4=0 
			
			return;
		}
		memset(ch3->data, 0, sizeof(ch3->data));
	}
	
	if (ch4 == NULL) 
	{
		ch4 = allocate();
		if (ch4 == NULL) {
			release(ch1);
			release(ch2);
			release(ch3); 
			
			return;
		}
		memset(ch4->data, 0, sizeof(ch4->data));
	}
 
Last edited:
Hi there - I'm excited to hear you have this working because it's exactly the configuration I need for a project I'm working on. Is your code accessible anywhere?
 
Hi,
We achieved to make it work unfortunetly we are not ready to release the code for now.
Sorry about that..
 
Back
Top