You are not logged in.

#1 2020-02-03 05:25:05

Batou
Member
Registered: 2017-01-03
Posts: 259

Linux and USB Audio Class 2 (UAC2) external DACs. Can it be enabled?

Hi all,

I've been curious about this issue for a while now and have read a lot of web pages but I just haven't been able to find an answer to this issue. I'm hoping that someone here is knowledgeable enough to explain it to me.

If you use an external DAC that's connected through a USB, the OS can send audio to it in two modes: USB Audio Class 1 and Class 2 modes. Cambridge Audio explains the difference as:

So what's the difference between Class 1 and Class 2?

The difference is in the resolution of music they can deliver. Class 1 will give you a BIG improvement in sound compared to your computers own headphone output, however class 2 will take you one step further. Class 1 can send up to a maximum of 24- bit/96kHz hi-res files, but if you want to play those studio master quality files you’ll need to step up to Class 2. This supports up to 24  bit/192 kHz resolution files, for those seeking absolute audio perfection.

By default Macs support both Class 1 and Class 2, meaning you can easily send files up to 24-bit/192kHz to your DAC from your Mac. However Windows doesn’t play as nicely. It isn’t compatible with both, and only supports Class 1 as default.

But all is not lost Windows lovers; if you are using Windows you can still play those super high quality hi-res files! Just install a Class 2 USB driver.

https://www.cambridgeaudio.com/en/blog/ … d-i-use-it
video: https://www.youtube.com/watch?v=xMcsVj6icZI

I use a Schiit audio DAC and it works OK under Linux (I've run into an issue with timing in the past but have managed to mitigate it with the help from V1del). However, I do not know how to enable Class 2 audio path under Linux.

I've tested my DAC under Windows (in a VM, with a driver) and with a Mac and you can tell when you're using Class 2 audio since the audio volume cannot be modified by the OS or any other app anymore. The only way to change the volume is through the external device. That makes sense since Class 2 spec specifies that a raw PCM is being sent.

However, under Linux, I can easily change the volume with Alsa, DE, music or a video player. So this leads me to believe that I don't have Class 2 audio enabled.

If you do a search, say "linux usb audio class 2", you will find a dearth of information on this topic. Someone answered it on some other forum as "Linux supports it" with a link to source:
https://git.kernel.org/cgit/linux/kerne … b/format.c Other post is this one: https://linuxmusicians.com/viewtopic.php?t=19262 (also clear as mud answers).

Schiit itself says this:

You do not need drivers for Mac or for Linux distros that support UAC2.
https://www.schiit.com/drivers

Well, does it really? How do you put it in Class 2 mode? How can you tell whether it's in Class 1 or 2 mode under Linux? No matter what I do, I can modify the volume though the OS. So it's always in Class 1?

Thanks for any info smile

Last edited by Batou (2020-02-03 05:29:18)


Please vote for all the AUR packages you're using. You can mass-vote for all of them by doing: "pacman -Qqm | xargs aurvote -v" (make sure to run "aurvote --configure"  first)

Offline

#2 2020-02-03 06:26:19

d_fajardo
Member
Registered: 2017-07-28
Posts: 1,563

Re: Linux and USB Audio Class 2 (UAC2) external DACs. Can it be enabled?

Class 1 can send up to a maximum of 24- bit/96kHz hi-res files, but if you want to play those studio master quality files you’ll need to step up to Class 2. This supports up to 24  bit/192 kHz resolution files, for those seeking absolute audio perfection.

I believe your DAC should be able to do this automatically depending in your input file. In my system, I use mpd to play and read DSD file and I am able to play these files in their given bitrate (192/24khz).
So I think it's a matter of deciding how to send this higher resolution files to your DAC.

Offline

#3 2020-02-03 07:02:21

Batou
Member
Registered: 2017-01-03
Posts: 259

Re: Linux and USB Audio Class 2 (UAC2) external DACs. Can it be enabled?

d_fajardo wrote:

Class 1 can send up to a maximum of 24- bit/96kHz hi-res files, but if you want to play those studio master quality files you’ll need to step up to Class 2. This supports up to 24  bit/192 kHz resolution files, for those seeking absolute audio perfection.

I believe your DAC should be able to do this automatically depending in your input file. In my system, I use mpd to play and read DSD file and I am able to play these files in their given bitrate (192/24khz).
So I think it's a matter of deciding how to send this higher resolution files to your DAC.

How do you know your DAC is in UAC2 mode? mpd could be downsampling the file for all you know.
Can you change the volume through your player of choice or through your DE? If so, it's not UAC2.


Please vote for all the AUR packages you're using. You can mass-vote for all of them by doing: "pacman -Qqm | xargs aurvote -v" (make sure to run "aurvote --configure"  first)

Offline

#4 2020-02-03 08:11:39

d_fajardo
Member
Registered: 2017-07-28
Posts: 1,563

Re: Linux and USB Audio Class 2 (UAC2) external DACs. Can it be enabled?

I have a Cambridge Audio DacMagic Plus. There are LED's in the DAC that shows the input bitrate so I can tell what the input bitrate is. You can configure mpd to be bit-perfect if you search the internet.
I change the volume directly through my DAC.
I also use JACK Audio Connection Kit for certain things. JACK also can be configured to output files in higher bitrate.
I am not really sure what UAC2 but just saying it is possible to input to DAC the actual bitrate of the audio file.

Offline

#5 2020-02-03 10:11:06

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,427

Re: Linux and USB Audio Class 2 (UAC2) external DACs. Can it be enabled?

This needs a bit more information about what you are doing. You usually want passthrough, so you need an SPDIF device, and play back to that directly (or enable passthrough modes on e.g. pulseaudio) .

So what is that you "no matter what" are doing exactly?

aplay -lL
amixer -c$correctCardIndex
#If pulse
pacmd list-cards
pacmd list-sinks

FWIW though I'm admittedly not that invested in the topic, from my googling UAC2 doesn't inherently make any statement over whether passthrough is possible, just that different sample rates are supported and exposed and can be used as such. That doesn't necessarily mean that any volume control from the OS is prohibited, just that it could actually open the device with different sample rates.

Last edited by V1del (2020-02-03 10:25:53)

Offline

#6 2020-02-03 18:03:09

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,680
Website

Re: Linux and USB Audio Class 2 (UAC2) external DACs. Can it be enabled?

Batou wrote:

under Linux, I can easily change the volume with Alsa, DE, music or a video player. So this leads me to believe that I don't have Class 2 audio enabled.

Both "Class 1" and "Class 2" are digital (S/PDIF) outputs and so do not contain any information pertaining to the volume level. The ability to control the volume depends on the device rather than the "Class" of output.

For example, I have an AudioQuest DragonFly Cobalt USB headphone DAC and that includes a 64-bit digital volume control that can be changed from the operating system:

AudioQuest wrote:

With DragonFly Red/Cobalt connected to a PC or mobile device, adjusting the host’s system volume control will, through proxy, control the DragonFly’s onboard volume.

What is the exact model of DAC you are using? Check the manufacturer's information to see if it is similarly endowed and check the dmesg output to see if it is correctly identified.

Linux certainly does support UAC2[1] and I'm pretty sure that it will be selected automatically as long as your device is recognised. But I don't know how to verify that, unfortunately.

If your DAC has an indicator for the sample rate then you can test for 192KHz reproduction with:

speaker-test -r 192000

And `pacmd list-sinks` should also display the sample rate (whilst speaker-test is running ofc).

d_fajardo wrote:

I use mpd to play and read DSD file and I am able to play these files in their given bitrate (192/24khz).

DSD is a bitstream format rather than PCM so "24/192" doesn't make any sense, the sample rates for DSD are 2.8224MHz or a multiple thereof but this is not directly comparable to PCM sampling rates.

And your DAC doesn't support DSD anyway smile

Offline

#7 2020-02-03 19:28:32

Batou
Member
Registered: 2017-01-03
Posts: 259

Re: Linux and USB Audio Class 2 (UAC2) external DACs. Can it be enabled?

V1del wrote:

This needs a bit more information about what you are doing. You usually want passthrough, so you need an SPDIF device, and play back to that directly (or enable passthrough modes on e.g. pulseaudio) .

So what is that you "no matter what" are doing exactly?

aplay -lL
amixer -c$correctCardIndex
#If pulse
pacmd list-cards
pacmd list-sinks

FWIW though I'm admittedly not that invested in the topic, from my googling UAC2 doesn't inherently make any statement over whether passthrough is possible, just that different sample rates are supported and exposed and can be used as such. That doesn't necessarily mean that any volume control from the OS is prohibited, just that it could actually open the device with different sample rates.

Cambridge Audio states in their documentation that you won't be able to change audio through the OS once you enable Class 2 audio. When you try it on a Mac or in Windows, it seems to confirm this behavior.

Here's how it looks like when I connect my Schiit Modi to a Mac laptop: https://gfycat.com/politicalenchantedemperorshrimp

Those high-end CA DACs have a status screen that shows you when it's in Class 2 mode but on cheaper stuff (like my Schiit), the device has no status of any kind to indicate the mode it's in.

Some outputs as requested (lots of useless Nvidia stuff... because my monitor has speakers and can receive audio from Nvidia card through the HDMI):

$ aplay -lL
null
    Discard all samples (playback) or generate zero samples (capture)
jack
    JACK Audio Connection Kit
default
    Default ALSA Output (currently PulseAudio Sound Server)
sysdefault:CARD=Device
    USB Modi Device, USB Audio
    Default Audio Device
front:CARD=Device,DEV=0
    USB Modi Device, USB Audio
    Front speakers
surround21:CARD=Device,DEV=0
    USB Modi Device, USB Audio
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=Device,DEV=0
    USB Modi Device, USB Audio
    4.0 Surround output to Front and Rear speakers
surround41:CARD=Device,DEV=0
    USB Modi Device, USB Audio
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Device,DEV=0
    USB Modi Device, USB Audio
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Device,DEV=0
    USB Modi Device, USB Audio
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Device,DEV=0
    USB Modi Device, USB Audio
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=Device,DEV=0
    USB Modi Device, USB Audio
    IEC958 (S/PDIF) Digital Audio Output
usbstream:CARD=Device
    USB Modi Device
    USB Stream Output
hdmi:CARD=HDMI,DEV=0
    HDA Intel HDMI, HDMI 0
    HDMI Audio Output
hdmi:CARD=HDMI,DEV=1
    HDA Intel HDMI, HDMI 1
    HDMI Audio Output
hdmi:CARD=HDMI,DEV=2
    HDA Intel HDMI, HDMI 2
    HDMI Audio Output
hdmi:CARD=HDMI,DEV=3
    HDA Intel HDMI, HDMI 3
    HDMI Audio Output
hdmi:CARD=HDMI,DEV=4
    HDA Intel HDMI, HDMI 4
    HDMI Audio Output
usbstream:CARD=HDMI
    HDA Intel HDMI
    USB Stream Output
hdmi:CARD=NVidia,DEV=0
    HDA NVidia, HDMI 0
    HDMI Audio Output
hdmi:CARD=NVidia,DEV=1
    HDA NVidia, HDMI 1
    HDMI Audio Output
hdmi:CARD=NVidia,DEV=2
    HDA NVidia, HDMI 2
    HDMI Audio Output
hdmi:CARD=NVidia,DEV=3
    HDA NVidia, HDMI 3
    HDMI Audio Output
usbstream:CARD=NVidia
    HDA NVidia
    USB Stream Output
**** List of PLAYBACK Hardware Devices ****
card 0: Device [USB Modi Device], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: HDMI [HDA Intel HDMI], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: HDMI [HDA Intel HDMI], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: HDMI [HDA Intel HDMI], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: HDMI [HDA Intel HDMI], device 9: HDMI 3 [HDMI 3]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: HDMI [HDA Intel HDMI], device 10: HDMI 4 [HDMI 4]
  Subdevices: 1/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 2: NVidia [HDA NVidia], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 9: HDMI 3 [HDMI 3]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
 
 $ amixer -c0
Simple mixer control 'PCM',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
 $ pacmd list-cards

<nvidia stuff removed>
...


    index: 6
	name: <alsa_card.usb-Schiit_Audio_USB_Modi_Device-00>
	driver: <module-alsa-card.c>
	owner module: 32
	properties:
		alsa.card = "0"
		alsa.card_name = "USB Modi Device"
		alsa.long_card_name = "Schiit Audio USB Modi Device at usb-0000:00:14.0-3.1, high speed"
		alsa.driver_name = "snd_usb_audio"
		device.bus_path = "pci-0000:00:14.0-usb-0:3.1:1.0"
		sysfs.path = "/devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3.1/2-3.1:1.0/sound/card0"
		udev.id = "usb-Schiit_Audio_USB_Modi_Device-00"
		device.bus = "usb"
		device.vendor.id = "0d8c"
		device.vendor.name = "C-Media Electronics, Inc."
		device.product.id = "0319"
		device.product.name = "USB Modi Device"
		device.serial = "Schiit_Audio_USB_Modi_Device"
		device.string = "0"
		device.description = "USB Modi Device"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-usb"
	profiles:
		output:analog-stereo: Analog Stereo Output (priority 6500, available: unknown)
		output:iec958-stereo: Digital Stereo (IEC958) Output (priority 5500, available: unknown)
		off: Off (priority 0, available: unknown)
	active profile: <output:analog-stereo>
	sinks:
		alsa_output.usb-Schiit_Audio_USB_Modi_Device-00.analog-stereo/#6: USB Modi Device Analog Stereo
	sources:
		alsa_output.usb-Schiit_Audio_USB_Modi_Device-00.analog-stereo.monitor/#6: Monitor of USB Modi Device Analog Stereo
	ports:
		analog-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
			properties:
				
		iec958-stereo-output: Digital Output (S/PDIF) (priority 0, latency offset 0 usec, available: unknown)
			properties:
	

This one is the most interesting:

 $  pacmd list-sinks

... nvidia hdmi removed...

* index: 6
	name: <alsa_output.usb-Schiit_Audio_USB_Modi_Device-00.analog-stereo>
	driver: <module-alsa-card.c>
	flags: HARDWARE HW_MUTE_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
	state: SUSPENDED
	suspend cause: IDLE
	priority: 9049
	volume: front-left: 45880 /  70% / -9.29 dB,   front-right: 45880 /  70% / -9.29 dB
	        balance 0.00
	base volume: 65536 / 100% / 0.00 dB
	volume steps: 65537
	muted: no
	current latency: 0.00 ms
	max request: 0 KiB
	max rewind: 0 KiB
	monitor source: 6
	sample spec: s16le 2ch 48000Hz
	channel map: front-left,front-right
	             Stereo
	used by: 0
	linked by: 5
	configured latency: 0.00 ms; range is 0.50 .. 1837.50 ms
	card: 6 <alsa_card.usb-Schiit_Audio_USB_Modi_Device-00>
	module: 32
	properties:
		alsa.resolution_bits = "16"
		device.api = "alsa"
		device.class = "sound"
		alsa.class = "generic"
		alsa.subclass = "generic-mix"
		alsa.name = "USB Audio"
		alsa.id = "USB Audio"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		alsa.device = "0"
		alsa.card = "0"
		alsa.card_name = "USB Modi Device"
		alsa.long_card_name = "Schiit Audio USB Modi Device at usb-0000:00:14.0-3.1, high speed"
		alsa.driver_name = "snd_usb_audio"
		device.bus_path = "pci-0000:00:14.0-usb-0:3.1:1.0"
		sysfs.path = "/devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3.1/2-3.1:1.0/sound/card0"
		udev.id = "usb-Schiit_Audio_USB_Modi_Device-00"
		device.bus = "usb"
		device.vendor.id = "0d8c"
		device.vendor.name = "C-Media Electronics, Inc."
		device.product.id = "0319"
		device.product.name = "USB Modi Device"
		device.serial = "Schiit_Audio_USB_Modi_Device"
		device.string = "front:0"
		device.buffering.buffer_size = "352800"
		device.buffering.fragment_size = "176400"
		device.access_mode = "mmap+timer"
		device.profile.name = "analog-stereo"
		device.profile.description = "Analog Stereo"
		device.description = "USB Modi Device Analog Stereo"
		alsa.mixer_name = "USB Mixer"
		alsa.components = "USB0d8c:0319"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-usb"
	ports:
		analog-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
			properties:
				
	active port: <analog-output>
 

Last edited by Batou (2020-02-03 19:29:48)


Please vote for all the AUR packages you're using. You can mass-vote for all of them by doing: "pacman -Qqm | xargs aurvote -v" (make sure to run "aurvote --configure"  first)

Offline

#8 2020-02-03 19:53:37

Batou
Member
Registered: 2017-01-03
Posts: 259

Re: Linux and USB Audio Class 2 (UAC2) external DACs. Can it be enabled?

Head_on_a_Stick wrote:
Batou wrote:

under Linux, I can easily change the volume with Alsa, DE, music or a video player. So this leads me to believe that I don't have Class 2 audio enabled.

Both "Class 1" and "Class 2" are digital (S/PDIF) outputs and so do not contain any information pertaining to the volume level. The ability to control the volume depends on the device rather than the "Class" of output.

For example, I have an AudioQuest DragonFly Cobalt USB headphone DAC and that includes a 64-bit digital volume control that can be changed from the operating system:

AudioQuest wrote:

With DragonFly Red/Cobalt connected to a PC or mobile device, adjusting the host’s system volume control will, through proxy, control the DragonFly’s onboard volume.

What is the exact model of DAC you are using? Check the manufacturer's information to see if it is similarly endowed and check the dmesg output to see if it is correctly identified.

So how is the audio volume encoded?
Do audio/video players alter the audio waveform in any way when you change the volume? For example, if you play a Youtube video, does moving the volume slider alter the audio waveform in any way before it's passed to a DAC? Any idea how the audio information is encoded when it's sent over a USB? I presume it's some kind of a standard...

Linux certainly does support UAC2[1] and I'm pretty sure that it will be selected automatically as long as your device is recognised. But I don't know how to verify that, unfortunately.

I'm also certain that it does. I just can't tell when it's in that mode and whether my DAC automatically switches to UAC2 when it's connected or if it stays in UAC1 like under Windows without a driver. Under macOS, it definitely switches to UAC2 as soon as you connect it. Not sure if it's even possible to switch it to UAC1 under macOS.

If your DAC has an indicator for the sample rate then you can test for 192KHz reproduction with:

speaker-test -r 192000

And `pacmd list-sinks` should also display the sample rate (whilst speaker-test is running ofc).

I tried this. I started the speaker-test and then checked the sinks:

 $ speaker-test -r 192000

speaker-test 1.2.1

Playback device is default
Stream parameters are 192000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
Rate set to 192000Hz (requested 192000Hz)
Buffer size range from 192 to 2097152
Period size range from 64 to 699051
Using max buffer size 2097152
Periods = 4
was set period_size = 524288
was set buffer_size = 2097152
 0 - Front Left
Time per period = 2.742650
 0 - Front Left
Time per period = 2.743575
 0 - Front Left
Time per period = 2.741316
 0 - Front Left
^C

and the only thing that changed when I ran the pacmd while the speaker-test was running was the "current latency".

 $ pacmd list-sinks
2 sink(s) available. 

<nvidia hdmi crap>

 * index: 6
	name: <alsa_output.usb-Schiit_Audio_USB_Modi_Device-00.analog-stereo>
	driver: <module-alsa-card.c>
	flags: HARDWARE HW_MUTE_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
	state: RUNNING
	suspend cause: (none)
	priority: 9049
	volume: front-left: 45880 /  70% / -9.29 dB,   front-right: 45880 /  70% / -9.29 dB
	        balance 0.00
	base volume: 65536 / 100% / 0.00 dB
	volume steps: 65537
	muted: no
	current latency: 23.23 ms
	max request: 4 KiB
	max rewind: 4 KiB
	monitor source: 6
	sample spec: s16le 2ch 48000Hz
	channel map: front-left,front-right
	             Stereo
	used by: 1
	linked by: 6
	configured latency: 24.99 ms; range is 0.50 .. 1837.50 ms
	card: 6 <alsa_card.usb-Schiit_Audio_USB_Modi_Device-00>
	module: 32
	properties:
		alsa.resolution_bits = "16"
		device.api = "alsa"
		device.class = "sound"
		alsa.class = "generic"
		alsa.subclass = "generic-mix"
		alsa.name = "USB Audio"
		alsa.id = "USB Audio"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		alsa.device = "0"
		alsa.card = "0"
		alsa.card_name = "USB Modi Device"
		alsa.long_card_name = "Schiit Audio USB Modi Device at usb-0000:00:14.0-3.1, high speed"
		alsa.driver_name = "snd_usb_audio"
		device.bus_path = "pci-0000:00:14.0-usb-0:3.1:1.0"
		sysfs.path = "/devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3.1/2-3.1:1.0/sound/card0"
		udev.id = "usb-Schiit_Audio_USB_Modi_Device-00"
		device.bus = "usb"
		device.vendor.id = "0d8c"
		device.vendor.name = "C-Media Electronics, Inc."
		device.product.id = "0319"
		device.product.name = "USB Modi Device"
		device.serial = "Schiit_Audio_USB_Modi_Device"
		device.string = "front:0"
		device.buffering.buffer_size = "352800"
		device.buffering.fragment_size = "176400"
		device.access_mode = "mmap+timer"
		device.profile.name = "analog-stereo"
		device.profile.description = "Analog Stereo"
		device.description = "USB Modi Device Analog Stereo"
		alsa.mixer_name = "USB Mixer"
		alsa.components = "USB0d8c:0319"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-usb"
	ports:
		analog-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
			properties:
				
	active port: <analog-output>

So, since I can hear the audio when it's played at 192kHz, that means it's in UAC2 mode, right? Or maybe it's being downsampled because I can also hear the noise if I switch to my monitor's speakers? Not sure this is a good test. I just wish there was another way to confirm it...

Last edited by Batou (2020-02-03 20:17:55)


Please vote for all the AUR packages you're using. You can mass-vote for all of them by doing: "pacman -Qqm | xargs aurvote -v" (make sure to run "aurvote --configure"  first)

Offline

#9 2020-02-03 20:16:48

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,427

Re: Linux and USB Audio Class 2 (UAC2) external DACs. Can it be enabled?

For the simplest form of raw no volume control direct access

speaker-test -Diec958 -r 192000

to properly route this over pulse, switch that to the iec port

pacmd set-card-profile alsa_output.usb-Schiit_Audio_USB_Modi_Device-00  iec958-stereo-output

and start enabling formats that should be passed through without prior conversion, easiest would be to check pavucontrol and tick relevant boxes under the iec sink (and maybe enable 'avoid-resampling' in your /etc/pulse/daemon.conf)

Offline

#10 2020-02-03 20:24:22

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,680
Website

Re: Linux and USB Audio Class 2 (UAC2) external DACs. Can it be enabled?

Batou wrote:

So how is the audio volume encoded?

That depends on the device and the driver. If the device accepts a digital input and has no on-board volume control then it shouldn't be possible to change the volume. Any information about the volume level that is sent to a USB audio device is separate from the S/PDIF output.

Batou wrote:
 $ pacmd list-sinks
[...]
	sample spec: s16le 2ch 48000Hz

Looks like your device only supports 48KHz with 16 bits of dynamic resolution (or PA is not configured correctly).

From my machine whilst playing 96KHz:

sample spec: s24le 2ch 96000Hz

Offline

#11 2020-02-03 20:54:11

Batou
Member
Registered: 2017-01-03
Posts: 259

Re: Linux and USB Audio Class 2 (UAC2) external DACs. Can it be enabled?

V1del wrote:

For the simplest form of raw no volume control direct access

speaker-test -Diec958 -r 192000

to properly route this over pulse, switch that to the iec port

pacmd set-card-profile alsa_output.usb-Schiit_Audio_USB_Modi_Device-00  iec958-stereo-output

and start enabling formats that should be passed through without prior conversion, easiest would be to check pavucontrol and tick relevant boxes under the iec sink (and maybe enable 'avoid-resampling' in your /etc/pulse/daemon.conf)

This is very cool! Thank you again V1del! I guess the standard that governs USB digital playback is IEC958. pavucontrol lists both the analog and digital output for Modi. I'm guessing analog is UAC1 and digital is UAC2?

MIa5QKA.png


CK3a7vd.png

Edit: One thing I've noticed after selecting Digital Output manually (with pacmd) is that the volume is a LOT louder. Before I had to crank up the volume quite high but now I can set it to be low. I don't think that Alsa/Pulse selects IEC958 automatically as you plug in the device. I think it uses analog by default.

Edit 2: After ticking off all of the boxes and setting the avoid-resampling and rebooting, the sound sounds very different. I don't think this is placebo. Oh, and volume knob on my amp is now at around 20% mark (before it was at 90%).

m0sAmsU.png

After a reboot, only AC3 remained checked. Hmmm... any idea where I could set these options in a conf file? I don't see anything in /etc/pulse/daemon.conf

Last edited by Batou (2020-02-03 21:52:32)


Please vote for all the AUR packages you're using. You can mass-vote for all of them by doing: "pacman -Qqm | xargs aurvote -v" (make sure to run "aurvote --configure"  first)

Offline

#12 2020-02-03 21:59:27

Batou
Member
Registered: 2017-01-03
Posts: 259

Re: Linux and USB Audio Class 2 (UAC2) external DACs. Can it be enabled?

Head_on_a_Stick wrote:

Looks like your device only supports 48KHz with 16 bits of dynamic resolution (or PA is not configured correctly).

From my machine whilst playing 96KHz:

sample spec: s24le 2ch 96000Hz

It definitely supports 192KHz:

Sample Rates/Bit Depths: 16/44.1 to 24/192 via USB. 16/44.1 to 24/192 via Toslink* and Coax.

Source: https://www.head-fi.org/showcase/schiit … ber.20495/

I'm not sure how to enable it exactly...

Edit : After changing the default format to s24le I get:

 	properties:
		alsa.resolution_bits = "24"
		device.api = "alsa"
		device.class = "sound"
		alsa.class = "generic"
		alsa.subclass = "generic-mix"
		alsa.name = "USB Audio"
		alsa.id = "USB Audio"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		alsa.device = "0"
		alsa.card = "0"
		alsa.card_name = "USB Modi Device"
		alsa.long_card_name = "Schiit Audio USB Modi Device at usb-0000:00:14.0-3.1, high speed"
		alsa.driver_name = "snd_usb_audio"
		device.bus_path = "pci-0000:00:14.0-usb-0:3.1:1.0"
		sysfs.path = "/devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3.1/2-3.1:1.0/sound/card0"
		udev.id = "usb-Schiit_Audio_USB_Modi_Device-00"
		device.bus = "usb"
		device.vendor.id = "0d8c"
		device.vendor.name = "C-Media Electronics, Inc."
		device.product.id = "0319"
		device.product.name = "USB Modi Device"
		device.serial = "Schiit_Audio_USB_Modi_Device"
		device.string = "iec958:0"
		device.buffering.buffer_size = "529200"
		device.buffering.fragment_size = "264600"
		device.access_mode = "mmap+timer"
		device.profile.name = "iec958-stereo"
		device.profile.description = "Digital Stereo (IEC958)"
		device.description = "USB Modi Device Digital Stereo (IEC958)"
		alsa.mixer_name = "USB Mixer"
		alsa.components = "USB0d8c:0319"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-usb"

Interestingly, Audacious now shows volume as missing! The audio plays fine.  From reading man pages, I could also set the sample rate as 192k but then PA would have to resample the audio if your source audio isn't 192k. Not sure if it's possible to set it to it adjusts automatically.

ypczf7.jpg

Last edited by Batou (2020-02-04 00:03:52)


Please vote for all the AUR packages you're using. You can mass-vote for all of them by doing: "pacman -Qqm | xargs aurvote -v" (make sure to run "aurvote --configure"  first)

Offline

#13 2020-02-04 06:10:23

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,680
Website

Re: Linux and USB Audio Class 2 (UAC2) external DACs. Can it be enabled?

I'm not completely sure about the intricacies of PA & ALSA configuration, hopefully V1del will be able to help you with that.

FWIW the only configuration I have is

# ~/.config/pulse/daemon.conf
avoid-resampling = true

Offline

#14 2020-02-04 21:34:56

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,427

Re: Linux and USB Audio Class 2 (UAC2) external DACs. Can it be enabled?

Batou wrote:

I'm guessing analog is UAC1 and digital is UAC2?

Without having delved too deep into the driver code, I don't think it's that black and white, from my understanding it always uses UAC2 but maps a digital out and an analog out device for ALSA/pulse to play back to and then internally transfers this over to something that makes sense for the end device regardless of choice. FWIW the fact that plain ALSA only exposes a IEC/on/off control on a mixer level reinforces that for me. What is a given that you don't have a passthrough choice on analog so only a final mix will reach the adapter, but I'd assume that you are actually able to drive the analog to sample rates/bit depths outside of UAC1 spec

But as mentioned this part really isn't something i dug into too deeply so this might be off base.


One thing I've noticed after selecting Digital Output manually (with pacmd) is that the volume is a LOT louder. Before I had to crank up the volume quite high but now I can set it to be low. I don't think that Alsa/Pulse selects IEC958 automatically as you plug in the device. I think it uses analog by default.

By default pulse prioritizes analog sinks indeed, if we look back at the cards output

profiles:
		output:analog-stereo: Analog Stereo Output (priority 6500, available: unknown)
		output:iec958-stereo: Digital Stereo (IEC958) Output (priority 5500, available: unknown)

the priority here defines which profile should be selected by default, granted the user hasn't explicitly made a choice yet. Due to the fact that you knowingly switched that now, this should be remembered and it should default to SPDIF in the future. Is that not the case?

After a reboot, only AC3 remained checked. Hmmm... any idea where I could set these options in a conf file? I don't see anything in /etc/pulse/daemon.conf

Have you double checked in the manual or so that all these formats are actually supported? FWIW what you could do is add at the end of your /etc/pulse/default.pa

###Don't fail server startup if the device isn't available/setting formats fails
.nofail
set-card-profile alsa_output.usb-Schiit_Audio_USB_Modi_Device-00  iec958-stereo-output
set-sink-formats alsa_output.usb-Schiit_Audio_USB_Modi_Device-00.iec958-stereo-output pcm; ac3-iec61937; dts-iec61937; eac3-iec61937;mpeg-iec61937;mpeg2-aac-iec61937

Interestingly, Audacious now shows volume as missing! The audio plays fine.  From reading man pages, I could also set the sample rate as 192k but then PA would have to resample the audio if your source audio isn't 192k. Not sure if it's possible to set it to it adjusts automatically.

That's what the avoid-resampling option is for. when that is set to true, it will - if possible - and you aren't already playing something from your sink, reconfigure it to open up with the sample rate/format of the first application you start playback with (all the ones started after will have to adjust to that initially selected rate, until you stop everything, and restart playback with something else. Generally pulse goes for the "safe" defaults which is why standard setting is to only try 44100 and 48000 without trying to adjust to the input sources.

FWIW regarding checking other capabilities the card exposes it might be interesting to look at what information it's producing when running an

sudo lsusb -v -d 0d8c:0319

Offline

#15 2020-02-04 23:29:13

Batou
Member
Registered: 2017-01-03
Posts: 259

Re: Linux and USB Audio Class 2 (UAC2) external DACs. Can it be enabled?

Thanks again V1del!
I'll play with these other options.
The manual is very terse and has no information about the formats it supports: https://www.schiit.com/public/upload/PD … al_2_1.pdf
Here's the output of lsusb:

 $ sudo lsusb -v -d 0d8c:0319

Bus 002 Device 057: ID 0d8c:0319 C-Media Electronics, Inc. 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          239 Miscellaneous Device
  bDeviceSubClass         2 
  bDeviceProtocol         1 Interface Association
  bMaxPacketSize0        64
  idVendor           0x0d8c C-Media Electronics, Inc.
  idProduct          0x0319 
  bcdDevice            1.05
  iManufacturer           1 Schiit Audio
  iProduct                2 USB Modi Device
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x012a
    bNumInterfaces          3
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xc0
      Self Powered
    MaxPower              500mA
    Interface Association:
      bLength                 8
      bDescriptorType        11
      bFirstInterface         0
      bInterfaceCount         2
      bFunctionClass          1 Audio
      bFunctionSubClass       0 
      bFunctionProtocol      32 
      iFunction               0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         1 Audio
      bInterfaceSubClass      1 Control Device
      bInterfaceProtocol     32 
      iInterface              2 USB Modi Device
      AudioControl Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      1 (HEADER)
        bcdADC               2.00
        bCategory              10
        wTotalLength       0x0100
        bmControls           0x00
      AudioControl Interface Descriptor:
        bLength                17
        bDescriptorType        36
        bDescriptorSubtype      2 (INPUT_TERMINAL)
        bTerminalID             1
        wTerminalType      0x0101 USB Streaming
        bAssocTerminal          0
        bCSourceID             18
        bNrChannels             0
        bmChannelConfig    0x00000000
        iChannelNames           0 
        bmControls         0x0040
          Cluster Control (read-only)
        iTerminal               0 
      AudioControl Interface Descriptor:
        bLength                12
        bDescriptorType        36
        bDescriptorSubtype      3 (OUTPUT_TERMINAL)
        bTerminalID             7
        wTerminalType      0x0301 Speaker
        bAssocTerminal          0
        bSourceID              13
        bCSourceID             18
        bmControls         0x0000
        iTerminal               0 
      AudioControl Interface Descriptor:
        bLength                18
        bDescriptorType        36
        bDescriptorSubtype      6 (FEATURE_UNIT)
        bUnitID                13
        bSourceID               1
        bmaControls(0)     0x00000003
          Mute Control (read/write)
        bmaControls(1)     0x00000000
        bmaControls(2)     0x00000000
        iFeature                0 
      AudioControl Interface Descriptor:
        bLength                 8
        bDescriptorType        36
        bDescriptorSubtype     10 (CLOCK_SOURCE)
        bClockID               18
        bmAttributes            3 Internal programmable clock 
        bmControls           0x07
          Clock Frequency Control (read/write)
          Clock Validity Control (read-only)
        bAssocTerminal          0
        iClockSource            0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x8f  EP 15 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0006  1x 6 bytes
        bInterval               4
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol     32 
      iInterface              4 Speaker-Schiit USB Audio Device
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       1
      bNumEndpoints           2
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol     32 
      iInterface              0 
      AudioStreaming Interface Descriptor:
        bLength                16
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink           1
        bmControls           0x05
          Active Alternate Setting Control (read-only)
          Valid Alternate Setting Control (read-only)
        bFormatType             1
        bmFormats          0x00000001
          PCM
        bNrChannels             2
        bmChannelConfig    0x00000003
          Front Left (FL)
          Front Right (FR)
        iChannelNames           0 
      AudioStreaming Interface Descriptor:
        bLength                 6
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bSubslotSize            2
        bBitResolution         16
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x05  EP 5 OUT
        bmAttributes            5
          Transfer Type            Isochronous
          Synch Type               Asynchronous
          Usage Type               Data
        wMaxPacketSize     0x0068  1x 104 bytes
        bInterval               1
        AudioStreaming Endpoint Descriptor:
          bLength                 8
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes         0x00
          bmControls           0x00
          bLockDelayUnits         0 Undefined
          wLockDelay         0x0000
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x85  EP 5 IN
        bmAttributes           17
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Feedback
        wMaxPacketSize     0x0004  1x 4 bytes
        bInterval               4
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       2
      bNumEndpoints           2
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol     32 
      iInterface              0 
      AudioStreaming Interface Descriptor:
        bLength                16
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink           1
        bmControls           0x05
          Active Alternate Setting Control (read-only)
          Valid Alternate Setting Control (read-only)
        bFormatType             1
        bmFormats          0x00000001
          PCM
        bNrChannels             2
        bmChannelConfig    0x00000003
          Front Left (FL)
          Front Right (FR)
        iChannelNames           0 
      AudioStreaming Interface Descriptor:
        bLength                 6
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bSubslotSize            3
        bBitResolution         24
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x05  EP 5 OUT
        bmAttributes            5
          Transfer Type            Isochronous
          Synch Type               Asynchronous
          Usage Type               Data
        wMaxPacketSize     0x009c  1x 156 bytes
        bInterval               1
        AudioStreaming Endpoint Descriptor:
          bLength                 8
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes         0x00
          bmControls           0x00
          bLockDelayUnits         0 Undefined
          wLockDelay         0x0000
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x85  EP 5 IN
        bmAttributes           17
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Feedback
        wMaxPacketSize     0x0004  1x 4 bytes
        bInterval               4
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       3
      bNumEndpoints           2
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol     32 
      iInterface              0 
      AudioStreaming Interface Descriptor:
        bLength                16
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink           1
        bmControls           0x05
          Active Alternate Setting Control (read-only)
          Valid Alternate Setting Control (read-only)
        bFormatType             1
        bmFormats          0x00000001
          PCM
        bNrChannels             2
        bmChannelConfig    0x00000003
          Front Left (FL)
          Front Right (FR)
        iChannelNames           0 
      AudioStreaming Interface Descriptor:
        bLength                 6
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bSubslotSize            4
        bBitResolution         32
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x05  EP 5 OUT
        bmAttributes            5
          Transfer Type            Isochronous
          Synch Type               Asynchronous
          Usage Type               Data
        wMaxPacketSize     0x00d0  1x 208 bytes
        bInterval               1
        AudioStreaming Endpoint Descriptor:
          bLength                 8
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes         0x00
          bmControls           0x00
          bLockDelayUnits         0 Undefined
          wLockDelay         0x0000
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x85  EP 5 IN
        bmAttributes           17
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Feedback
        wMaxPacketSize     0x0004  1x 4 bytes
        bInterval               4
    Interface Association:
      bLength                 8
      bDescriptorType        11
      bFirstInterface         2
      bInterfaceCount         1
      bFunctionClass          3 Human Interface Device
      bFunctionSubClass       0 
      bFunctionProtocol       0 
      iFunction               0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.00
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      24
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x84  EP 4 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0010  1x 16 bytes
        bInterval               4
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass          239 Miscellaneous Device
  bDeviceSubClass         2 
  bDeviceProtocol         1 Interface Association
  bMaxPacketSize0        64
  bNumConfigurations      1
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0001
  Self Powered

Last edited by Batou (2020-02-04 23:32:55)


Please vote for all the AUR packages you're using. You can mass-vote for all of them by doing: "pacman -Qqm | xargs aurvote -v" (make sure to run "aurvote --configure"  first)

Offline

#16 2020-02-09 17:56:03

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,680
Website

Re: Linux and USB Audio Class 2 (UAC2) external DACs. Can it be enabled?

Batou wrote:

The manual is very terse and has no information about the formats it supports

The device supports the PCM format.

Offline

Board footer

Powered by FluxBB