jackaudio / jack2

jack2 codebase
GNU General Public License v2.0
2.19k stars 374 forks source link

Does alsa backend really need frames per period to be a power of two? #494

Open crocket opened 5 years ago

crocket commented 5 years ago

According to alsa backend section of man jackd, frames per period must be a power of two.

According to my direct experience, it doesn't need to be.

The following setup seems to work just fine with CONFIG_PREEMPT_RT_FULL.

It even withstands nice -n 19 stress-ng --iomix 8 --ionice-class idle --cpu 8 -t 5m without xruns.

On Raspberry Pi 3 B+

jackd -P 90 -d alsa -d speakers -p 192 -n 2 -P -r 48000
jack_netsource -H desktop_ip_address -o 0 -i 2 -O 0 -I 0 -n 2 -N guardian -m 1500

On my desktop computer

jackd -P 90 -d netone -n 2
# zita-a2j and zita-j2a work on a USB soundcard called
# Creative Sound Blaster X-Fi HD
zita-a2j -j from_alsa -d spdif_in -p 96 -n 2 -r 48000
zita-j2a -j headphones -d xfihd_hdp -p 96 -n 2 -r 48000
jackminimix -c 2 -p 20255 -n soft-vol
falkTX commented 5 years ago

it does not need to be, documentation is wrong.

crocket commented 5 years ago

@falkTX What about settings for USB soundcards? Does X-Fi HD have no problem with 2 periods per buffer? If -r is 48000, does -p need to be a multiple of 48 when -n is 2? I read that USB devices like multiples of 1ms for either period size or buffer size.

trebmuh commented 5 years ago

it does not need to be, documentation is wrong.

Should we change the man page then? Just removing the This value must be a power of 2, or relaxing it to something along You are encouraged to use a power of 2 for this value but it should work with any other value?

crocket commented 5 years ago

https://wiki.linuxaudio.org/wiki/list_of_jack_frame_period_settings_ideal_for_usb_interface

NOTE: quite a few pieces of software and plug-ins expect frames that are a power of 2 (like guitarix). You might get weird errors when using frame numbers that are not a power of 2 or the plug-in/software may not even start at all.

https://linuxmusicians.com/viewtopic.php?t=10707

A small caveat when using Guitarix

Many of the effects and amp simulators in Guitarix depend on a library which expects your frames/period to be a power of two (16, 32, 64, 128, etc), and large parts of Guitarix fail to work properly if this is not the case. This can easily be resolved by choosing periods=3, which enables most of the “conventional” 2^n frames/period values. In fact, if you choose periods=2, it will be impossible to get Guitarix to work properly while also having a latency which is an integral number of ms.

Some softwares have problems with period sizes that are not powers of two. However, I've worked with such period sizes as 48, 64, 80, 96, 160, and 192 without problems.