From owner-freebsd-multimedia@freebsd.org Wed Dec 26 08:38:37 2018 Return-Path: Delivered-To: freebsd-multimedia@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CE47E13472CC for ; Wed, 26 Dec 2018 08:38:37 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id D4D876C456 for ; Wed, 26 Dec 2018 08:38:35 +0000 (UTC) (envelope-from hps@selasky.org) Received: by mailman.ysv.freebsd.org (Postfix) id 92DF613472CB; Wed, 26 Dec 2018 08:38:35 +0000 (UTC) Delivered-To: multimedia@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7059A13472CA for ; Wed, 26 Dec 2018 08:38:35 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (turbocat.net [88.99.82.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EE9896C455 for ; Wed, 26 Dec 2018 08:38:34 +0000 (UTC) (envelope-from hps@selasky.org) Received: from hps2016.home.selasky.org (31.89-11-148.nextgentel.com [89.11.148.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id A6F2B2601E2; Wed, 26 Dec 2018 09:38:26 +0100 (CET) Subject: Re: Stumped with multi-channel USB sound output To: Andrew Reilly , multimedia@freebsd.org References: <5042D970-166F-4D13-8B0C-BD7216064567@bigpond.net.au> From: Hans Petter Selasky Message-ID: <2e491e79-cc0b-9742-c907-fdb89b130f40@selasky.org> Date: Wed, 26 Dec 2018 09:36:08 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <5042D970-166F-4D13-8B0C-BD7216064567@bigpond.net.au> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: EE9896C455 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.97 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.971,0]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Dec 2018 08:38:38 -0000 On 12/26/18 5:44 AM, Andrew Reilly wrote: > Hi there, > > I've recently acquired one of these: > https://www.minidsp.com/products/usb-audio-interface/u-dac8 to do some multi-amp speaker crossover hi-fi tweaking. Since my FreeBSD-12.STABLE file server is quite close to my amplifier, I thought that I'd start by using it to drive the DAC. > > It is a USB Audio Class 2.0 device, and as such is recognised seemingly well by the snd_uaudio driver (loaded by /boot/loader.conf, as it doesn't seem to be compiled-in): > Hi, > and for dev.pcm: > > dev.pcm.0.feedback_rate: 47999 ^ can you sample this parameter over time. Because your device does not have any recording endpoints, this value will be used to decide how many additional or less samples will be sent. Also check the that USB cable has good connection. Sometimes if the cable is slightly bad, data may be lost. Isochronous traffic has no re-transmi. Try also to enable USB audio debugging: sysctl hw.usb.uaudio.debug=15 > dev.pcm.0.mixer.mute_1.desc: > dev.pcm.0.mixer.mute_1.max: 1 > dev.pcm.0.mixer.mute_1.min: 0 > dev.pcm.0.mixer.mute_1.val: 0 > dev.pcm.0.mixer.vol_0.desc: > dev.pcm.0.mixer.vol_0.max: 0 > dev.pcm.0.mixer.vol_0.min: -32512 > dev.pcm.0.mixer.vol_0.val: -11475 > dev.pcm.0.bitperfect: 0 > dev.pcm.0.buffersize: 0 > dev.pcm.0.play.vchanformat: s16le:2.0 ^ In order to use 8 channels you need to set this sysctl to s32le:7.1 or s24le:7.1 > dev.pcm.0.play.vchanrate: 48000 > dev.pcm.0.play.vchanmode: fixed > dev.pcm.0.play.vchans: 1 > dev.pcm.0.hwvol_mixer: vol > dev.pcm.0.hwvol_step: 5 > dev.pcm.0.%parent: uaudio0 > dev.pcm.0.%pnpinfo: > dev.pcm.0.%location: > dev.pcm.0.%driver: pcm > dev.pcm.0.%desc: USB audio > dev.pcm.%parent: > > I think that is saying (working from the bottom up) that userland is sending data which is being sample-rate converted using the default (q:1) sample rate converter to 48kHz, and then feeder_matrix(2.0 -> 7.1) is probably trying to do the right thing to drive eight output channels? Unless you set the bitperfect option or vchanformat, this is the case. > That looks as though my eight channels is being mixed down to two (on the last line) and then up-mixed to eight (7.1)? I don't want it to do that. How do I stop it? See hints about setting sysctl options. > Also, this hardware is perfectly capable of running at 44100Hz, as shown in the dmesg output. Is there a way to tell the pcm driver to set the hardware sample rate, rather than do sample rate conversion in software? sysctl hw.usb.uaudio.default_rate=44100 > > Is there any documentation about any of this? The pcm(4) man page says that there is matrixing support to handle channel routing and up/down mixing, but it isn't particularly clear about the possibilities. > but the audio output distortion is the same. Despite the distorted output, sndstat is indicating that there are no underruns, and there are no kernel messages showing up in the dmesg buffer about pcm misbehaviour. > The problem is the formula in: static void uaudio_chan_play_sync_callback(struct usb_xfer *xfer, usb_error_t error) in sys/dev/sound/usb/uaudio.c Maybe you can play with it. > Am I going to win, with additional tweaking, do you think? Or will I be better off setting up a Raspberry Pi or the like, running linux, to drive it? Raspberry Pi doesn't work very well with USB audio devices of this kind. What kind of USB host are you using? Are there any USB HUBs in between? Try connecting directly to the computer? > Where can I find documentation about the mixer/feeder architecture, to interpret those sndstat outputs? Maybe send a patch if you think something is very useful? --HPS