Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

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

  1. #1
    Junior Member
    Join Date
    Apr 2021
    Posts
    8

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

    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 :

    Click image for larger version. 

Name:	4CH Waveform.jpg 
Views:	11 
Size:	56.6 KB 
ID:	26581


    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.

    Click image for larger version. 

Name:	Patern.PNG 
Views:	9 
Size:	16.9 KB 
ID:	26582

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

    Click image for larger version. 

Name:	Shifted.jpg 
Views:	11 
Size:	23.8 KB 
ID:	26583

    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/47114...973#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 !

  2. #2
    Junior Member
    Join Date
    Apr 2021
    Posts
    8
    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 by VP.dplns; 11-26-2021 at 04:24 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •