TDM Master Xcore-200 using version 7.0.0

Discussions about USB Audio on XMOS devices
xmos_user123
Junior Member
Posts: 6
Joined: Tue Oct 01, 2024 1:43 am

TDM Master Xcore-200 using version 7.0.0

Post by xmos_user123 »

Hi All,

I'm trying to use the XMOS as a TDM Master and simply do 8 channels of TDM audio on a single pin. I see there are issues due to low level timing with xcore-200 in the newer versions of SW_USB_AUDIO [https://github.com/xmos/sw_usb_audio/issues/99] and I've been experiencing issues where the data will drop for up to 750ms at a time. I'm trying to revert to USB Audio version 7.0.0 where I had a TDM master setup working in the past, however, when I try to run

Code: Select all

xmake all
on version 7.0.0 I get the following error:

Code: Select all

Checking https://www.xmos.com for required libraries
ERROR: No compatible version found for lib_xua.
ERROR: No compatible version found for lib_xud.
For context:
I'm using this version of USB Audio: https://github.com/xmos/sw_usb_audio/tree/v7.0.0alpha0
XTC Version: 15.1.4
User avatar
Ross
Verified
XCore Legend
Posts: 1071
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

The older releases of USB Audio are using the old build system (the original xcommon), that try and grab dependencies from xmos.com, but they do not reside there at the moment (we are actually looking to revert back to supporting this old model as it assists people where GitHub access is an issue)

It seems we are no longer linking to old releases on the main USB Audio pages on xmos.com. I'll get this rectified, they are linked here: https://www.xmos.com/file/sw_usb_audio-sw/

You can also grab the whole source code bundle from the release "assets" on the GitHub release page, in this instance, https://github.com/xmos/sw_usb_audio/re ... .0.0alpha0

Newer releases of USB audio come equipped with the "new" build system: xcommon-cmake. This will grab dependencies automatically for you (currently from GitHub, but we're looking to extend to grabbing from xmos.com when that's fully populated again - again this helps people without good GitHub access, users in China for example)

TBH it would probably be best to try and support you on the latest code-base. It's likely not a hard issue to solve on the bench, remotely does add another element of course!

In the code-base we're prioritised making xcore.ai designs more robust, removing the lines referenced in the issue would help xcore-200 performance.

However, 750ms would be a long time for a low-level issue as described, I would expect a bit shift or similar.

Is the code otherwise un modified?
Technical Director @ XMOS. Opinions expressed are my own
xmos_user123
Junior Member
Posts: 6
Joined: Tue Oct 01, 2024 1:43 am

Post by xmos_user123 »

Hi Ross,

Thanks for those references! I was able to build and run the older version of 8 channel. I was also able to root cause the issue to a Mac settings. For some reason the audio tends has the cutting out behaviour with my default Mac settings, but if I go to Logic Pro -> Settings -> Audio and select the input/output devices there instead, the audio no longer cuts out. I wonder if it has to do with explicit setting the IO Buffer size? Either way I can build 8, 16, and 32 channel TDM8 configs with no issues.
Screenshot 2024-10-01 at 11.55.45 AM.png
I did have another request (I can make a separate thread for this if you prefer): Is there a way to do an internal fanout so we have 8 channels out of the Mac, but duplicates the same 8 channels on 4 different pins to have 32 channels out?
You do not have the required permissions to view the files attached to this post.
User avatar
Ross
Verified
XCore Legend
Posts: 1071
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

Pleased to hear you're up and running!

So, you'll want to set NUM_USB_CHAN_OUT to 8, I2S_CHANS_DAC to 32 and XUA_PCM_FORMAT to XUA_PCM_FORMAT_TDM, but I suspect you already have this sorted.

Then you'll want to over-ride the weak symbol

Code: Select all

UserBufferManagement(unsigned sampsFromUsbToAudio[], unsigned sampsFromAudioToUsb[])
by putting a custom implementation somewhere in your codebase (default implementation is empty)

I'm not sure of the exact channel mappings you had in mind, but I show an example below, Excuse magic numbers..

Code: Select all

void UserBufferManagement(unsigned sampsFromUsbToAudio[], unsigned sampsFromAudioToUsb[])
{
	/*
	[0] -> [0]
	[1] -> [1]
	...
	[0] -> [24]
	[1] -> [25]
	...
	*/
	for(int i = 24; i > 7; i-=8)
    		for(int j = 7; j >= 0; j--)
    		{
        		sampsFromUsbToAudio[j+i] = sampsFromUsbToAudio[j];
    		}

}
You might want to unroll this for performance. Also

Code: Select all

#pragma unsafe arrays
might be your friend (one you've got it working and deffo not got any out of bounds accesses!)
Technical Director @ XMOS. Opinions expressed are my own