4 channels input and output, 24bits USB soundcard

Status
Not open for further replies.

VNadon

New member
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
20171019_132628_23943831718_o.jpg

Screenshot of a 1kHz pure-tone sent to 1 input and recorded in audacity
SineWave_44samples.jpg

Thanks!

Vincent
 
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...
 
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.
 
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..
 
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
 
Status
Not open for further replies.
Back
Top