User avatar
TerryC65
Posts: 60
Joined: Sat May 09, 2015 7:50 am
Location: Wimborne, Dorset, UK

Identify Audio Channels (hw:x,y) for two USB Audio Adaptors

Sat Jan 13, 2018 10:23 am

Hi,

Way back in Nov 2016, I posted a query about playing two mp3 files simultaneously through two independent USB audio adaptors for my local Model Town. I got it to work, see viewtopic.php?f=38&t=164784&p=1066454#p1066454, but then fell at the next hurdle because all the adaptors that I could source at that time had the same ID, so it was impossible to determine which was which when directing the audio to the right channel. In the end, I abandoned using a Pi Zero and used a Pi 3 instead because it had an independent audio jack that could be identified and the USB adaptor then stayed on the same channel.

However.... All in the garden is not rosy. During the summer season the system began to suffer from cross-talk and very noticeable hum; a problem that I put down in part at least to the fact that the original 12 V Power Brick for the audio amps failed and the new one is noisy compared to the old one. I've now filtered this and the problem is much reduced, but is still apparent. The real problem seems to be that the Pi itself introduces a hum loop and the audio is modulated onto the hum and so appears on both channels. In an effort to solve this once and for all I bought a new set of USB audio adaptors from a different source and joy of joys :D they have a different ID to the originals.

My problem now is how to translate the information from dmesg, lsusb and aplay -l to allow me to discover the hw: numbers for the two devices programatically.

With both adaptors plugged into this desktop machine, here is the output of lsusb:

Code: Select all

terry@OptiPlex:~$ lsusb
Bus 002 Device 006: ID 0d8c:013c C-Media Electronics, Inc. CM108 Audio Controller
Bus 002 Device 005: ID 045e:0084 Microsoft Corp. Basic Optical Mouse
Bus 002 Device 004: ID 046a:0023 Cherry GmbH CyMotion Master Linux Keyboard G230
Bus 002 Device 003: ID 046d:09a2 Logitech, Inc. QuickCam Communicate Deluxe/S7500
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 8086:0808 Intel Corp. 
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
The C-Media device 0d8c:013c is one adaptor and 8086:0808 is the other.

Here is aplay -l:

Code: Select all

terry@OptiPlex:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC269VB Analog [ALC269VB Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 3: Device [USB PnP Sound Device], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0                                                                                                                                   
card 4: Device_1 [USB PnP Sound Device], device 0: USB Audio [USB Audio]                                                                                       
  Subdevices: 1/1                                                                                                                                              
  Subdevice #0: subdevice #0

As you can see there is no clue as to which [USB PnP Sound Device] is the C-Media one and which is the intel one.

Here is dmesg:

Code: Select all

terry@OptiPlex:~$ dmesg | grep PnP
[    0.107560] pnp: PnP ACPI init
[    0.108176] pnp: PnP ACPI: found 6 devices
[ 7168.666002] usb 1-1.3: Product: USB PnP Sound Device
[ 7168.686080] input: C-Media Electronics Inc.       USB PnP Sound Device as /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.3/1-1.3:1.3/0003:8086:0808.0004/input/input15                                                                                                                                                      
[ 7168.744309] hid-generic 0003:8086:0808.0004: input,hidraw3: USB HID v1.00 Device [C-Media Electronics Inc.       USB PnP Sound Device] on usb-0000:00:1a.0-1.3/input3                                                                                                                                                      
[ 7174.537970] usb 2-1.7: Product: USB PnP Sound Device
[ 7174.558015] input: C-Media Electronics Inc.       USB PnP Sound Device as /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.7/2-1.7:1.3/0003:0D8C:013C.0005/input/input16                                                                                                                                                      
[ 7174.616030] hid-generic 0003:0D8C:013C.0005: input,hidraw4: USB HID v1.00 Device [C-Media Electronics Inc.       USB PnP Sound Device] on usb-0000:00:1d.0-1.7/input3
Suddenly, they both seem to be C-media devices!

What I can't quite see is how I can extract from dmesg and / or lsusb the link that tells me the Card and Subdevice numbers that I can use to play the file using aplay or mpg321. The output from lsusb seems to bear no relation to the Card numbers and the output from dmesg is frankly gobblygook to me.

Can anyone help with the necessary alchemy?

User avatar
TerryC65
Posts: 60
Joined: Sat May 09, 2015 7:50 am
Location: Wimborne, Dorset, UK

Re: Identify Audio Channels (hw:x,y) for two USB Audio Adaptors

Sun Jan 14, 2018 6:25 pm

Replying to myself.

There's been some discussion about this on my local LUG Mailing List, but I've had problems posting the output of aplay -l after a reboot, so here it is:

Code: Select all

terry@OptiPlex:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 1: Device [USB PnP Sound Device], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: PCH [HDA Intel PCH], device 0: ALC269VB Analog [ALC269VB Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 3: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 3: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 4: Device_1 [USB PnP Sound Device], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
Note that the two USB Audio Adaptors are now in different Card numbers.

AJB2K3
Posts: 209
Joined: Sun Aug 11, 2013 3:25 pm

Re: Identify Audio Channels (hw:x,y) for two USB Audio Adaptors

Fri Jan 19, 2018 8:47 pm

TerryC65 wrote:
Sun Jan 14, 2018 6:25 pm
Replying to myself.

There's been some discussion about this on my local LUG Mailing List, but I've had problems posting the output of aplay -l after a reboot, so here it is:

Code: Select all

terry@OptiPlex:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 1: Device [USB PnP Sound Device], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: PCH [HDA Intel PCH], device 0: ALC269VB Analog [ALC269VB Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 3: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 3: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 4: Device_1 [USB PnP Sound Device], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
Note that the two USB Audio Adaptors are now in different Card numbers.
there used to be a way to mk-node and force a new nodename for each device then point the software to the separate nodes but I can't remember how I did this.
I know I used a similar trick to get GPSD to work.
Back in the old days, we were smarter then the technology.
Nowadays technology makes us look like villages fools in front of the children!

User avatar
TerryC65
Posts: 60
Joined: Sat May 09, 2015 7:50 am
Location: Wimborne, Dorset, UK

Re: Identify Audio Channels (hw:x,y) for two USB Audio Adaptors

Sat Jan 20, 2018 7:44 am

AJB2K3 wrote:
Fri Jan 19, 2018 8:47 pm
there used to be a way to mk-node and force a new nodename for each device then point the software to the separate nodes but I can't remember how I did this.
I know I used a similar trick to get GPSD to work.
The local LUG Mailing List denizens have pointed me at a few sites to do this, but I haven't had a chance to work through the process. I hope to sort it out this weekend. If I do, I'll report back.

Return to “Graphics, sound and multimedia”

Who is online

Users browsing this forum: No registered users and 14 guests