Re: sndio and bit perfect playback

2022-10-13 Thread Andre Smagin
On Thu, 13 Oct 2022 22:14:33 +0200
Alexandre Ratchov  wrote:

> On Thu, Oct 13, 2022 at 03:11:50AM +, s...@skolma.com wrote:
> > in summary, audio works.. just not bit-perfectly :)
> > does anyone know if SNDIO supports such mode ? and how i might configure it.
> 
> bit-perfect is practical for one thing only: avoid questionings about
> whether the processing adds audible noise & distortion. I've tryed
> various hacks, including bypassing sndiod and neither was very
> practical.
> 
> IMHO, the sndiod resampler covers 99% of the cases. To handle the
> remaining 1%, I just resample the files off-line. audio/sox is
> excellent for that.
> 
> So, I'd suggest you to add "-e s24" to sndiod_flags and resample
> off-line when needed.
> 
> HTH
 
There is possibly one more use case for "bit-perfect". I have a small
collection of surround sound (5.1, 4.1, quad, etc) recordings extracted
from various DVDs, SACDs, and other sources. They are encoded in DTS
and Dolby Digital formats, as plain WAV files, and "compressed" to flac
format to prevent "smart" applications, such as ffmpeg, mpd, etc. from
trying to decode them and convert to stereo.

My desktop is connected to a receiver via optical SPDIF cable. To get
the surround sound, I use mpd with 'device "snd/0"' option and Ario to
control the mpd daemon. mpd decodes the top layer (flac), but stops
there and sends DTS-wav to the sndiod without mangling it further.
However, if sndiod's sample rate does not match that of the recording,
it resamples the stream, which ruins the DTS and results in white noise.

I found out that I have to restart sndiod with either
'sndiod_flags="-m play -r 44100"' or 'sndiod_flags="-m play -r 48000"'
flags in /etc/rc.conf.local depending on the files I am playing,
and then it gets to the receiver without issues.

I have each music directory annotated with the sample rate used, like so:

HAMLET: /storage $ ls music/dts/Pink\ Floyd/
(1970) Atom Heart Mother (Quadrophonic Vinyl Conversion) (Dolby Digital Quad 
16-48)
(1973) Dark Side of the Moon (Alan Parson's Mix) (DVD-Audio) (DTS 4.1 24-48)
(1971) Echoes (Original 4.0 Quad Mix) (From Pink Floyd the Early Years 
1965-1972, Volume 5) (DTS Quad 16-48)
(1973) Dark Side of the Moon (Analogue Transfer From SACD) (DTS 5.1 16-44.1)
(1971) Meddle (From Pink Floyd the Early Years 1965-1972, Volume 5) (DTS 5.1 
16-48)
(1994) The Division Bell (2014, Warner Music Group, 20th Anniversary Edition) 
(DTS 5.1 16-48)
Live: (1974) Live at Pompeii (DTS Quad 24-48)

For '16-48' and '24-48' (bit depth-samplerate), I start sndiod with
sndiod_flags="-m play -r 48000"
for '16-44.1', I restart sndiod with
sndiod_flags="-m play -r 44100"

Bit depth does not seem to matter. I don't care about "bit-perfect", but
only about sending the dts stream to the receiver as-is, which works.

--
Andre






Re: sndio and bit perfect playback

2022-10-13 Thread Geoff Steckel

On 10/13/22 16:14, Alexandre Ratchov wrote:

On Thu, Oct 13, 2022 at 03:11:50AM +, s...@skolma.com wrote:


in summary, audio works.. just not bit-perfectly :)
does anyone know if SNDIO supports such mode ? and how i might configure it.


bit-perfect is practical for one thing only: avoid questionings about
whether the processing adds audible noise & distortion. I've tryed
various hacks, including bypassing sndiod and neither was very
practical.

IMHO, the sndiod resampler covers 99% of the cases. To handle the
remaining 1%, I just resample the files off-line. audio/sox is
excellent for that.

So, I'd suggest you to add "-e s24" to sndiod_flags and resample
off-line when needed.

HTH


There's code in the kernel down through uaudio.c to set sample rates.
audioctl accepts a "rate" argument
sndiod accepts a "rate" argument.
The code in those and libsndio looks reasonable.

If those don't work it's a (fixable) bug/not-yet-implemented.
I've tried those settings with ambiguous results but not failure.
My usb dacs don't have visible indicators & I don't have a
USB protocol sniffer.

In my experience resampling quality in any particular implementation
is not guaranteed and can introduce significant artifacts.
Declaring a particular implementation "good enough" without
knowing more seems premature.

geoff steckel



Re: sndio and bit perfect playback

2022-10-13 Thread Alexandre Ratchov
On Thu, Oct 13, 2022 at 03:11:50AM +, s...@skolma.com wrote:
> 
> 
> in summary, audio works.. just not bit-perfectly :)
> does anyone know if SNDIO supports such mode ? and how i might configure it.
> 

bit-perfect is practical for one thing only: avoid questionings about
whether the processing adds audible noise & distortion. I've tryed
various hacks, including bypassing sndiod and neither was very
practical.

IMHO, the sndiod resampler covers 99% of the cases. To handle the
remaining 1%, I just resample the files off-line. audio/sox is
excellent for that.

So, I'd suggest you to add "-e s24" to sndiod_flags and resample
off-line when needed.

HTH



Re: sndio and bit perfect playback

2022-10-13 Thread Jan Stary
> By the way, sndiod defaults to 48k as well.
> 
> > eg music , brower video and system sounds.
> > but is techncally up/down sampling based on feed.

Forgot to say/rant:

If you have a 44100 Hz linear PCM stereo wav file,
and play it with aucat, and sndiod resamples it to 48 kHz
(as I believe it does with the default sndiod -r rate),
there is no way for you to hear the difference.

Play the file with sndiod -r 48000, then with sndiod -r 44100
and tell me: are the trebles "crispy"? Are the middles "rich"?
Or are they not, when it's not "bit-perfect"? Please.



Re: sndio and bit perfect playback

2022-10-13 Thread Jan Stary
On Oct 13 03:11:50, s...@skolma.com wrote:
> A questions about SNDIO and bit-perfect audio playback.
> 
> I use a usb dac, audioquest dragonfly black 1.5,
> and headphones to listen to my digitised music collection,
> as i can conveniently move between my various devices.
> 
> OpenBSD has detected this device

dmesg?

> and following FAQ13 i was able
> to have working playback of .wav and .flac audio files with ease
> via the various sndioctl commands.
> tested successfully with aucat, and ogg123,
> including other audio such as browser/yt.

> The dac supports several native bit rates,

This is the point where you should show the full output
of mixerctl -av and audioctl.

> and has a nice party_trick of changing physical logo colour
> based on the feed, the main ones being:

never mind the logo colour, show the actual audio settings,
as in mixerctl and audioctl

> 16bit / 44.1k, green. (cd quality)
> 24bit / 48k, blue (dvd quality)
> 24bit / 88.2k, orange,
> 24bit / 96k pink.

Are all of these stereo, or are some of them multichannel?

> In my testing, windows, mac, freebsd, openbsd, and linux
> all default to the 48k - blue mode allowing mulitple input streams.

Multiple input streams have nothing to do with the above settings.
By default, sndio will play what you feed it, mixing from multiple
inputs - as I suppose other audio systems do on other OSes;
this is not a property of the audio device.

By the way, sndiod defaults to 48k as well.

> eg music , brower video and system sounds.
> but is techncally up/down sampling based on feed.

Of course: how else are you gonna play a 8 kHZ audio file
when the device cannot do 8 kHz?

> For bit perfect to work correctly..

Stop right there: what do you mean by bit perfect?
The bits stored in a flac file are not the same bits
that arrive at the audio device to be played.

Are you just concerned with the upsampling?
(Or downsampling? Meaning you have music
stored in more than 24bit @ 96 kHz?

> normally the audio subsystem

What subsytem? sndio?

> would be configured to operate
> in exclusive mode. where only the music would be the output.

Meaning what? To the running sndiod, an input is an input,
there;s nothing distinguishing "music". What you probably mean
is giving e.g. ogg123 exclusive rights to open the audio device,
resp. exclusive rights to be sndiod's input, so that nothing else
is playing while ogg123 is playing. Is that what you mean?

(Even so, the bits of the ogg file are not the bits that reach
the audio device. Drop the "bit-perfect" lingo, this is imho
about exclusive audio device access.)

> does anyone know if SNDIO supports such mode?
> and how i might configure it.

I suppose you have already read sndiod(8) in its entirety ...

(You can also not run sndiod: then only one audio player
will have access to the underlying device.)

Jan