<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Modartt user forum - Linux latency with pipewire?]]></title>
	<link rel="self" href="https://forum.modartt.com/extern.php?action=feed&amp;tid=11154&amp;type=atom"/>
	<updated>2024-01-25T19:26:55Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.modartt.com/viewtopic.php?id=11154</id>
		<entry>
			<title type="html"><![CDATA[Re: Linux latency with pipewire?]]></title>
			<link rel="alternate" href="https://forum.modartt.com/viewtopic.php?pid=994924#p994924"/>
			<content type="html"><![CDATA[<p>Just came back to say how much I love pianoteq, it puts a smile on my face that&#039;s there right now :-)&nbsp; (Bluethner, Steinway D)</p><p>And, for anybody else reading this thread later:</p><p>1. Do what it says in the Pianoteq linux README (personally I skipped the part about CPU frequency throttling and it works fine: see my first post re that)<br />2. Do what @Lycomedes says to do here <a href="https://forum.modartt.com/viewtopic.php?pid=994443#p994443">https://forum.modartt.com/viewtopic.php...43#p994443</a></p><p>After that everything has worked fine for me, if I&#039;d done that to start with I&#039;d not have needed to do any of the experimentation I did here!</p>]]></content>
			<author>
				<name><![CDATA[un_regard]]></name>
				<uri>https://forum.modartt.com/profile.php?id=9493</uri>
			</author>
			<updated>2024-01-25T19:26:55Z</updated>
			<id>https://forum.modartt.com/viewtopic.php?pid=994924#p994924</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Linux latency with pipewire?]]></title>
			<link rel="alternate" href="https://forum.modartt.com/viewtopic.php?pid=994923#p994923"/>
			<content type="html"><![CDATA[<div class="quotebox"><cite>shiihs wrote:</cite><blockquote><p>Pipewire has this behavior where it will use the highest quality settings asked for by any program running on your computer for all running programs in your computer. What I mean by that is that by starting a second program that asks for a lower quantum value (e.g. pavucontrol), all other running programs now suddenly also use the lower quantum value which can result in sudden &quot;magic&quot; solution for problems &quot;without changing any settings&quot;.</p></blockquote></div><p>That&#039;s useful information, thanks.&nbsp; I think in my case what happened here is just that I didn&#039;t set the buffer size and sample rate as suggested and then listen carefully to what I heard.</p>]]></content>
			<author>
				<name><![CDATA[un_regard]]></name>
				<uri>https://forum.modartt.com/profile.php?id=9493</uri>
			</author>
			<updated>2024-01-25T19:24:55Z</updated>
			<id>https://forum.modartt.com/viewtopic.php?pid=994923#p994923</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Linux latency with pipewire?]]></title>
			<link rel="alternate" href="https://forum.modartt.com/viewtopic.php?pid=994788#p994788"/>
			<content type="html"><![CDATA[<div class="quotebox"><cite>un_regard wrote:</cite><blockquote><p>Good news: I think the latency is gone!&nbsp; <br />Bad news: I have no idea what changed.&nbsp; <br />I was regularly restarting pipewire, pipewire-pulse, and wireplumber, so I don&#039;t think it&#039;s that.</p></blockquote></div><p>I suspect you&#039;ve solved your problem by now, but I wanted to share a small quirk I discovered about pipewire. Pipewire has this behavior where it will use the highest quality settings asked for by any program running on your computer for all running programs in your computer. What I mean by that is that by starting a second program that asks for a lower quantum value (e.g. pavucontrol), all other running programs now suddenly also use the lower quantum value which can result in sudden &quot;magic&quot; solution for problems &quot;without changing any settings&quot;.</p>]]></content>
			<author>
				<name><![CDATA[shiihs]]></name>
				<uri>https://forum.modartt.com/profile.php?id=8448</uri>
			</author>
			<updated>2024-01-20T14:34:41Z</updated>
			<id>https://forum.modartt.com/viewtopic.php?pid=994788#p994788</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Linux latency with pipewire?]]></title>
			<link rel="alternate" href="https://forum.modartt.com/viewtopic.php?pid=994480#p994480"/>
			<content type="html"><![CDATA[<p>On my setup with 48k/128 the latency is negligible, it feels like playing an acoustic piano.&nbsp; It may depend on your hardware, and direct ALSA may perform better than PipeWire.</p>]]></content>
			<author>
				<name><![CDATA[Lycomedes]]></name>
				<uri>https://forum.modartt.com/profile.php?id=8410</uri>
			</author>
			<updated>2024-01-07T21:39:04Z</updated>
			<id>https://forum.modartt.com/viewtopic.php?pid=994480#p994480</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Linux latency with pipewire?]]></title>
			<link rel="alternate" href="https://forum.modartt.com/viewtopic.php?pid=994473#p994473"/>
			<content type="html"><![CDATA[<p>Experimenting some more (reboots, removing PT config file, changing PT settings):</p><p>I think most of the difference is just from the buffer size.&nbsp; I believe when I reported still hearing noticeable latency at 48k sample rate and 256 buffer in pianoteq didn&#039;t make much difference, I was *expecting* to still hear the delay, and I did for real, but it was significantly reduced but just about still audible.&nbsp; Really it&#039;s not very noticeable at all at the level I&#039;m now seeing even at 256 and perhaps 128 is even better.</p><p>So basically @Lycomedes had it exactly right (also they suggested 128 buffer size and I&#039;d not paid attention and picked 256).</p><p>Only thing I&#039;m still a bit surprised by is that having &quot;measured&quot; (in the somewhat sloppy way available to me) around 80 ms total latency, I was surprised that the difference between 10 ms and 5 ms (512 and 256 buffer size at 48k) made an audible difference.&nbsp; But it seems to, I can&#039;t explain why.</p>]]></content>
			<author>
				<name><![CDATA[un_regard]]></name>
				<uri>https://forum.modartt.com/profile.php?id=9493</uri>
			</author>
			<updated>2024-01-07T20:09:02Z</updated>
			<id>https://forum.modartt.com/viewtopic.php?pid=994473#p994473</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Linux latency with pipewire?]]></title>
			<link rel="alternate" href="https://forum.modartt.com/viewtopic.php?pid=994471#p994471"/>
			<content type="html"><![CDATA[<div class="quotebox"><cite>un_regard wrote:</cite><blockquote><p>I wonder where it stores its settings, so I can wipe them to help me see exactly what makes the difference?</p></blockquote></div><p>The answer to that seems to be (thanks to `strace -e trace=file`):</p><p>~/.config/Modartt/Pianoteq81.prefs</p>]]></content>
			<author>
				<name><![CDATA[un_regard]]></name>
				<uri>https://forum.modartt.com/profile.php?id=9493</uri>
			</author>
			<updated>2024-01-07T19:48:51Z</updated>
			<id>https://forum.modartt.com/viewtopic.php?pid=994471#p994471</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Linux latency with pipewire?]]></title>
			<link rel="alternate" href="https://forum.modartt.com/viewtopic.php?pid=994470#p994470"/>
			<content type="html"><![CDATA[<p>One thing that makes this harder: I can see that pianoteq retains its settings across restarts, and even if I wipe the directory where I extracted the demo and extract the demo again before restarting.</p><p>I wonder where it stores its settings, so I can wipe them to help me see exactly what makes the difference?&nbsp; But maybe that&#039;s for another thread.</p><p>Perhaps from bitter experience from software as a day job, I never fully trust ways to &quot;reset&quot; software that are controlled by the software itself!&nbsp; I&#039;d rather just wipe it completely and try again.</p>]]></content>
			<author>
				<name><![CDATA[un_regard]]></name>
				<uri>https://forum.modartt.com/profile.php?id=9493</uri>
			</author>
			<updated>2024-01-07T19:37:18Z</updated>
			<id>https://forum.modartt.com/viewtopic.php?pid=994470#p994470</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Linux latency with pipewire?]]></title>
			<link rel="alternate" href="https://forum.modartt.com/viewtopic.php?pid=994469#p994469"/>
			<content type="html"><![CDATA[<p>Good news: I think the latency is gone!&nbsp; (I can barely hear it with the two-headphones test)</p><p>Bad news: I have no idea what changed.&nbsp; I was regularly restarting pipewire, pipewire-pulse, and wireplumber, so I don&#039;t think it&#039;s that.</p><p>Right now, I have this in pianoteq:</p><p>Audio device type: ALSA<br />Audio output: PipeWire Sound Server<br />Sample rate: 48000 Hz<br />Audio buffer size: 256 samples (5.3 ms)</p><p>and in pipewire (I commented out my config file changes and ran `systemctl --user restart pipewire pipewire-pulse wireplumber` again):</p><div class="codebox"><pre><code>$ pw-metadata -n settings 
Found &quot;settings&quot; metadata 30
update: id:0 key:&#039;log.level&#039; value:&#039;2&#039; type:&#039;&#039;
update: id:0 key:&#039;clock.rate&#039; value:&#039;16000&#039; type:&#039;&#039;
update: id:0 key:&#039;clock.allowed-rates&#039; value:&#039;[ 16000 ]&#039; type:&#039;&#039;
update: id:0 key:&#039;clock.quantum&#039; value:&#039;1024&#039; type:&#039;&#039;
update: id:0 key:&#039;clock.min-quantum&#039; value:&#039;32&#039; type:&#039;&#039;
update: id:0 key:&#039;clock.max-quantum&#039; value:&#039;2048&#039; type:&#039;&#039;
update: id:0 key:&#039;clock.force-quantum&#039; value:&#039;0&#039; type:&#039;&#039;
update: id:0 key:&#039;clock.force-rate&#039; value:&#039;0&#039; type:&#039;&#039;</code></pre></div>]]></content>
			<author>
				<name><![CDATA[un_regard]]></name>
				<uri>https://forum.modartt.com/profile.php?id=9493</uri>
			</author>
			<updated>2024-01-07T19:33:52Z</updated>
			<id>https://forum.modartt.com/viewtopic.php?pid=994469#p994469</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Linux latency with pipewire?]]></title>
			<link rel="alternate" href="https://forum.modartt.com/viewtopic.php?pid=994468#p994468"/>
			<content type="html"><![CDATA[<div class="quotebox"><cite>un_regard wrote:</cite><blockquote><p>or even quantify it?</p></blockquote></div><p>If you want to try and quantify your latency somewhat, this is what I used to compare with the two-headphones test:</p><div class="codebox"><pre><code>import numpy as np
import pyaudio

sample_rate = 44100
duration = 1  # in seconds
frequency_C = 261.63  # middle C in Hz
delay = 0.08  # 80 ms

t = np.linspace(0, duration, int(sample_rate * duration), False)
tone_C = 0.5 * np.sin(2 * np.pi * frequency_C * t)

delayed = tone_C.copy()
delayed[:int(sample_rate * delay)] = 0

# superimpose the two tones
mixed_tone = tone_C + delayed[:len(tone_C)]

# normalize to 16-bit range
mixed_tone = (mixed_tone * 32767).astype(np.int16)

# play
p = pyaudio.PyAudio()
stream = p.open(format=pyaudio.paInt16, channels=1, rate=sample_rate, output=True, output_device_index=7)
try:
    stream.write(mixed_tone.tobytes())
finally:
    stream.stop_stream()
    stream.close()
    p.terminate()</code></pre></div><p>To run that you&#039;d need `numpy` and `pyaudio` installed from PyPI - I won&#039;t go into how to install those since I wouldn&#039;t know where I&#039;m starting from in the context of your system and background knowledge.&nbsp; Also it seems one needs to figure out which output_device_index to use - for that I used this snippet and looked for a device named &quot;pipewire&quot; in the output:</p><div class="codebox"><pre><code>for i in range(p.get_device_count()):
    print(i, p.get_device_info_by_index(i))</code></pre></div>]]></content>
			<author>
				<name><![CDATA[un_regard]]></name>
				<uri>https://forum.modartt.com/profile.php?id=9493</uri>
			</author>
			<updated>2024-01-07T18:54:25Z</updated>
			<id>https://forum.modartt.com/viewtopic.php?pid=994468#p994468</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Linux latency with pipewire?]]></title>
			<link rel="alternate" href="https://forum.modartt.com/viewtopic.php?pid=994467#p994467"/>
			<content type="html"><![CDATA[<div class="quotebox"><cite>Lycomedes wrote:</cite><blockquote><p>I haven’t changed any PipeWire or ALSA config files.&nbsp; I only changed the buffer size in the Pianoteq settings.&nbsp; By default Pianoteq used a high buffer size which caused latency.&nbsp; Setting the buffer size to a low value solved the problem and I get low latency whether I’m using my HP Omen 25L’s internal sound card or my Focusrite Scarlett 2i2.</p></blockquote></div><p>Ah I see - just tried with (in pianoteq &quot;Devices&quot; options) &quot;Sample rate&quot; set to &quot;48000 Hz&quot; and &quot;Audio buffer size&quot; set to &quot;256 samples (5.3 ms)&quot; - no very obvious difference (this time I didn&#039;t try a careful before/after comparison nor compare against my script-generated tones).</p><p>What does &quot;low latency&quot; mean to you?&nbsp; Maybe you&#039;re able to try a two-headphones test or even quantify it?</p>]]></content>
			<author>
				<name><![CDATA[un_regard]]></name>
				<uri>https://forum.modartt.com/profile.php?id=9493</uri>
			</author>
			<updated>2024-01-07T18:49:19Z</updated>
			<id>https://forum.modartt.com/viewtopic.php?pid=994467#p994467</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Linux latency with pipewire?]]></title>
			<link rel="alternate" href="https://forum.modartt.com/viewtopic.php?pid=994466#p994466"/>
			<content type="html"><![CDATA[<div class="quotebox"><cite>un_regard wrote:</cite><blockquote><p>Unfortunately no obvious effect: still a noticeable delay of perhaps 100 ms.</p></blockquote></div><p>Just in case this was all in my head, I thought to try with the headphones connected to the roland on one ear, and pianoteq&#039;s output on the other ear. Very clear delay.</p><p>Then I wrote a script to generate a sound that simulates that (two middle C notes played a short time apart).&nbsp; From comparing that with the two-headphones test, I think the delay between the roland and pianoteq outputs reaching my ears is about 80 ms (plus or minus max 20 ms).</p><p>So with USB audio output contributing say 20 ms max (measured 29 ms round trip), that leaves roughly 60 ms to be accounted for in the pipeline involving USB midi input and pianoteq processing.&nbsp; Does that seem too high?&nbsp; Should I be able to reduce it?&nbsp; Or should I just be less fussy? <i class="far fa-smile smiley"></i></p>]]></content>
			<author>
				<name><![CDATA[un_regard]]></name>
				<uri>https://forum.modartt.com/profile.php?id=9493</uri>
			</author>
			<updated>2024-01-07T18:39:24Z</updated>
			<id>https://forum.modartt.com/viewtopic.php?pid=994466#p994466</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Linux latency with pipewire?]]></title>
			<link rel="alternate" href="https://forum.modartt.com/viewtopic.php?pid=994465#p994465"/>
			<content type="html"><![CDATA[<p>I haven’t changed any PipeWire or ALSA config files.&nbsp; I only changed the buffer size in the Pianoteq settings.&nbsp; By default Pianoteq used a high buffer size which caused latency.&nbsp; Setting the buffer size to a low value solved the problem and I get low latency whether I’m using my HP Omen 25L’s internal sound card or my Focusrite Scarlett 2i2.</p>]]></content>
			<author>
				<name><![CDATA[Lycomedes]]></name>
				<uri>https://forum.modartt.com/profile.php?id=8410</uri>
			</author>
			<updated>2024-01-07T18:34:35Z</updated>
			<id>https://forum.modartt.com/viewtopic.php?pid=994465#p994465</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Linux latency with pipewire?]]></title>
			<link rel="alternate" href="https://forum.modartt.com/viewtopic.php?pid=994464#p994464"/>
			<content type="html"><![CDATA[<div class="quotebox"><cite>rasaru wrote:</cite><blockquote><p>Hi, I only use the Pipewire Sound Server and have banned Jack.</p></blockquote></div><p>Hi, thanks for replying!&nbsp; I don&#039;t have Jack installed either - pipewire-jack is pipewire pretending to be Jack for the benefit of client applications like pianoteq.</p><div class="quotebox"><cite>rasaru wrote:</cite><blockquote><p>(Bitwig DAW runs fine with Pipewire) However, I use openSuse tumbleweed (Liquorix kernel) and a Doug Audio USB DAC with 48k sample rate 256 or less samples. Korg D1 as master keyboard. I can&#039;t detect any delays when playing. (Subjective) Start in terminal pw-top (Manual with: man pw-top). The correct settings for the DAC can vary depending on the model and I have also noticed differences with the USB port (2 or 3). (Cheap DAC)</p><p>see also: <a href="https://wiki.archlinux.org/title/PipeWire">https://wiki.archlinux.org/title/PipeWire</a></p></blockquote></div><p>I just measured my sound card round trip time using audacity and a microphone, it&#039;s 29 ms - doesn&#039;t seem terrible.</p><p>After that, at @Lycomedes suggestion I set my sample rate to 48k and quantum to 256 (which I assume means a buffer capable of holding 256 samples?), ending up with this config (should I set min/max/force values too? couldn&#039;t figure out how to do that):</p><div class="quotebox"><blockquote><p>$ pw-metadata -n settings <br />Found &quot;settings&quot; metadata 30<br />update: id:0 key:&#039;log.level&#039; value:&#039;2&#039; type:&#039;&#039;<br />update: id:0 key:&#039;clock.rate&#039; value:&#039;48000&#039; type:&#039;&#039;<br />update: id:0 key:&#039;clock.allowed-rates&#039; value:&#039;[ 48000 ]&#039; type:&#039;&#039;<br />update: id:0 key:&#039;clock.quantum&#039; value:&#039;256&#039; type:&#039;&#039;<br />update: id:0 key:&#039;clock.min-quantum&#039; value:&#039;32&#039; type:&#039;&#039;<br />update: id:0 key:&#039;clock.max-quantum&#039; value:&#039;2048&#039; type:&#039;&#039;<br />update: id:0 key:&#039;clock.force-quantum&#039; value:&#039;0&#039; type:&#039;&#039;<br />update: id:0 key:&#039;clock.force-rate&#039; value:&#039;0&#039; type:&#039;&#039;</p></blockquote></div><p>Unfortunately no obvious effect: still a noticeable delay of perhaps 100 ms.</p>]]></content>
			<author>
				<name><![CDATA[un_regard]]></name>
				<uri>https://forum.modartt.com/profile.php?id=9493</uri>
			</author>
			<updated>2024-01-07T18:03:46Z</updated>
			<id>https://forum.modartt.com/viewtopic.php?pid=994464#p994464</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Linux latency with pipewire?]]></title>
			<link rel="alternate" href="https://forum.modartt.com/viewtopic.php?pid=994443#p994443"/>
			<content type="html"><![CDATA[<p>Pipewire works well on my Arch desktop with 6.6.9 kernel and no tweaks.&nbsp; Make sure you set the buffer size to a low value like 128 samples, and the sample rate to 48khz or higher.</p>]]></content>
			<author>
				<name><![CDATA[Lycomedes]]></name>
				<uri>https://forum.modartt.com/profile.php?id=8410</uri>
			</author>
			<updated>2024-01-06T12:30:27Z</updated>
			<id>https://forum.modartt.com/viewtopic.php?pid=994443#p994443</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Linux latency with pipewire?]]></title>
			<link rel="alternate" href="https://forum.modartt.com/viewtopic.php?pid=994415#p994415"/>
			<content type="html"><![CDATA[<p>Hi, I only use the Pipewire Sound Server and have banned Jack. (Bitwig DAW runs fine with Pipewire) However, I use openSuse tumbleweed (Liquorix kernel) and a Doug Audio USB DAC with 48k sample rate 256 or less samples. Korg D1 as master keyboard. I can&#039;t detect any delays when playing. (Subjective) Start in terminal pw-top (Manual with: man pw-top). The correct settings for the DAC can vary depending on the model and I have also noticed differences with the USB port (2 or 3). (Cheap DAC)</p><p>see also: <a href="https://wiki.archlinux.org/title/PipeWire">https://wiki.archlinux.org/title/PipeWire</a></p>]]></content>
			<author>
				<name><![CDATA[rasaru]]></name>
				<uri>https://forum.modartt.com/profile.php?id=6607</uri>
			</author>
			<updated>2024-01-04T02:56:46Z</updated>
			<id>https://forum.modartt.com/viewtopic.php?pid=994415#p994415</id>
		</entry>
</feed>
