THE TIPS CONTINUE HERE: [Only registered and activated users can see links. Click here to register]
How to Optimize PulseAudio for a (Ubuntu) Linux DAW
...and some other good basic optimizations/tweaks
This is a guide primarily for Ubuntu (Studio) Linux users, but some of the tweaks will work for other types of Linux. The tweaks are NOT just for PulseAudio; they will help a Linux system run without getting buffer underruns (xruns).
This should be helpful for anybody who wants to try out Linux and doesn't yet use or prefer or need JACK Audio Connection Kit.
Also, I have included the main initial DAW tweaks I do on a fresh Ubuntu Linux install either before or after installing the low-latency kernel.
I explain how to install the low-latency kernel in a different post here at:
[Only registered and activated users can see links. Click here to register]
. But in this one post, are most of the main tweaks/optimizations that make the biggest differences aside from how to install WINE-staging. I will explain that too later.
Many modern Linux distros come with PulseAudio installed by default. So since IT IS POSSIBLE TO IMPROVE PULSEAUDIO's LATENCY, you might as well do it if you have this chance. The information I'm providing here is incomplete for now. I'll be adding more info as I get the uploads done
These first two images document the most important essential things to implement which will help jumpstart Linux's PulseAudio to get it capable of working with Wine to run programs like Cockos REAPER:
I forget what "tsched" does anymore, but I remember that it disables a type of audio driver scheduling and thus works around some technical problems I think related to synchronization with the audio driver. It doesn't cause problems though, in fact it's probably the most crucial DAW tweak for enabling PulseAudio to work, yet it's hardly documented anywhere at all.
It's not so obvious, but absolutely needed to get Reaper and other programs to play in Wine besides lowering the default buffer size (described next).
...will possibly work better than default-fragments=2 on USB audio devices according to the AVLINUX manual.
But if you have a PCI or built-in audio interface or maybe firewire, then default-fragments=2 might be better.
Keep default-fragment-size-msec equalling 2, because the two numbers multiplied result in latency if too big.
On my system, I changed from 4 & 2 to 3 & 2 and didn't notice any problems.
OK, while we're at it, here's part of how to disable unneeded services in Ubuntu Studio Linux:
Essentially, you make a *.override file with the word "manual" in it on a single line, and name it the same as the *.conf file but instead of ending in ".conf" it ends in ".override". Those files go into the same directory as the *.conf files
Ubuntu Linux, this is within "/etc/init". You will need temporary root access privileges to do stuff in that directory. That's a different topic, so I won't go into that. There are other webpages to explain how to "get root access" or "sudo" or "gksu" or "su" or whatnot. I'm assuming you already know that or can learn how elsewhere. This way I don't have to explain all the technical risks of that or get flamed about that topic.
The "GVFS" services files shown above have been renamed to prevent them from loading.
".disabled" was added to each name. It's important to see this because Ubuntu Studio Linux now puts them in a different place than where they used to be. Also their native names have changed a bit for some of the services. However, a giveaway is the "g"... "vfs" in the filename(s).
OK, the one of the pictures above lists services within "
/usr/share/dbus-1/services/" that can also be disabled by renaming them.
Add ".disabled" to their names and then they won't run at boot. If you need to re-enable them, remove the ".disabled" from their names and reboot. You need temporary root privileges to do stuff in that directory.
Note that you might lose access to your trash bin, so you might need to install BleachBit or create a script just to be able to empty the trash bins around your system. Also, you might lose the ability to view or edit emblems icons. However, disabling those particular gvfs services is specifically designed to prevent buffer underruns ("xruns").
OK, after you reboot after implementing the stuff listed above, things should already be a lot smoother and this should have no bad effects upon JACK users either.
Here's what my Reaper and WINE settings look like in a working system:
WASAPI seems to work better with PulseAudio than ASIO unless you are on AVLINUX or similar already.
The thing to realise about REAPER's settings for inputs and outputs, is that whatever you put here is"absorbed" and "contextualised" by what your Wine Configuration (winecfg) settings are. If "winecfg" (executable) can be found in "/opt/wine-devel/bin/" or "/opt/wine-staging/bin/". Personally, I use wine-staging because it's the most up to date and has more features than regular wine or even wine-development.
OK, So the image above is a little bit misleading because it says to set both inputs and outputs to "PulseAudio". Essentially this is still true, but the trick is to set it to PulseAudio in winecfg (Wine Configuration) instead of at this particular page in Reaper's preferences. So it's OK to have them both set for "default" as long as you choose the correct settings in winecfg. If by chance PulseAudio isn't installed or you disabled it, winecfg (Wine Configuration) will point to and allow and use ALSA settings instead, unless you have some other type of setup. So the "default" pretty much points to ALSA in absence of you telling it to be PulseAudio.
This is important because if you don't select the right signal flow, you won't hear anything from Reaper.
In the image above, the inputs are disabled within REAPER by putting in "0" (zero). This saves A LOT of CPU time, so you might as do it and change it to your number of used inputs right before you record. And after you are done, set it back to zero so you can compose better again.
Hopefully, this image isn't too messy and helps to explain. If it's messiness bothers you, let that be a mental reminder that you need to choose settings carefully in BOTH places AND in QasMixer, which you SHOULD install if you aren't using Ubuntu Studio:
QasMixer looks something like this:
You will need to probably press F6 to get the main display. Be sure to edit it's preferences to get operation predictable and tidy.
IMPORTANT: Some devices will show up as "USB AUDIO CODEC" and others as "PnP USB Audio Device"(?) or something like that.
These are just generic names for gear such as or similar to Alesis M1Active 320 USB Monitors/Audio Interface.
Make sure that ALSA and QasMixer are not choosing your MIDI keyboard and trying to use those to play audio.
If you are getting some anomalies, you also should do a "sudo apt-get install --reinstall alsa" or "alsa-base";
It will probably download and install quickly. On my system, that fixed MIDI buffer errors of Xubuntu.
Next: Disable last file access logging. Actually, you might want to do this before you install or copy much of anything, just so that everything is faster. This essentially speeds up disk I/O (input & output) because logging of each file access is not needed AT ALL for most users and most programs. Windows DAW users should and often do the same thing, but using NTFS utils. This is Linux, so it's different, but not hard...
Edit "/etc/fstab" with a text editor in root mode:
Be careful not to type the wrong thing, or boot will be slow or maybe not at all, or your swap partition will be forgotten or whatnot. But don't worry, all you are probably going to do is add "noatime," to part of the line which corresponds to the ID of your main system drive. I don't know what else you might want to put if it's a solid state drive, but this won't hurt:
The above assumes that the drive is formatted as ext2 (non-encrypted), or ext3 (what I prefer). If the OS is designed for ext4, you will still get a few ext4 features even if you still only use ext3. Yet since ext3 is journalled, system stability is better than ext2 if there's a power loss or crash.
I did try ext4 for a while, and didn't notice much of a speed increase but did have some problems because ext4 was still in development in 2016 and there were incompatibility issues with parts of my system and gParted. Nothing died, but it was frustrating till I read the fine print. However, if you prefer to use ext4 file system, here's my tips for that:
$ man ext4
can explain more about those ext4 settings. They aren't entirely backwards compatible, and converting from ext3 to ext4 on Ubuntu isn't as easy as it seems. And it's MUCH MUCH harder to convert from ext4 back to ext3 without losing data. But if you are building a Linux system from scratch, it will probably be much of a relief to choose ext3 and skip a lot of headaches in the future.
Don't use FAT(32) for anything except for flash drives and (micro)SD cards. You won't want to use NTFS either. But you'll want to expect that Windows won't recognize the ext filesystems and will either ignore them or erase them if not blocked.
If you do like to run Puppy Linux, FAT(32) is sometimes OK, and at least just about anything can read and write to it even though it has filesize and metadata limitations. Even Windows XP 32-bit can be installed into FAT32 if you are careful and know the risks. But anyways, if you do use FAT, you will probably want to enable the LBA (Logical Block Access) flag using gParted or whatever partition software you are using to format partitions.
VERY IMPORTANT: If installing Ubuntu Studio or some other Ubuntu derivative from a LiveDVD or .ISO, be sure to choose "SOMETHING ELSE" and be extremely careful. Otherwise, your entire hard drive will possibly get erased as the default choice.
It's worth mentioning the SWAP partition and UUID's...
4096 MB (4GB) is probably big enough. If using gParted, you can copy the partition UUID from right-click --> "Information". This is the UUID that is listed in /etc/fstab after a successful install (if you created a SWAP parition). You can use the same technique to check or change UUID's (using gParted) for other partitions. I'm not being as clear as I need to be about this topic, but suffice to say... install gParted and gdebi via Synaptic Package Manager and install Synaptic via "apt-get install synaptic" as soon as you can boot up Linux and after you have a working internet connection.
Gdebi package manager is much more easy to use than the current system default (Gnome Software).
About partitions... Puppy Linux still requires booting in MBR-BIOS mode and using an MBR formatted drive. UEFI/EFI/GPT booting and drive format (GPT) gets a bit too tricky these days because of the many unsuccessful varieties of BIOSes.
Enable Legacy Boot in your computer's BIOS. You will probably need to disable Secure Boot, in order to do that. It depends upon the manufacturer and whatnot. Also, you should set a fresh computer's BIOS to ACHI (for faster SATA drive access) instead of leaving it at IDE. If it's already at one or the other, make a note of it if you are trying to dual boot. Windows won't boot if it doesn't recognize ACHI mode and it's not always an easy fix unless you set it back to IDE and accept having slower drive access.
Of course I'm digressing a bit, but these are the types of infos that you needed to know in case some readers are reading this to help them set up a fresh system or troubleshoot an existing system. OK... more in the next pages...
But first, one last GOOD IMPORTANT Linux DAW optimization: Enable CPU Threading (for speed increase)
This tip came from the AVLINUX manual also. It's worth reading even if you choose not to use AVLINUX yet.
There's some nice tips and explanations of a few common customizations as well as why AVLINUX tends to work (due to it's own customizations).
Notice how I removed the "quiet splash" items... this is REALLY USEFUL, so you can see what Linux is doing or trying to do during bootup. This helps you if something is slow or busy or faulty or needing your assistance. Pretty pictures can't do that, you need to know what's happening behind the scenes. However, if you DO want a pretty picture at the GRUB menu, take a screenshot of your system after boot, save it as "/boot.png" and edit it in an image editor to look how you want. Probably it should be set for root:root permissions too. Or just give all users read/write access to it. I'm not entirely sure of the exact protections, but you want root to be able to access it as well as yourself. Save the file in the top directory ("/").
By taking a screenshot (with prt sc/upper right key or function on your QWERTY keyboard), you can ctrl-v / paste into a graphics image editor program the exact right size without having to guess or check. Be sure to save as a standard .PNG with compression=9,all filters if possible.
If I remember correctly, if you hold down the spacebar during Linux boot, the GRUB boot menu will show up. GRUB boot menu let's you choose which kernel to run. This is helpful if you need to select the low-latency kernel or a previous kernel version that you haven't yet deleted.
OK, one last service disablement tip... useful and doesn't seem to be mentioned in the usual guides elsewhere:
This image should be self-explanatory. You create a folder to put stuff so that those *.desktop files don't autoload at start.
THE TIPS CONTINUE HERE: [Only registered and activated users can see links. Click here to register]