<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>pulseaudio on foosel.net</title><link>https://foosel.net/tags/pulseaudio/</link><description>Recent content in pulseaudio on foosel.net</description><generator>Hugo</generator><language>en-us</language><copyright>Gina Häußge (foosel)</copyright><lastBuildDate>Sat, 11 Mar 2023 00:00:00 +0000</lastBuildDate><atom:link href="https://foosel.net/tags/pulseaudio/feed.xml" rel="self" type="application/rss+xml"/><item><title>How to add an audio delay for video conferencing on Linux/Pulseaudio</title><link>https://foosel.net/til/how-to-add-an-audio-delay-for-video-conferencing-on-linuxpulseaudio/</link><pubDate>Sat, 11 Mar 2023 00:00:00 +0000</pubDate><guid>https://foosel.net/til/how-to-add-an-audio-delay-for-video-conferencing-on-linuxpulseaudio/</guid><description>&lt;p&gt;After recently switching to work under Linux, I needed a way to replicate &lt;a href="../how-to-add-an-audio-delay-for-video-conferencing-on-windows"&gt;my existing solution for delaying audio under Windows&lt;/a&gt; under Linux/Pulseaudio.&lt;/p&gt;
&lt;p&gt;To once again explain my situation, I use &lt;a href="https://obsproject.com/"&gt;OBS&lt;/a&gt; also for video conferencing, through the virtual camera&lt;sup id="fnref:1"&gt;&lt;a href="#fn:1" class="footnote-ref" role="doc-noteref"&gt;1&lt;/a&gt;&lt;/sup&gt;. OBS does not offer a built-in way to provide a virtual microphone with all the filters and such applied as well (in my case noise reduction and a limiter), so I need to solve this in a separate way. Additionally, my camera setup has a small delay of around 350ms that I also need to compensate by delaying my audio.&lt;/p&gt;</description><content:encoded><![CDATA[<p>After recently switching to work under Linux, I needed a way to replicate <a href="../how-to-add-an-audio-delay-for-video-conferencing-on-windows">my existing solution for delaying audio under Windows</a> under Linux/Pulseaudio.</p>
<p>To once again explain my situation, I use <a href="https://obsproject.com/">OBS</a> also for video conferencing, through the virtual camera<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>. OBS does not offer a built-in way to provide a virtual microphone with all the filters and such applied as well (in my case noise reduction and a limiter), so I need to solve this in a separate way. Additionally, my camera setup has a small delay of around 350ms that I also need to compensate by delaying my audio.</p>
<p>OBS offers a monitoring port that you can push your audio devices on, and that will get the filters applied, but <a href="https://obsproject.com/forum/threads/connecting-obs-with-zoom-without-av-syncing-issues.123960/post-469274">none of the configured offsets</a>. On Windows, I solved this <a href="../how-to-add-an-audio-delay-for-video-conferencing-on-windows">by using a combination of two Virtual Cable devices and RadioDelay between the two</a>.</p>
<p>Today I rebuild basically the same setup on Linux via a bunch of virtual <a href="https://www.freedesktop.org/wiki/Software/PulseAudio/">Pulseaudio</a> devices. I have this in <code>~/.local/bin/obs-virtual-mic</code>:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#75715e">#!/bin/bash
</span></span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># create virtual speaker</span>
</span></span><span style="display:flex;"><span>pactl load-module module-null-sink sink_name<span style="color:#f92672">=</span>Virtual-Speaker sink_properties<span style="color:#f92672">=</span>device.description<span style="color:#f92672">=</span>Virtual-Speaker
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># create delayed virtual speaker &amp; associated mic</span>
</span></span><span style="display:flex;"><span>pactl load-module module-null-sink sink_name<span style="color:#f92672">=</span>Virtual-Speaker-Delayed sink_properties<span style="color:#f92672">=</span>device.description<span style="color:#f92672">=</span>Virtual-Speaker-Delayed
</span></span><span style="display:flex;"><span>pactl load-module module-remap-source source_name<span style="color:#f92672">=</span>Remap-Source master<span style="color:#f92672">=</span>Virtual-Speaker-Delayed.monitor
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># copy from virtual to delayed virtual with 350ms delay</span>
</span></span><span style="display:flex;"><span>pactl load-module module-loopback latency_msec<span style="color:#f92672">=</span><span style="color:#ae81ff">350</span> source<span style="color:#f92672">=</span>Virtual-Speaker.monitor sink<span style="color:#f92672">=</span>Virtual-Speaker-Delayed
</span></span></code></pre></div><p>Let&rsquo;s take a closer look at what this does:</p>
<ul>
<li>create two virtual sinks <code>Virtual-Speaker</code> and <code>Virtual-Speaker-Delayed</code> with <code>pactl load-module module-null-sink ...</code></li>
<li>create a virtual source for the delayed sink via <code>pactl load-module module-remap-source ...</code></li>
<li>finally mirror the sound from <code>Virtual-Speaker.monitor</code> to <code>Virtual-Speaker-Delayed</code> while adding a latency of 350ms</li>
</ul>
<p>I run this. Then OBS gets set to use <code>Virtual-Speaker</code> as monitor. In my video conferencing software I then use <code>Virtual-Speaker-Delayed</code> as my input to get my video and audio synced up.</p>
<div class="footnotes" role="doc-endnotes">
<hr>
<ol>
<li id="fn:1">
<p>I prefer the flexibility and control it gives me with regards to how I show up, how my screen shows up, etc, vs what you usually get from your run-of-the-mill video conferencing tool.&#160;<a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
</ol>
</div>
]]></content:encoded></item></channel></rss>