USB Audio + 4ch ADC (Mixing) -> DAC(TDM) ?

Discussions about USB Audio on XMOS devices
jungyg
Newbie
Posts: 1
Joined: Sun Aug 18, 2024 1:22 pm

USB Audio + 4ch ADC (Mixing) -> DAC(TDM) ?

Post by jungyg »

Hello. I am new to xmos so I have a question.

I am trying to use XU316 to mix USB Audio source (Stereo) and 4-channel ADC I2S(TDM) signal, and send I2S(TDM) signal to DAC.

ADC: AK5574EN

Is this possible in xcore.ai (XU316)? (In my previous project, I used ADAU1467 for mixing.)

If possible, is there any sample code related to this?
Thank you in advance.
MaximLiadov
XCore Addict
Posts: 143
Joined: Mon Apr 16, 2018 9:14 am

Post by MaximLiadov »

It's certainly possible for any XMOS generation. I have implemented it myself. It is a bit tricky, though, to sum two signed integers without an overflow.

Good style is to just try and ask your questions when you get stuck. IMHO.
User avatar
Ross
Verified
XCore Legend
Posts: 1071
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

The supplied mixer code should handle this with ease.

An example host program to configure the mixer (via USB) is provided.

If you want to hard code the mixer, that will take a bit of code, but shouldn't be too much effort.

The biggest issue here is that we regression test TDM at 8 channels only (as is the common interface and a per the hardware on our boards), however, I suspect setting I2S_CHANS_PER_FRAME appropriately (i.e from 8 to 4) should yield correct results.

In summary, this should be a straight forward project that the 316 is easily capable of.

Good luck :)
Technical Director @ XMOS. Opinions expressed are my own
MaximLiadov
XCore Addict
Posts: 143
Joined: Mon Apr 16, 2018 9:14 am

Post by MaximLiadov »

Great idea if you don't need an additional licence for Thesycon's Mixer API. Ross, could you please confirm that? https://www.thesycon.de/eng/usb_audiodriver.shtml
"The Mixer Add-on is an optional component of the TUSBAudio driver and has to be licensed additionally."

Anyway, to use mixer you need another dedicated core. Makes no sense to me if you need in summing 2 channels with no volume change. You just need some additional arithmetic operations right in place, within the audio procedure, before sending to the DAC.
User avatar
Ross
Verified
XCore Legend
Posts: 1071
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

MaximLiadov wrote: Thu Aug 22, 2024 8:33 am Great idea if you don't need an additional licence for Thesycon's Mixer API. Ross, could you please confirm that? https://www.thesycon.de/eng/usb_audiodriver.shtml
"The Mixer Add-on is an optional component of the TUSBAudio driver and has to be licensed additionally."

Anyway, to use mixer you need another dedicated core. Makes no sense to me if you need in summing 2 channels with no volume change. You just need some additional arithmetic operations right in place, within the audio procedure, before sending to the DAC.
That is a mixer in the host driver, rather than the xcore.

If its just a fixed mix no control will be required from the host in any case.

Sure, there could be more optimal ways of doing things but the method I present requires little coding for a new user, it'll also handle the overflow etc. There are many similar compromises in the sw, for example, the thread count could be considered overkill for a stereo only 48 kHz device but the same codebase can handle 10x channels at 192 kHz.
Technical Director @ XMOS. Opinions expressed are my own
MaximLiadov
XCore Addict
Posts: 143
Joined: Mon Apr 16, 2018 9:14 am

Post by MaximLiadov »

Thank you, Ross! Nice to know. Big respect.

I looked deep inside host_usb_mixer_control project. Correct me if I'm wrong, but it uses Thesycon SDK on Windows platform.
global_h:
#include "tusbaudioapi.h"
#include "TUsbAudioApiDll.h"

I have compiled the project successfully, as I have all of it.
User avatar
Ross
Verified
XCore Legend
Posts: 1071
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

Hey Maxim,

Yes the control app use the SDK to control the mixer in the device, rather than a mixer in the host driver which incurs requires the extra licence.

Hope that makes sense.
Technical Director @ XMOS. Opinions expressed are my own