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

Thread: 4 channels input and output, 24bits USB soundcard

  1. #1
    Junior Member
    Join Date
    Oct 2017
    Posts
    4

    4 channels input and output, 24bits USB soundcard

    Hi guys,

    I am trying to modify the audio library to support 4 channels with 24bit-depth. I basically have 32bits samples that I cut to 24 later.

    I am very close to get everything working, however the input signal is not correct. There seems to be an overlap in the buffers somewhere, see screenshot of a pure-tone sine wave. The number of samples selected corresponds to the FRAME_BY_BLOCK size.

    The I2S buffer seems to operate at the same speed as the USB buffer, but could be slightly out of phase (1kHz I2S and 1kHz USB, see screenshot).

    I think the problem could be caused by a setting in the DMA, however I don't fully understand what I have to use for the modulo (SMOD and DMOD). I tried a few settings but they end up crashing the Teensy. If you think it would be caused by something else let me know.

    Here's the code I have for the DMA setting at the moment:

    Code:
            dma.TCD->SADDR = &I2S0_RDR0;
    	dma.TCD->SOFF = 4;
    	dma.TCD->ATTR = 
    		DMA_TCD_ATTR_SMOD(3) | // 15-11 : Source adress modulo. != 0 activate the feature
    		DMA_TCD_ATTR_SSIZE(2) | // 10-8 : Source tranfer size. (0:8bit,1:16bit,2:32bit), Originally 1
    		DMA_TCD_ATTR_DMOD(0) | 	// 7-3 : Destination adress modulo
    		DMA_TCD_ATTR_DSIZE(2); // 2-0 : Destination tranfer size. (0:8bit,1:16bit,2:32bit)
    		
    	// Number of bytes to transfer (in each service request)	
    	dma.TCD->NBYTES_MLNO = 4;
    	dma.TCD->SLAST = 0;
    	dma.TCD->DLASTSGA = -sizeof(i2s_rx_buffer);
    	
    	dma.TCD->DADDR = i2s_rx_buffer;
    	dma.TCD->DOFF = 4;
    	// Set loop counts
    	dma.TCD->CITER_ELINKNO = sizeof(i2s_rx_buffer) / 4;
    	dma.TCD->BITER_ELINKNO = sizeof(i2s_rx_buffer) / 4;
    	
    	dma.TCD->CSR = DMA_TCD_CSR_INTHALF | DMA_TCD_CSR_INTMAJOR;
    Screenshot of USB vs I2S
    Click image for larger version. 

Name:	20171019_132628_23943831718_o.jpg 
Views:	27 
Size:	127.4 KB 
ID:	11831

    Screenshot of a 1kHz pure-tone sent to 1 input and recorded in audacity
    Click image for larger version. 

Name:	SineWave_44samples.jpg 
Views:	32 
Size:	38.0 KB 
ID:	11830

    Thanks!

    Vincent

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    17,022
    Are you planning to share or contribute this code? Is there a complete copy on github or somewhere else? I could try running it here on dual audio shields...

  3. #3
    Senior Member MickMad's Avatar
    Join Date
    Feb 2013
    Location
    Essonne, France
    Posts
    154
    Quote Originally Posted by PaulStoffregen View Post
    Are you planning to share or contribute this code? Is there a complete copy on github or somewhere else? I could try running it here on dual audio shields...
    There's plenty of update() functions that should be double-checked for correctness too. Also, replying to this post so that I get updates, this is really interesting; this + the dynamic USB change of options that's being tested in another topic could really lead to good stuff in the near future with regards to USB Audio functionality.

  4. #4
    Hi Vincent,
    Very interesting project! Did you manage to solve it?

    I will be happy to get more details and access for the code if that possible!
    I am trying to modify the audio library to work with 4 channels input (USB) for a few month but I couldn't get to solution..

  5. #5
    Senior Member
    Join Date
    Oct 2015
    Location
    Vermont, USA
    Posts
    150
    I, too, tried to modify the I2S library to enable 24-bit or 32-bit transfer of audio data from the audio AIC. I, too, got stymied by DMA settings. Kudos to those who figured it out for 16-bit transfers (is that you, Paul? Thank you!).

    I did not try to do 4-channel transfer; I was just trying to do two channels at 32 bits per sample. I never got it to work. I hope to return to it someday. Unless, of course, someone here is able to solve this problem first!

    Chip

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    17,022
    Yeah, configuring the DMA TCD settings is a bit tricky.

Posting Permissions

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