Topic: Linux tips - fixes for latency, audio glitches, poor performance ...
TL;DR version:
Cut and paste the following in a terminal window and hit enter:
for ((i=0; i<$(cpufreq-info | grep analyzing | wc -l); i++)); do sudo cpufreq-set -g performance -c $i; done
------------------------
Long version:
How I got Pianoteq 5 flying on Linux (after some initial woes)
I had a bit of trouble getting Pianoteq Std working without issues on my Linux Mint 17.2 Dell laptop. It's a fairly capable machine, i5-3337U 1.8GHz, 8GB RAM - should be plenty to run PTQ.
Yet I kept getting crackling/popping sounds every now and again (even without CPU overload), and latency was not all that reliable or great (not near what PTQ claimed) and polyphony was pathetic (<10, at most 20) on "Pessimistic".
Things I tried (but did not solve the problems)
- Low latency Linux kernel (this is usually a good idea)
- JACK audio set up for realtime audio (this actually made things a bit worse; but it wasn't JACK's fault, see below)
- "sudo renice"-ing the 'Pianoteq 5' process to -20 (if you don't know what that means, don't worry; if you're curious, look up the "renice" command in Linux)
What worked in the end:
- Disable CPU throttling and set all CPUs/cores to run at their maximum speed
You can accomplish this with the cpufreq-set command (part of the cpufrequtils package, installed by default on most Linux systems). But first to see your settings and hardware info run cpufreq-info (in a terminal window). The only info you really need is how many CPUs (cores) the OS thinks you have. You can read the full output of cpufreq-info or if it's too much info, do something like this:
ptquser@mycompter:/home/ptquser/Pianoteq Standard 5.42/Pianoteq 5/amd64 > cpufreq-info | grep analyzing
analyzing CPU 0:
analyzing CPU 1:
analyzing CPU 2:
analyzing CPU 3:
So here we have four CPUs/cores and they are numbered 0 to 3. We want to configure all of these for performance, which will disable on-the-fly CPU speed changes and will always run them at their max rated speed (without overclocking). This is accomplished with cpufreq-set:
ptquser@mycompter:/home/ptquser/Pianoteq Standard 5.42/Pianoteq 5/amd64 > sudo cpufreq-set -g performance -c 0
[sudo] password for ptquser:
sudo cpufreq-set -g performance -c 1
sudo cpufreq-set -g performance -c 2
sudo cpufreq-set -g performance -c 3
This fixed all the issues. I torture tested it and polyphony "Pessimistic" goes over 100, latency is non-existent, there are no glitches in the sound output and the CPU never overloads. My final PTQ configuration is:
- Audio device type: ALSA (not using JACK, no need for now but may use it in future)
- Output: PulseAudio Sound Server
- Sample rate: 48000 Hz
- Audio buffer size: 128 samples (2.7 ms)
- Multicore rendering ON
- CPU Overload detection ON
- Internal sample rate: 48000 Hz
- Max polyphony: Auto (Pessimistic)
Cheers.