Topic: Slightly bigger latency on Linux

Hi guys,

I have recently noticed that Pianoteq 5 on Linux has slightly bigger latency than on Windows.
Both of the OS are installed on the same hardware(using onboard soundcard) and detailed condition was below.

Linux (tick=1000HZ, turned off dynamic tick, Changed Pinoteq 5 process's schedule policy to SCHED_FIFO with priority 90):
output = alsa hw:0 (which provides direct memory accessing to the sound card, so should be the best way to reduce the latency)
Sample rate = 44100 Hz
Audio buffer size = 512 samples (11.6 ms)

Windows 7:
output = ASIO4ALL v2
Sample rate = 44100 Hz
Audio buffer size = 512 samples (11.6 ms)

I compared the latency by connecting my Casio keyboard to the PC using USB interface and listening the sound coming from the PC and the keyboard's internal sound at the same time.
The result was that the sound on Windows was like there was one sound source coming from both speaker. But, on Linux it sounded like there was an echo effect because of the latency.
I haven't tried rt Linux kernel, as I thought it wouldn't give much difference.

I am not sure whether I am the only one who is having this issue and I am just curious whether the difference comes from Pianoteq Linux binary itself due to the compiler difference or comes from others such as USB midi driver or alsa direct access API.

Last edited by geneven (08-04-2015 06:10)

Re: Slightly bigger latency on Linux

Hello,

First,
If you want to use Pianoteq on Linux, I strongly suggest you to use (or to try from a live CD) a music dedicated distribution (Tango Studio, KX Studio, Ubuntu Studio...). From a standard distributions there will be too much things to tweak to have a good result.

Second,
I am not sure but I think the samples are considered differently on Linux and on Windows. For example, 128 samples on Linux gives me the same sensation than 256 samples on Windows. I am not sure but I think on Windows the sample value is "in/out" while on Linux it is only one way... or something like that...

Re: Slightly bigger latency on Linux

Good catch geneven, Pianoteq currently uses 4 periods (quad-buffering) with its ALSA backend -- it also explains the feeling of stamkorg. This is overkill, and we used to use a lower number of periods, I'm not sure when that change was introduced, but we will revert that in the next version.

Re: Slightly bigger latency on Linux

Thanks Julien for the kind reply.

I am a big fan of Linux and also a software developer who has been involved in developing real-time software using RT linux to control a robot system. So, I was curious about the reason of the latency difference between Windows and Linux.
I will look forward to the fix.

Re: Slightly bigger latency on Linux

furthermore i would recommend using JACK over ALSA, and make sure your account has rt-access. another thing i found out is, that you should set the CPU frequency to the max gives better performance than  scaling "ondemand".