Device detected without ability to capture the input stream

Discussions about USB Audio on XMOS devices
tMi
New User
Posts: 3
Joined: Fri Sep 22, 2023 12:31 pm

Device detected without ability to capture the input stream

Post by tMi »

Hi.

I wanted the XK-AUDIO-316-MC-AB to work as a sound card on my linux (Linux 5.15.131-1-MANJARO) system. I need 8x input and 8x output so I used:
xmake CONFIG=2AMi8o8xxxxxx
The device has been detected.
lsusb:
Bus 003 Device 005: ID 20b1:f7d5 XMOS Ltd XMOS XTAG-4
Bus 001 Device 058: ID 20b1:0016 XMOS Ltd XMOS xCORE.ai MC (UAC2.0)
cat /proc/asound/card2/stream0
XMOS XMOS xCORE.ai MC (UAC2.0) at usb-0000:03:00.0-9, high speed : USB Audio

Playback:
Status: Running
Interface = 1
Altset = 2
Packet Size = 144
Momentary freq = 44105 Hz (0x5.8360)
Feedback Format = 16.16
Interface 1
Altset 1
Format: S32_LE
Channels: 8
Endpoint: 0x01 (1 OUT) (ASYNC)
Rates: 44100, 48000, 88200, 96000, 176400, 192000
Data packet interval: 125 us
Bits: 24
Channel map: FL FR FC LFE RL RR FLC FRC
Sync Endpoint: 0x81 (1 IN)
Sync EP Interface: 1
Sync EP Altset: 1
Implicit Feedback Mode: No
Interface 1
Altset 2
Format: S16_LE
Channels: 8
Endpoint: 0x01 (1 OUT) (ASYNC)
Rates: 44100, 48000, 88200, 96000, 176400, 192000
Data packet interval: 125 us
Bits: 16
Channel map: FL FR FC LFE RL RR FLC FRC
Sync Endpoint: 0x81 (1 IN)
Sync EP Interface: 1
Sync EP Altset: 2
Implicit Feedback Mode: No

Capture:
Status: Stop
Interface 2
Altset 1
Format: S32_LE
Channels: 8
Endpoint: 0x82 (2 IN) (ASYNC)
Rates: 44100, 48000, 88200, 96000, 176400, 192000
Data packet interval: 125 us
Bits: 24
Channel map: FL FR FC LFE RL RR FLC FRC
aplay -l
card 2: MCUAC20 [XMOS xCORE.ai MC (UAC2.0)], device 0: USB Audio [USB Audio]
Subdevices: 0/1
Subdevice #0: subdevice #0

arecord -l
card 2: MCUAC20 [XMOS xCORE.ai MC (UAC2.0)], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
Music from the player or YouTube plays correctly. Also when I use aplay everything works fine.
However, I cannot record sound through the microphone. The LEDs on XMOS are on, arecord (or another program... like audacity) starts without error (I also checked the ADC D0-D3 pins where the stream bits are visible). Recording starts but the track is silent (without any noise).

Does anyone have an idea?


User avatar
fabriceo
XCore Addict
Posts: 188
Joined: Mon Jan 08, 2018 4:14 pm

Post by fabriceo »

Hello,
I would try first changing:
#define NUM_USB_CHAN_IN (2)
"sometime" linux players like to find an Altset exactly with the same parameters.

also I d try to force the feedback endpoint as it is not enabled here:
#define UAC_FORCE_FEEDBACK_EP (1)

please post your findings
tMi
New User
Posts: 3
Joined: Fri Sep 22, 2023 12:31 pm

Post by tMi »

The NUM_USB_CHAN_IN definition works. Linux recognizes it and sets the appropriate number of channels. However, the result is the same: the recording is silent.
But, I also checked the XK-AUDIO-316-MC-AB on windows ( with installed xmos usb audio 2.0 driver ). The result is the same. I see eight output channels ( which already works ) and the same number of input channels ( which can be recording but the soundtrack is just straight line ).
tMi
New User
Posts: 3
Joined: Fri Sep 22, 2023 12:31 pm

Post by tMi »

I have no idea how to start or where to look for the problem. I checked Altset and it seems to be working properly. Depending on the configuration set during recording the system launches a given interface.
But few lines are interesting.
cat /proc/asound/card1/stream0
XMOS XMOS xCORE.ai MC (UAC2.0) at usb-0000:00:15.0-1, high speed : USB Audio

Playback:
Status: Stop
Interface 1
Altset 1
Format: S32_LE
Channels: 8
Endpoint: 0x01 (1 OUT) (ASYNC)
Rates: 44100, 48000, 88200, 96000, 176400, 192000
Data packet interval: 125 us
Bits: 24
Channel map: FL FR FC LFE RL RR FLC FRC
Sync Endpoint: 0x81 (1 IN)
Sync EP Interface: 1
Sync EP Altset: 1

Implicit Feedback Mode: No
Interface 1
Altset 2
Format: S16_LE
Channels: 8
Endpoint: 0x01 (1 OUT) (ASYNC)
Rates: 44100, 48000, 88200, 96000, 176400, 192000
Data packet interval: 125 us
Bits: 16
Channel map: FL FR FC LFE RL RR FLC FRC
Sync Endpoint: 0x81 (1 IN)
Sync EP Interface: 1
Sync EP Altset: 2

Implicit Feedback Mode: No

Capture:
Status: Stop
Interface 2
Altset 1

Format: S32_LE
Channels: 8
Endpoint: 0x82 (2 IN) (ASYNC)
Rates: 44100, 48000, 88200, 96000, 176400, 192000
Data packet interval: 125 us
Bits: 24
Channel map: FL FR FC LFE RL RR FLC FRC
"Sync Endpoint: 0x81 (1 IN)" is directed to the input. However the next few lines show the Sync EP Interface: 1 which is different from the Capture interface.
User avatar
fabriceo
XCore Addict
Posts: 188
Joined: Mon Jan 08, 2018 4:14 pm

Post by fabriceo »

Hi
as you have the same problem on both linux and windows, I would not suspect the USB stack immediately (still I suggest you try the UAC_FORCE_FEEDBACK_EP (1) anyway).

I suggest you patch the handle_audio_request interrupt in decouple.xc so that you loop back an out sample into the samplein table, by overwriting what normally comes from the audio task with sample out[0].

Using a tool like REW, you can then push a sine and see what happens on the receiving side in scope mode. if you get the sine, then the problem is somewhere in the audio.xc, maybe on I2S and clocking. And you can also loopback a sample at different point in this file to identify where is the issue
User avatar
Ross
XCore Expert
Posts: 968
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

fabriceo wrote: Sun Sep 24, 2023 8:37 am

also I d try to force the feedback endpoint as it is not enabled here:
#define UAC_FORCE_FEEDBACK_EP (1)

FYI this is a default setting now. The output above seems also to suggest its used ("implicit feedback mode: no" and "Sync endpoint 0x81 (1 IN)"
User avatar
Ross
XCore Expert
Posts: 968
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

tMi wrote: Fri Sep 29, 2023 9:04 am
"Sync Endpoint: 0x81 (1 IN)" is directed to the input. However the next few lines show the Sync EP Interface: 1 which is different from the Capture interface.
This is expected EP 1 IN is the "feedback" endpoint for the output stream (on EP 1 OUT). The input audio stream is on EP 2 IN
User avatar
Ross
XCore Expert
Posts: 968
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

An easier way of doing fabrices loop suggestion is simply to add the following function somewhere in your source tree:

Code: Select all

void UserBufferManagement(unsigned sampsFromUsbToAudio[], unsigned sampsFromAudioToUsb[])
{
	for(int i = 0; i < NUM_USB_CHAN_IN; i++)
	   sampsFromAudioToUsb[i] = samplesFromUsbToAudio[i]

}
This assumes NUM_USB_CHAN_OUT (i.e. the size of samplesFromUsbToAudio[]) is >= NUM_USB_CHAN_IN 😉
User avatar
Ross
XCore Expert
Posts: 968
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

I guess another obvious suggestion would be to check the volume control. Disable the processing on the code if needs be!