<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="https://dev1galaxy.org/extern.php?action=feed&amp;tid=7538&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Dev1 Galaxy Forum / How to detect hidden ALSA resampling]]></title>
		<link>https://dev1galaxy.org/viewtopic.php?id=7538</link>
		<description><![CDATA[The most recent posts in How to detect hidden ALSA resampling.]]></description>
		<lastBuildDate>Mon, 17 Nov 2025 06:03:56 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[Re: How to detect hidden ALSA resampling]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=59757#p59757</link>
			<description><![CDATA[<h5>Full duplex</h5><p>Full duplex in ALSA is achieved by combining <span class="bbc">dmix</span> (for playback) and <span class="bbc">dsnoop</span> (for capture) via the <span class="bbc">asym</span> plugin.</p><p>Just like with <span class="bbc">dmix</span>, <span class="bbc">dsnoop</span> must be explicitly tuned.<br /><span class="bbc">dsnoop.conf</span> should be fixed in the same way as <span class="bbc">dmix.conf</span></p><p>By default, both <span class="bbc">dmix</span> and <span class="bbc">dsnoop</span> use fixed, high-latency settings (e.g., <span class="bbc">period_time</span> 125000 µs).</p><p>Notice: high latency is embedded in default Debian&#039;s ALSA config. It is unimaginable. </p><p>High latency is embedded in Debian&#039;s default ALSA configuration — particularly through conservative defaults in <span class="bbc">dmix</span> and <span class="bbc">dsnoop</span>, where <span class="bbc">period_time</span> often defaults to 125000 µs (125 ms) and <span class="bbc">periods</span> to 16, resulting in total buffer latencies up to 2 seconds.</p><p>This is not a myth, not a conspiracy theory — it’s a documented design choice favoring stability over performance. Most users never notice, but for real-time audio, it’s crippling.</p><p>The default <span class="bbc">dmix</span> and <span class="bbc">dsnoop</span> settings prioritize stability over performance — large buffers prevent underruns, which is crucial for PulseAudio, as it relies on ALSA plugins for mixing and expects reliable, glitch-free operation. PulseAudio assumes ALSA is just a backend, so stable, high-latency defaults reduce the risk of dropouts, even if responsiveness suffers.</p><p>It’s unimaginable for a system that supports professional audio. It may not look sane — high latency in ALSA defaults is a trade-off for stability, not sound quality or usability. It masks architectural inefficiencies and fails real-time applications. True sanity would be low-latency defaults that work out of the box. While the defaults may seem insane for low-latency use, they are a safeguard against instability in the PulseAudio layer.</p><p>Notice: the reason for high latency is <span class="bbc">period_time</span> defaulting to 125000 µs (125 ms) in both <span class="bbc">dmix</span> and <span class="bbc">dsnoop</span>, unless overridden.</p><p>In Debian&#039;s <span class="bbc">dmix.conf</span> and <span class="bbc">dsnoop.conf</span>, <span class="bbc">period_time</span> defaults to <span class="bbc">-1</span>, which means &quot;use the hardware default&quot; — often resulting in 125 ms periods. Combined with <span class="bbc">periods = 16</span>, this gives a total capture buffer latency of:<br /><span class="bbc">125 ms × 16 = 2000 ms</span> (2 seconds) — extremely high.</p><p>To fix it, override both:<br /><span class="bbc">period_time</span> (40000 µs = 40 ms)<br /><span class="bbc">periods</span> (4)</p><p>So total latency becomes:<br /><span class="bbc">40 ms × 4 = 160 ms</span> — much better.</p><p>By appending <span class="bbc">/usr/share/alsa/pcm/dmix.conf</span> to <span class="bbc">~/.asoundrc</span> and modifying it with:</p><div class="codebox"><pre><code>sed -i &#039;s/default -1/default 40000/; s/default 1024/default -1/; s/default 16/default 4/&#039; ~/.asoundrc</code></pre></div><p>You override the default high-latency settings:<br /><span class="bbc">period_time default -1</span> → now <span class="bbc">40000</span> µs (40 ms)<br /><span class="bbc">period_size default 1024</span> → now <span class="bbc">-1</span> (controlled by rate)<br /><span class="bbc">periods default 16</span> → now <span class="bbc">4</span></p><p>This reduces playback latency significantly and matches <strong>fftrate</strong> needs. The same logic should be applied to <span class="bbc">dsnoop</span> for symmetric, low-latency full duplex.</p><p><span class="bbc">/usr/share/alsa/pcm/dmix.conf</span> → enables software mixing for playback<br /><span class="bbc">/usr/share/alsa/pcm/dsnoop.conf</span> → enables simultaneous recording<br /><span class="bbc">/usr/share/alsa/alsa.conf</span> → main config, includes others</p><p>Full duplex requires <span class="bbc">asym</span> device that links <span class="bbc">dmix</span> (playback) and <span class="bbc">dsnoop</span> (capture), like:</p><div class="codebox"><pre><code>pcm.duplex {
    type asym
    playback.pcm &quot;dmix&quot;
    capture.pcm &quot;dsnoop&quot;
}

pcm.!default {
    type plug
    slave.pcm &quot;duplex&quot;
}</code></pre></div><p>Such setup can be added manually to <span class="bbc">~/.asoundrc</span>. <br />You can also find a sort of &quot;full duplex&quot; in <span class="bbc">/usr/share/alsa/cards/HDA-Intel.conf</span>&#160; It seems to be enabled by default.</p><div class="quotebox"><blockquote><div><p><strong>Rinat Ibragimov</strong> (creator of apulse): </p><p><span class="bbc">apulse</span> relies on ALSA&#039;s <span class="bbc">dmix</span>, <span class="bbc">dsnoop</span>, and <span class="bbc">plug</span> plugins to handle multiple sound sources and capture streams running at the same time. <span class="bbc">dmix</span> plugin muxes multiple playback streams; <span class="bbc">dsnoop</span> plugin allow multiple applications to capture from a single microphone; and <span class="bbc">plug</span> plugin transparently converts audio between various sample formats, sample rates and channel numbers. <span style="color: green"><strong>For more than a decade now, ALSA comes with these plugins enabled and configured by default.</strong></span><br />_https://github.com/i-rinat/apulse</p></div></blockquote></div><p>1. For more than a decade now, ALSA comes with <span class="bbc">dmix</span>, <span class="bbc">dsnoop</span>, <span class="bbc">plug</span> , and <span class="bbc">asym</span> (full duplex), that is, a fully functional software mixer, enabled and configured by default.<br />2. Devuan users have been, shall we say, unhurried in noticing the elephant in the room.</p><p>Remove your ALSA config, play audio from two sources at once, and you’ll hear the default <span class="bbc">dmix</span> quietly doing its job. When using multiple sound cards, setting <span class="bbc">defaults.pcm.!card</span> and <span class="bbc">defaults.ctl.!card</span> in <span class="bbc">~/.asoundrc</span> ensures ALSA directs audio and control to the correct device. Without this, removing your config may cause ALSA to default to a different card — potentially making sound &quot;disappear.&quot; Use the card’s name (e.g., <span class="bbc">PCH</span>) or index to lock the default.</p><div class="quotebox"><blockquote><div><p>There oughtn’t to be any trouble with <span class="bbc">apulse</span>, unless one’s gone and enabled a rather peculiar ALSA configuration. If Firefox stumbles on ALSA input, it’s a bug in cubeb’s backend — nothing more.</p></div></blockquote></div><p>With default Debian settings, full duplex is likely to expose the high default latency (e.g., <span class="bbc">125 ms period × 16 periods = 2 seconds</span>) to users, even those with moderate hearing.</p><p>With full duplex, round-trip latency (mic-to-speaker or loopback) becomes obvious — especially in real-time monitoring. The default <span class="bbc">dmix</span> and <span class="bbc">dsnoop</span> settings were designed for stability, not performance, and reveal a two-period delay minimum.</p><p>With Debian defaults, full duplex would make the latency audible and embarrassing, even to semi-deaf users. It would expose insanity of &quot;sane defaults&quot; _https://wiki.debian.org/ALSA#Configuration</p><p>The manual fix — overriding <span class="bbc">period_time</span> and <span class="bbc">periods</span> — is essential to restore sanity.</p><p>The Debian wiki’s claim of &quot;sane defaults&quot; is misleading. The actual defaults — <span class="bbc">period_size 1024</span>, <span class="bbc">periods 16</span> — result in high latency (often 200+ ms), which is far from sane for real-time audio. These settings are not optimized for low latency or high-fidelity resampling (e.g., <strong>fftrate</strong>). ALSA users must manually override them, proving that sane is a misnomer.</p><p>Sanity may be boring — and perhaps that’s why it’s so rarely implemented. In Linux, as in history, the dramatic, the complex, and the broken often take center stage. Simplicity and correctness don’t generate headlines. But with the right config, sanity can be built — even if it’s not the default.</p>]]></description>
			<author><![CDATA[dummy@example.com (igorzwx)]]></author>
			<pubDate>Mon, 17 Nov 2025 06:03:56 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=59757#p59757</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to detect hidden ALSA resampling]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=59747#p59747</link>
			<description><![CDATA[<p><strong>How to consume this manual without thinking.</strong></p><p>First of all, it is almost impossible. It might be a real challenge for Devuan consumer community. But, nevertheless, you have to try it simply because it is a challenge. In any case, both thinking and non-thinking may inevitably produce misunderstanding. </p><h5>ALSA Setup: Simple, Low-Latency, No Nonsense</h5><p>Keep it minimal:</p><p><span class="bbc">period_time = 40000</span> (40 ms per audio chunk)<br /><span class="bbc">periods = 4</span> (total buffer = 16 ms)</p><p>Only change <span class="bbc">defaults.pcm.dmix.rate</span> to set sample rate (e.g., 44100, 48000, 96000, 192000)<br />That’s it.</p><p>ALSA automatically adjusts <span class="bbc">period_size</span> based on the rate — just like physics: if volume is fixed, changing temperature sets pressure. Here, timing is fixed, so sample rate sets data flow. No resampling jitter. No app config needed.</p><p>The modified <span class="bbc">dmix.conf</span> stays untouched. This works because ALSA’s defaults use <span class="bbc">@func refer</span> - they respect <span class="bbc">defaults.pcm.dmix.rate</span>.</p><p>One line controls everything. Clean. Predictable. Precise.</p><p>The <span class="bbc">period_time = 40000</span> and <span class="bbc">periods = 4</span> settings are critical for <strong>fftrate</strong> to perform exact, low-jitter resampling.</p><p>Unlike basic resamplers, <strong>fftrate</strong> is a high-quality, real-time FFT-based resampler that needs precise buffer timing to align its windowing and avoid phase errors. The 40ms period time (40,000 µs) ensures sufficient data for accurate spectral analysis, while 4 periods balance latency and stability.</p><p>When you set:</p><div class="codebox"><pre><code>defaults.pcm.dmix.rate 192000
defaults.pcm.rate_converter &quot;fftrate&quot;</code></pre></div><p>and fix <span class="bbc">period_time = 40000</span>, ALSA configures the mixing engine so all audio is resampled via <strong>fftrate</strong> to 192kHz — regardless of source rate (44.1k, 48k, etc). This gives bit-perfect timing, zero jitter (J: 0.00%), and superior audio fidelity.</p><p>Firefox (via cubeb) then feeds into this pipeline — it sees a clean 48kHz or 44.1kHz stream, but resampling is silently handled by ALSA/<strong>fftrate</strong>, not the browser. That’s why the logs show:</p><div class="codebox"><pre><code>Rates: 48000 --&gt; 192000 (J: 0.00%, T: FFT, W: Vorbis)</code></pre></div><p>This setup is exactly what is needed: one central, high-quality resampling stage, perfectly timed.</p><h5>SUMMARY: ALSA Setup For the Mildly Confused, But Firmly Committed</h5><p>With due modesty, I present my no-nonsense ALSA config:</p><p><span class="bbc">period_time = 40000</span>&#160; <br /><span class="bbc">periods = 4</span>&#160; <br />Only variable: <span class="bbc">defaults.pcm.dmix.rate</span></p><p>That’s it. Everything else? Left to ALSA’s good sense.</p><p>By fixing the period time, I give <strong>fftrate</strong> enough data for clean, FFT-based resampling — no jitter, no drift, just smooth 0.00% magic. Apps feed in at any rate; ALSA resamples to my chosen <span class="bbc">dmix.rate</span> (192kHz, thank you) with surgical precision.</p><p>It’s not clever. It’s not flashy. But it works — even for someone like most ALSA users, whose hearing’s gone slightly south and whose memory’s worse.</p><p>So yes: this might just be the gold standard… for audiophiles who are half-deaf, half-blind, and cheerfully demented.</p><p>One final note: <strong>fftrate</strong> is vastly superior to most soundcards’ built-in hardware resamplers. So while you can vary the sample rate freely, best practice is to set <span class="bbc">defaults.pcm.dmix.rate</span> to the maximum your DAC supports — 192kHz or 384kHz — and leave it there.</p><p>This ensures all audio is resampled once, at the highest quality, before hitting your hardware. No more relying on mediocre onboard DSP. You’re not just avoiding jitter — you’re upgrading your entire chain.</p><p>So yes: set it to the max, and forget it. Let <strong>fftrate</strong> do the work nature intended.</p><p><strong>fftrate</strong> is exceptionally fast because it was optimized over 15 years ago for real-time, high-quality resampling on modest hardware. Its design leverages FFT-based interpolation, allowing it to outperform most built-in hardware resamplers — even on modern systems.</p><p>Setting <span class="bbc">defaults.pcm.dmix.rate</span> to your DAC’s maximum supported rate ensures all audio is resampled just once, at the highest quality, before playback.</p><p>So: set it to the max, and forget it. Let <strong>fftrate</strong> do the heavy lifting — efficiently, accurately, and without breaking a sweat.</p><div class="quotebox"><blockquote><div><p><strong>WARNING:</strong> This ALSA setup is not complete. For example, &quot;full duplex for simultaneous playback and recording&quot; is missing. A complete solution, that is a fully functional ALSA software mixer, is provided by <span class="bbc">arateconf</span> ALSA configuration utility<br />_https://dev1galaxy.org/viewtopic.php?id=6644</p></div></blockquote></div>]]></description>
			<author><![CDATA[dummy@example.com (igorzwx)]]></author>
			<pubDate>Mon, 17 Nov 2025 01:31:21 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=59747#p59747</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to detect hidden ALSA resampling]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=59689#p59689</link>
			<description><![CDATA[<h5>How to use fftrate with default ALSA software mixer</h5><div class="quotebox"><blockquote><div><p><strong>Debian Wiki: Configuration</strong></p><p>You can find ALSA configuration files in the <span class="bbc">/etc/alsa/conf.d/ </span>directory. A lot of files are already included here by default. Advanced features such as mixing should already be configured with sane defaults. If you want to make changes, add a new file in here.<br />_https://wiki.debian.org/ALSA#Configuration</p></div></blockquote></div><p>There are indeed very secret <span class="bbc">dmix</span> and <span class="bbc">dsnoop</span> enabled by default.</p><div class="codebox"><pre><code>$ grep -r &quot;defaults.pcm.dmix.rate&quot; /usr/share/alsa/
/usr/share/alsa/pcm/dsnoop.conf:            name defaults.pcm.dmix.rate
/usr/share/alsa/pcm/dmix.conf:            name defaults.pcm.dmix.rate
/usr/share/alsa/alsa.conf:defaults.pcm.dmix.rate 48000</code></pre></div><p>However, the so-called &quot;sane defaults&quot; may seem rather strange, for example:</p><div class="codebox"><pre><code>period_size 1024
periods     16</code></pre></div><div class="codebox"><pre><code>$ grep -rE &quot;period|1024|16&quot; /usr/share/alsa/pcm/dmix.conf
        period_size {
                    &quot;.period_size&quot;
            default 1024
        period_time {
                    &quot;.period_time&quot;
        periods {
                    &quot;.periods&quot;
            default 16</code></pre></div><p><strong>fftrate</strong> cannot perform exact resampling with such &quot;sane defaults&quot;. This can easily be fixed with the help of simple esoteric math:</p><div class="codebox"><pre><code>period_time = (period_size/sample_rate) * 1000000</code></pre></div><p>To perform exact resampling with low latency, <strong>fftrate</strong> needs proper settings</p><div class="codebox"><pre><code>period_time 40000    
periods     4</code></pre></div><p>First of all, create a simple ALSA config.<br />If you have only one sound card, it may look like this:</p><div class="codebox"><pre><code>$ cat ~/.asoundrc
defaults.pcm.rate_converter &quot;fftrate&quot;
# defaults.pcm.dmix.rate 192000
# defaults.pcm.dmix.rate 96000
# defaults.pcm.dmix.rate 48000    # Default
# defaults.pcm.dmix.rate 44100</code></pre></div><p>If you have several sound cards, you have to set up a default card, for example:</p><div class="codebox"><pre><code>$ cat /proc/asound/cards
 0 [system         ]: USB-Audio - iMic USB audio system
                      Griffin Technology, Inc iMic USB audio system at usb-0000:00:1a.0-1.3.4, full s
 1 [PCH            ]: HDA-Intel - HDA Intel PCH
                      HDA Intel PCH at 0xf7e10000 irq 31</code></pre></div><div class="codebox"><pre><code>$ cat ~/.asoundrc
defaults.pcm.rate_converter &quot;fftrate&quot;
defaults.pcm.dmix.rate 192000
# defaults.pcm.dmix.rate 96000
# defaults.pcm.dmix.rate 48000    # Default
# defaults.pcm.dmix.rate 44100
defaults.pcm.!card PCH
defaults.ctl.!card PCH </code></pre></div><p>Now you can execute esoteric commands:</p><div class="codebox"><pre><code>echo -e &#039;\n\n# This dmix config can be used for various values of defaults.pcm.dmix.rate\n# Intel HDA native sample rates (min - max): 44100 - 192000 (44100,48000,96000,192000)&#039; &gt;&gt; ~/.asoundrc
cat /usr/share/alsa/pcm/dmix.conf &gt;&gt; ~/.asoundrc
sed -i &#039;s/default -1/default 40000/; s/default 1024/default -1/; s/default 16/default 4/&#039; ~/.asoundrc </code></pre></div><p>The result:</p><div class="codebox"><pre class="vscroll"><code>$ cat ~/.asoundrc
defaults.pcm.rate_converter &quot;fftrate&quot;
defaults.pcm.dmix.rate 192000
# defaults.pcm.dmix.rate 96000
# defaults.pcm.dmix.rate 48000    # Default
# defaults.pcm.dmix.rate 44100
defaults.pcm.!card PCH
defaults.ctl.!card PCH

# This dmix config can be used for various values of defaults.pcm.dmix.rate
# Intel HDA native sample rates (min - max): 44100 - 192000 (44100,48000,96000,192000)
#
# dmix output
#

pcm.!dmix {
	@args [ CARD DEV SUBDEV FORMAT RATE CHANNELS ]
	@args.CARD {
		type string
		default {
			@func refer
			name defaults.pcm.dmix.card
		}
	}
	@args.DEV {
		type integer
		default {
			@func refer
			name defaults.pcm.dmix.device
		}
	}
	@args.SUBDEV {
		type integer
		default 0
	}
	@args.FORMAT {
		type string
		default {
			@func refer
			name defaults.pcm.dmix.format
		}
	}
	@args.RATE {
		type integer
		default {
			@func refer
			name defaults.pcm.dmix.rate
		}
	}
	@args.CHANNELS {
		type integer
		default {
			@func refer
			name defaults.pcm.dmix.channels
		}
	}
	type dmix
	ipc_key {
		@func refer
		name defaults.pcm.ipc_key
	}
	ipc_gid {
		@func refer
		name defaults.pcm.ipc_gid
	}
	ipc_perm {
		@func refer
		name defaults.pcm.ipc_perm
	}
	tstamp_type {
		@func refer
		name defaults.pcm.tstamp_type
	}
	slave {
		pcm {
			type hw
			card $CARD
			device $DEV
			subdevice $SUBDEV
		}
		format $FORMAT
		rate $RATE
		channels $CHANNELS
		period_size {
			@func refer
			name {
				@func concat
				strings [
					&quot;defaults.dmix.&quot;
					{
						@func card_id
						card $CARD
					}
					&quot;.period_size&quot;
				]
			}
			default -1
		}		
		period_time {
			@func refer
			name {
				@func concat
				strings [
					&quot;defaults.dmix.&quot;
					{
						@func card_id
						card $CARD
					}
					&quot;.period_time&quot;
				]
			}
			default 40000
		}		
		periods {
			@func refer
			name {
				@func concat
				strings [
					&quot;defaults.dmix.&quot;
					{
						@func card_id
						card $CARD
					}
					&quot;.periods&quot;
				]
			}
			default 4
		}
	}
	hint {
		show {
			@func refer
			name defaults.namehint.extended
		}
		description &quot;Direct sample mixing device&quot;
		device_output $DEV
	}
}</code></pre></div><p>Now we can debug Firefox</p><div class="quotebox"><blockquote><div><p><strong>NOTE:</strong> If you have in Firefox&#039;s about:config this entry:</p><div class="codebox"><pre><code>media.cubeb.force_sample_rate        48000</code></pre></div><p>delete it.</p></div></blockquote></div><div class="codebox"><pre class="vscroll"><code>$ MOZ_LOG=&quot;cubeb:3&quot; firefox 2&gt;&amp;1 about:support | grep -vE &quot;input latency|ATT&quot;
[Parent 24955: Main Thread]: I/cubeb media.cubeb.sandbox: true
Input:  44100 Hz, 2 ch, &#039;s32_le&#039; (0xa): dummy = 0, period = 1764
Output: 192000 Hz, 2 ch, &#039;s32_le&#039; (0xa): dummy = 0, period = 7680
Rates:  44100 --&gt; 192000 (J: 0.00%, T: FFT, W: Vorbis)
Ok.

Input:  44100 Hz, 2 ch, &#039;s32_le&#039; (0xa): dummy = 0, period = 1764
Output: 192000 Hz, 2 ch, &#039;s32_le&#039; (0xa): dummy = 0, period = 7680
Rates:  44100 --&gt; 192000 (J: 0.00%, T: FFT, W: Vorbis)
Ok.

[Parent 24955: AudioIPC Server RPC]: E/cubeb cubeb.c:654:DeviceID: &quot;default&quot; (PREFERRED)
    Name:    &quot;default&quot;
    Group:    &quot;default&quot;
    Vendor:    &quot;default&quot;
    Type:    output
    State:    enabled
    Maximum channels:    10000
    Format:    S16LE (0x10) (default: S16LE)
    Rate:    [192000, 192000] (default: 192000)
    Latency: lo 0 frames, hi 0 frame
[Parent 24955: Main Thread]: E/cubeb cubeb.c:654:DeviceID: &quot;default&quot; (PREFERRED)
    Name:    &quot;default&quot;
    Group:    &quot;default&quot;
    Vendor:    &quot;default&quot;
    Type:    output
    State:    enabled
    Maximum channels:    10000
    Format:    S16LE (0x10) (default: S16LE)
    Rate:    [192000, 192000] (default: 192000)
    Latency: lo 0 frames, hi 0 frame</code></pre></div><p><span class="bbc">about:support</span></p><div class="codebox"><pre><code>Name     Firefox
Version     140.5.0esr
Build ID     20251106203603
...
Media
Audio Backend    alsa
Max Channels    10000
Preferred Sample Rate    192000</code></pre></div><div class="quotebox"><blockquote><div><p><strong>Reference media files:</strong></p><p><strong>Best Audiophile Vocal 24 bit - Hi-Res Music 2025 - Audiophile Voices</strong><br />_https://www.youtube.com/watch?v=uO6jfQ5tQHM<br />_https://youtu.be/uO6jfQ5tQHM</p><p><strong>Best Voices &amp; Dynamic Sound - Hi-Res Music 24 Bit - Audiophile NBR Music</strong><br />_https://rutube.ru/video/4202a6f411ad55ea7f55e38f860e26bc/</p></div></blockquote></div><p><span class="bbc">defaults.pcm.dmix.rate 192000</span></p><div class="codebox"><pre><code>$ cat ~/.asoundrc
defaults.pcm.rate_converter &quot;fftrate&quot;
defaults.pcm.dmix.rate 192000
# defaults.pcm.dmix.rate 96000
# defaults.pcm.dmix.rate 48000    # Default
# defaults.pcm.dmix.rate 44100
...</code></pre></div><p><strong>YouTube:</strong> <span class="bbc">48000 --&gt; 192000</span></p><div class="codebox"><pre><code>$ MOZ_LOG=&quot;MediaDecoder:4,cubeb:3&quot; firefox 2&gt;&amp;1 https://youtu.be/uO6jfQ5tQHM | awk &#039;!/ATT/ &amp;&amp; !/libva/ &amp;&amp; !/s=1/ &amp;&amp; !/s=0/ &amp;&amp; (!/MediaDecoder/ || /rate/)&#039;
[Child 15580: Main Thread]: D/MediaDecoder MediaDecoder[7ff773454200] MetadataLoaded, channels=2 rate=48000 hasAudio=1 hasVideo=1
[Child 15580: MediaSupervisor #1]: I/cubeb media.cubeb.sandbox: true
Input:  44100 Hz, 2 ch, &#039;s32_le&#039; (0xa): dummy = 0, period = 1764
Output: 192000 Hz, 2 ch, &#039;s32_le&#039; (0xa): dummy = 0, period = 7680
Rates:  44100 --&gt; 192000 (J: 0.00%, T: FFT, W: Vorbis)
Ok.

[Child 15580: Main Thread]: D/MediaDecoder MediaDecoder[7ff773454200] FirstFrameLoaded, channels=2 rate=48000 hasAudio=1 hasVideo=1 mPlayState=PLAY_STATE_LOADING transportSeekable=1
[Child 15580: MediaDecoderStateMachine #1]: I/cubeb CubebStreamInit output stream rate 48000
Input:  48000 Hz, 2 ch, &#039;s32_le&#039; (0xa): dummy = 0, period = 1920
Output: 192000 Hz, 2 ch, &#039;s32_le&#039; (0xa): dummy = 0, period = 7680
Rates:  48000 --&gt; 192000 (J: 0.00%, T: FFT, W: Vorbis)
Ok.</code></pre></div><p><strong>RuTube:</strong> <span class="bbc">44100 --&gt; 192000</span></p><div class="codebox"><pre><code>$ MOZ_LOG=&quot;MediaDecoder:4,cubeb:3&quot; firefox 2&gt;&amp;1 https://rutube.ru/video/4202a6f411ad55ea7f55e38f860e26bc/ | awk &#039;!/ATT/ &amp;&amp; !/libva/ &amp;&amp; !/s=1/ &amp;&amp; !/s=0/ &amp;&amp; (!/MediaDecoder/ || /rate/)&#039;
[Child 16217: Main Thread]: I/cubeb media.cubeb.sandbox: true
Input:  44100 Hz, 2 ch, &#039;s32_le&#039; (0xa): dummy = 0, period = 1764
Output: 192000 Hz, 2 ch, &#039;s32_le&#039; (0xa): dummy = 0, period = 7680
Rates:  44100 --&gt; 192000 (J: 0.00%, T: FFT, W: Vorbis)
Ok.

[Child 16217: Main Thread]: D/MediaDecoder MediaDecoder[7f89b2ef8f00] MetadataLoaded, channels=2 rate=44100 hasAudio=1 hasVideo=1
[Child 16217: Main Thread]: D/MediaDecoder MediaDecoder[7f89b2ef8f00] FirstFrameLoaded, channels=2 rate=44100 hasAudio=1 hasVideo=1 mPlayState=PLAY_STATE_LOADING transportSeekable=1
[Child 16217: BackgroundThreadPool #1]: I/cubeb CubebStreamInit output stream rate 44100
Input:  44100 Hz, 2 ch, &#039;s32_le&#039; (0xa): dummy = 0, period = 1764
Output: 192000 Hz, 2 ch, &#039;s32_le&#039; (0xa): dummy = 0, period = 7680
Rates:  44100 --&gt; 192000 (J: 0.00%, T: FFT, W: Vorbis)
Ok.</code></pre></div><p>You can also try <span class="bbc">defaults.pcm.dmix.rate 44100</span></p><div class="codebox"><pre><code>$ cat ~/.asoundrc
defaults.pcm.rate_converter &quot;fftrate&quot;
# defaults.pcm.dmix.rate 192000
# defaults.pcm.dmix.rate 96000
# defaults.pcm.dmix.rate 48000    # Default
defaults.pcm.dmix.rate 44100
...</code></pre></div><p><strong>YouTube:</strong> <span class="bbc">48000 --&gt; 44100<br /></span></p><div class="codebox"><pre><code>$ MOZ_LOG=&quot;MediaDecoder:4,cubeb:3&quot; firefox 2&gt;&amp;1 https://youtu.be/uO6jfQ5tQHM | awk &#039;!/ATT/ &amp;&amp; !/libva/ &amp;&amp; !/s=1/ &amp;&amp; !/s=0/ &amp;&amp; (!/MediaDecoder/ || /rate/)&#039;
[Child 17205: Main Thread]: D/MediaDecoder MediaDecoder[7ff8efdfc600] MetadataLoaded, channels=2 rate=48000 hasAudio=1 hasVideo=1
[Child 17205: MediaSupervisor #2]: I/cubeb media.cubeb.sandbox: true
[Child 17205: Main Thread]: D/MediaDecoder MediaDecoder[7ff8efdfc600] FirstFrameLoaded, channels=2 rate=48000 hasAudio=1 hasVideo=1 mPlayState=PLAY_STATE_LOADING transportSeekable=1
[Child 17205: MediaDecoderStateMachine #1]: I/cubeb CubebStreamInit output stream rate 48000
Input:  48000 Hz, 2 ch, &#039;s32_le&#039; (0xa): dummy = 0, period = 1920
Output: 44100 Hz, 2 ch, &#039;s32_le&#039; (0xa): dummy = 0, period = 1764
Rates:  48000 --&gt; 44100 (J: 0.00%, T: FFT, W: Vorbis)
Ok.</code></pre></div><p>It seems that Firefox does not resample anything. Resampling is performed by <strong>fftrate</strong>, which is now the default ALSA resampler. With new defaults (<span class="bbc">period_time = 40000, periods = 4</span>), resampling is exact: <span class="bbc">Jitter = 0.00%</span></p><div class="codebox"><pre><code># ~/.asoundrc
defaults.pcm.rate_converter &quot;fftrate&quot;
defaults.pcm.dmix.rate 48000            # Default
...</code></pre></div><div class="codebox"><pre><code>$ audacious 2&gt;&amp;1 &#039;rudra veena and pakhawaj.flac&#039;
Input:  44100 Hz, 2 ch, &#039;s32_le&#039; (0xa): dummy = 0, period = 1764
Output: 48000 Hz, 2 ch, &#039;s32_le&#039; (0xa): dummy = 0, period = 1920
Rates:  44100 --&gt; 48000 (J: 0.00%, T: FFT, W: Vorbis)
Ok.</code></pre></div><div class="codebox"><pre><code>$ audacious 2&gt;&amp;1 *.dsf
Input:  1411200 Hz, 2 ch, &#039;s32_le&#039; (0xa): dummy = 0, period = 56448
Output: 48000 Hz, 2 ch, &#039;s16_le&#039; (0x2): dummy = 0, period = 1920
Rates:  1411200 --&gt; 48000 (J: 0.00%, T: FFT, W: Vorbis)
Ok.</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (igorzwx)]]></author>
			<pubDate>Sat, 15 Nov 2025 22:01:23 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=59689#p59689</guid>
		</item>
		<item>
			<title><![CDATA[How to detect hidden ALSA resampling]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=59271#p59271</link>
			<description><![CDATA[<p>1. Make fftrate the default ALSA resampler</p><div class="codebox"><pre><code>$ cat ~/.asoundrc
defaults.pcm.rate_converter &quot;fftrate&quot;</code></pre></div><div class="codebox"><pre><code>$ file &#039;rudra veena and pakhawaj.flac&#039;
rudra veena and pakhawaj.flac: FLAC audio bitstream data, 16 bit, stereo, 44.1 kHz, 49123284 samples</code></pre></div><div class="codebox"><pre><code>$ file audio_test_48kHz_16bit.wav
audio_test_48kHz_16bit.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, stereo 48000 Hz</code></pre></div><p>2. Run media players with debug <span class="bbc">2&gt;&amp;1</span></p><div class="codebox"><pre><code>$ audacious 2&gt;&amp;1 &#039;rudra veena and pakhawaj.flac&#039;
Input:  44100 Hz, 2 ch, &#039;s32_le&#039; (0xa): dummy = 0, period = 940
Output: 48000 Hz, 2 ch, &#039;s16_le&#039; (0x2): dummy = 0, period = 1024
Rates:  30080 --&gt; 32768 (J: 0.09%, T: FFT, W: Vorbis)
Ok.</code></pre></div><div class="codebox"><pre><code>$ /usr/bin/totem 2&gt;&amp;1 &#039;rudra veena and pakhawaj.flac&#039;
Input:  44100 Hz, 2 ch, &#039;s16_le&#039; (0x2): dummy = 0, period = 940
Output: 48000 Hz, 2 ch, &#039;s16_le&#039; (0x2): dummy = 0, period = 1024
Rates:  30080 --&gt; 32768 (J: 0.09%, T: FFT, W: Vorbis)
Ok.</code></pre></div><div class="quotebox"><blockquote><div><p>Notice that <span class="bbc">Jitter = 0.09%</span></p><div class="codebox"><pre><code>Rates:  30080 --&gt; 32768 (J: 0.09%, T: FFT, W: Vorbis)</code></pre></div><p>It means that resampling is not exact. This is because of Debian/Devuan defaults:</p><div class="codebox"><pre><code>period_size  1024
periods      16 </code></pre></div><p>See: <span class="bbc">/usr/share/alsa/pcm/dmix.conf</span></p></div></blockquote></div><div class="codebox"><pre><code>$ mpv 2&gt;&amp;1 &#039;rudra veena and pakhawaj.flac&#039;
 (+) Audio --aid=1 (flac 2ch 44100Hz)
AO: [alsa] 48000Hz stereo 2ch s16</code></pre></div><div class="codebox"><pre><code>$ mpv 2&gt;&amp;1 audio_test_48kHz_16bit.wav
 (+) Audio --aid=1 (pcm_s16le 2ch 48000Hz)
AO: [alsa] 48000Hz stereo 2ch s16</code></pre></div><p>3. Check <span class="bbc">hw_params</span></p><div class="codebox"><pre><code>$ cat /proc/asound/cards
 0 [system]:  USB-Audio - iMic USB audio system
              Griffin Technology, Inc iMic USB audio system at usb-0000:00:1a.0-1.3.4, full s</code></pre></div><div class="codebox"><pre><code>$ cat /proc/asound/system/pcm0p/sub0/hw_params
access: MMAP_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 48000 (48000/1)
period_size: 1024
buffer_size: 16384</code></pre></div><p>This means that the default sample rate is 48kHz. Let us change it. Presumably, there is already a sort of invisible <span class="bbc">dmix</span>, so that we can set <span class="bbc">defaults.pcm.dmix.rate</span> in ALSA config.</p><div class="codebox"><pre><code>$ cat ~/.asoundrc
defaults.pcm.rate_converter &quot;fftrate&quot;
defaults.pcm.dmix.rate 44100</code></pre></div><div class="codebox"><pre><code>$ /usr/bin/totem 2&gt;&amp;1 audio_test_48kHz_16bit.wav
Input:  48000 Hz, 2 ch, &#039;s16_le&#039; (0x2): dummy = 0, period = 480
Output: 44100 Hz, 2 ch, &#039;s16_le&#039; (0x2): dummy = 0, period = 441
Rates:  48000 --&gt; 44100 (J: 0.00%, T: FFT, W: Vorbis)
Ok.</code></pre></div><div class="codebox"><pre><code>$ mpv 2&gt;&amp;1 audio_test_48kHz_16bit.wav
 (+) Audio --aid=1 (pcm_s16le 2ch 48000Hz)
AO: [alsa] 44100Hz stereo 2ch s16</code></pre></div><div class="codebox"><pre><code>$ mpv 2&gt;&amp;1 &#039;rudra veena and pakhawaj.flac&#039;
 (+) Audio --aid=1 (flac 2ch 44100Hz)
AO: [alsa] 44100Hz stereo 2ch s16</code></pre></div><div class="codebox"><pre><code>$ cat /proc/asound/system/pcm0p/sub0/hw_params
access: MMAP_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 44100 (44100/1)
period_size: 2734
buffer_size: 11026</code></pre></div><p>It works because <span class="bbc">dmix</span> is already enabled.</p><div class="quotebox"><blockquote><div><p>Debian Wiki:<br /> Advanced features such as mixing should already be configured with sane defaults.<br />_https://wiki.debian.org/ALSA#Configuration</p></div></blockquote></div><p>This means that there is already a very advanced software mixer with <span class="bbc">dmix</span> and other plugins configured for pulseaudio. It might be obvious that this strange construction was created to imitate &quot;bit perfect&quot; playback of audiophile apps for macOS: media players can easily change the default sample rate of the software mixer to avoid software resampling. Try &quot;bit perfect&quot; mode of Audacious for macOS. It makes sense for macOS, because the built-in HW resampler of the DAC is better than the software resampler of macOS.</p><p>Why do we need this Stone Age technology? Configure a normal mixer with <span class="bbc">arateconf</span> and forget about problems with sound quality. The so-called &quot;bit perfect&quot; is not needed, because the fftrate resampler is much better than the built-in HW resampler of your DAC. You can safely configure fftrate for the maximal sample rate supported by your DAC.</p><p><strong>NOTE:</strong> When software mixer configured by arateconf, mpv does not resample anything,</p><div class="codebox"><pre><code>$ mpv &#039;rudra veena and pakhawaj.flac&#039;
 (+) Audio --aid=1 (flac 2ch 44100Hz)
Input:  44100 Hz, 2 ch, &#039;s16_le&#039; (0x2): dummy = 0, period = 1764
Output: 48000 Hz, 2 ch, &#039;s16_le&#039; (0x2): dummy = 0, period = 1920
Rates:  44100 --&gt; 48000 (J: 0.00%, T: FFT, W: Vorbis)
Ok.
AO: [alsa] 44100Hz stereo 2ch s16</code></pre></div><p>Explanation:</p><div class="codebox"><pre><code>$ mpv &#039;rudra veena and pakhawaj.flac&#039;
 (+) Audio --aid=1 (flac 2ch 44100Hz)       # mpv Input 
AO: [alsa] 44100Hz stereo 2ch s16           # mpv Output --&gt; ALSA software mixer

# ALSA software mixer: fftrate
Input:  44100 Hz, 2 ch, &#039;s16_le&#039; (0x2): dummy = 0, period = 1764
Output: 48000 Hz, 2 ch, &#039;s16_le&#039; (0x2): dummy = 0, period = 1920
Rates:  44100 --&gt; 48000 (J: 0.00%, T: FFT, W: Vorbis)
Ok.</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (igorzwx)]]></author>
			<pubDate>Fri, 07 Nov 2025 16:07:53 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=59271#p59271</guid>
		</item>
	</channel>
</rss>
