Re: [Alsa-user] [asoundrc] "lossless" format conversion without any rate conversion?

2017-11-17 Thread Vincent Yu
Thank you so much for the informative and detailed response!

Clemens Ladisch wrote:
> This plugin will not do resampling.

It's a relief to hear that plug, in this situation, will not cause resampling.

>> Specifically, does sample rate conversion still occur anywhere in the
>> signal chain even though I provided the "unchanged" string for rate?
>
> The hardware, another plugin layered on top of this, or some application
> might still do resampling.  :)

Ah, yes - like when applications mix or change the volume of streams
before talking to ALSA. I'll be sure to try to have the applications
send a bit-perfect stream to the aforementioned newly defined pcm.

>> I would like to create a configuration to force digital audio output
>> from my PC (Arch Linux - ALSA only, no Pulseaudio) to remain at or be
>> converted to 24-bit format without any sample rate conversion.
>
> Then try the linear plugin, which changes only the sample format:
>
> pcm.my_new_default {
> type linear
> slave {
> pcm "hw:0,0"
> format S24_3LE
> }
> }
>
> (The "plug" plugin does nothing but dynamically inserting other plugins,
> such as "linear"/"route"/"rate", when required.)

Using the linear plugin directly also works for me. Thanks for
clarifying how stuff is working under the hood. I'm directly using the
linear plugin now to make my asoundrc config more readable and clear
to me in the future.

>> I understand that the word, "lossless," in the title may be a bit of
>> a misnomer, since quantization noise from quantization errors during
>> bit depth conversion will raise the noise floor of the signal by
>> a small (and probably inaudible) amount
>
> Converting between integer sample formats does not change the bits; you
> get quantization errors only with volume changes.

Ah, right - CD audio uses LPCM. So only zero-padding occurs... by left
shifting zeros from the right into the samples (without taking
endianness into account)? To only increase precision without losing
information. Ah, it makes sense.

>> looking at the code and trying to grep directory trees recursively for
>> the string, "unchanged", to see if I can get any leads, I got lost in
>> the behemoth of a code base
>
> The "unchanged" string is parsed in pcm.c; in pcm_plug.c, search for
> "== -2".

And so we get:

links |= SND_PCM_HW_PARBIT_RATE;

I was just using a rather vanilla configuration of vim to browse the
code base. Perhaps I should look into plugins and such to make looking
up references/definitions easier. Thanks, yet again, for the
clarification and taking the time to respond to my long post!

Thanks,
Vincent

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


Re: [Alsa-user] [asoundrc] "lossless" format conversion without any rate conversion?

2017-11-16 Thread Clemens Ladisch via Alsa-user
Vincent Yu wrote:
> Will any sample rate conversions occur with this .asoundrc config?
>
> pcm_slave.force_24_bit_no_rate_convert {
> pcm "hw:0,0"
> format S24_3LE # Or other 24-bit format
> rate "unchanged" # Necessary?
> }
>
> pcm.my_new_default {
> type plug
> slave force_24_bit_no_rate_convert
> }

http://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html#pcm_plugins_plug

This plugin will not do resampling.

> Specifically, does sample rate conversion still occur anywhere in the
> signal chain even though I provided the "unchanged" string for rate?

The hardware, another plugin layered on top of this, or some application
might still do resampling.  :)

> I would like to create a configuration to force digital audio output
> from my PC (Arch Linux - ALSA only, no Pulseaudio) to remain at or be
> converted to 24-bit format without any sample rate conversion.

Then try the linear plugin, which changes only the sample format:

pcm.my_new_default {
type linear
slave {
pcm "hw:0,0"
format S24_3LE
}
}

(The "plug" plugin does nothing but dynamically inserting other plugins,
such as "linear"/"route"/"rate", when required.)

> I understand that the word, "lossless," in the title may be a bit of
> a misnomer, since quantization noise from quantization errors during
> bit depth conversion will raise the noise floor of the signal by
> a small (and probably inaudible) amount

Converting between integer sample formats does not change the bits; you
get quantization errors only with volume changes.

> looking at the code and trying to grep directory trees recursively for
> the string, "unchanged", to see if I can get any leads, I got lost in
> the behemoth of a code base

The "unchanged" string is parsed in pcm.c; in pcm_plug.c, search for
"== -2".


Regards,
Clemens

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user