Skip to content

Instantly share code, notes, and snippets.

@fufexan
Forked from EllySensei/TUT.md
Last active April 26, 2021 15:10
Show Gist options
  • Save fufexan/8286b38392a55039f6d26e2817e8835a to your computer and use it in GitHub Desktop.
Save fufexan/8286b38392a55039f6d26e2817e8835a to your computer and use it in GitHub Desktop.

Elly's Low Latency osu! on Linux Tutorial

Ever since ThePooN's osu! on Linux tutorial got released, a lot of developments have since been discovered. Such as a new PulseAudio replacement that theoretically achieves lower latency and fixes, but the fundamentals are still there.

Disclaimer: This is mostly a tutorial for Arch Linux users and all flavours of it, you can follow the tutorial but it would be different for others.

Fundamentals: Installing WINE and making the WINEPREFIX

First of all, we have to install WINE, with patches by PooN enabled and stability patches to fix some crashes.

For Arch Linux I have made a package that was made using my fork.

If you want to build from source (which I recommend), you can use my fork or Geno's fork.

For other distributions, you have to build from source but every distro is different so make sure you patched the correct files, you can find the patches that are going to be built in my fork.

Patch the files one by one using patch -p1 < [name of patch].

You need the terminal for these next instructions Quick instruction for Arch users: Uncomment the multilib repository by editing /etc/pacman.conf AS ROOT and removing the # from [multilib] and the server below it, then run sudo pacman -Sy

If you're on Arch, download my package and install it using sudo pacman -U (package name). You will also install the dependencies needed with WINE.

You should also copy this command to install other needed applications. # pacman -S winetricks lib32-libxcomposite lib32-gnutls

We can make the wineprefix now!

From ThePooN

Very basically, the WINEPREFIX is a folder that will be the root of our “Windows install”. No, we won’t install Windows, but it will be considered the root, and we will install libraries/frameworks that osu! needs to run here.

We don’t have to create it, Wine will take care of that for us. All we need to do is set the path to it in our environment. That also means you will need to define it every time you open a new shell and want to manipulate your osu! install and start osu! (unless you define it in your profile, which will make it your default WINEPREFIX, which is pointless since it already has a default value of ~/.wine when undefined).

We will also set WINEARCH to win32. That will make this WINEPREFIX only able to execute 32-bit apps, which is fine in our case. It is recommended to make your prefix 32-bit only if you don’t need 64-bit support, as this is a more stable configuration.

Copy these to your terminal since these are going to be important.

export WINEPREFIX="$HOME/.wine_osu"
export WINEARCH=win32
export PATH=/opt/wine-osu/bin:$PATH

Now to install the dependencies.

winetricks --force dotnet45 gdiplus allfonts

Since these take a bit of time to download, I'll describe what these are: --force is a flag which means it installs everything you need for installing dotnet45.

dotnet45 is .NET Runtime 4.5. If you want gosumemory to work, you need this, unless you're going to use it, dotnet40 will be enough.

gdiplus is the icon rendering library, which you can see with the back icon, as well as other icons that need on the fly rendering.

allfonts are all fonts supplied with winetricks, this is just a quick fix for the thai font and non english glyphs. cjkfonts (Chinese, Japanese, and Korean fonts) are going to be fixed later.

This WILL take time to download and install depending on your download speed.

After this command is done, make a folder where you will house the osu files, change to that folder by using cd <path/to/folder> and run this command

wget https://m1.ppy.sh/r/osu\!install.exe

Then run wine osu\!install.exe

This should theoretically install to the folder you put it on, in case it doesn't, point it to the osu folder you created, it usually is in the My Documents folder, then the osu folder you created. Let it install, then at this point, you can run osu! now, congratulations! But we need some configurations to do.

PipeWire

To give some backstory, PipeWire is a low latency audio backend that can replace PulseAudio which was the old backend we were using until present day.

Since this is still new, this is mostly developing, with a lot more low latency developments on the horizon, this will also (probably) update

To install PipeWire, let's first remove PulseAudio. In Arch Linux, uninstall it by running this command

sudo pacman -Rs pulseaudio pulseaudio-alsa pulseaudio-jack

If pulseaudio-alsa and pulseaudio-jack are not found, remove them from the command. Go through the prompts and remove it from the system. It's best to reboot your system to make sure it is completely removed, or check in the system monitor if all of the processes are removed.

Now let's install PipeWire by running

sudo pacman -S pipewire pipewire-pulse pipewire-alsa pipewire-jack

Once that's installed, you can try running pipewire by running this command: systemctl --user enable pipewire{,-pulse,-media-session} --now

To lower the latency even further, read this carefully.

AS SUDO, edit /etc/pipewire/pipewire.conf with your favorite text editor and find this line.

default.clock.min-quantum = *value*

You might see the default value like 16, you are free to change that and see how far you can go without breaking it. Lower values mean less latency.

You can also optionally change the value of default.clock.quantum for system-wide low-ish latency.

All of the following files belong in /etc/pipewire

pipewire.conf:

context.properties = {
  default.clock.min-quantum = 8 # default is 32
  default.clock.quantum = 256   # optional, default is 1024
}

pipewire-pulse.conf:

context.modules = [
  {
    name = "libpipewire-module-protocol-pulse"
    args = {
      pulse.min.req = 8/48000     # recording minimum quant
      pulse.min.quantum = 8/48000 # playback minimum quant, both are ~0.16ms
    }
  }
]
stream.propeties = {
  node.latency = 32/48000 # adjusting this is not necessary
}

media-session.d/alsa-monitor.conf:

rules = [
	{
		matches = [{ node.name = ~alsa_output.* }]
		actions = {
			update-props = {
				audio.format = "S16LE"
				audio.rate = 192000
				api.alsa.period-size = 160
				#api.alsa.disable-batch = true # USB soundcards use batch mode
			}
		}
	}
]

After all of that, restart pipewire using this command systemctl --user restart pipewire{,-pulse,-media-session}

Parting

After all that, I should just leave you with some parts with troubleshooting cjkfonts using Francesco's guide, and ThePooN's osu! on Linux tutorial to make the osu scripts and running them.

Thank you so much to gonX for helping with what to edit in Pipewire, though this may improve more, and to everyone in PooN's Discord for patches, notable as openglfreak, gonX tdeo, and a lot more people.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment