Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER for Linux

Reply
 
Thread Tools Display Modes
Old 05-22-2021, 10:58 AM   #1
timothys_monster
Human being with feelings
 
timothys_monster's Avatar
 
Join Date: Jan 2012
Location: Germany
Posts: 1,130
Default What does the "periods" option in the preferences stand for?

I was wondering how it affects the overall performance but more importantly, RT performance and latency. I guess it's an ALSA thing, since under ASIO on Windows it doesn't even exist... Would someone like to explain or point in a direction for further reading, please?
timothys_monster is offline   Reply With Quote
Old 05-22-2021, 11:58 AM   #2
Glennbo
Human being with feelings
 
Glennbo's Avatar
 
Join Date: Mar 2008
Location: Planet Earth
Posts: 9,055
Default

Quote:
Originally Posted by timothys_monster View Post
I was wondering how it affects the overall performance but more importantly, RT performance and latency. I guess it's an ALSA thing, since under ASIO on Windows it doesn't even exist... Would someone like to explain or point in a direction for further reading, please?
Actually it does exist in Windows, but you can't change it in that OS AFAIK. Setting 2 periods Double Buffers whatever blocksize you've set. Setting it to 3 Triple Buffers, which with my interfaces, both M-Audio cards I used to use and my current USB audio device, matches what I saw in Windows.

IOW if I select 2 periods @ 64 samples I see 1.3/1.3ms, but in Windows I would see 1.3/2.6ms which matches what I see in Linux when I select 3 periods @64 samples.
__________________
Glennbo
Hear My Music - Click Me!!!
--
Glennbo is offline   Reply With Quote
Old 05-22-2021, 12:30 PM   #3
JamesPeters
Human being with feelings
 
Join Date: Aug 2011
Location: Near a big lake
Posts: 3,943
Default

If you're wondering what the number of periods (aka blocks) of samples you are (or were) using in Windows or OSX, you can work backwards from the Reaper reported latency of the audio device.

My latency shown in Reaper is 1.4/4.3 ms (input/output latency). That's 5.7 ms total "round trip" latency, at my samplerate setting of 44100 Hz (samples/second).

.0057 * 44100 = 251.37 samples

My blocksize is 64 samples. So 251.37 / 64 = 3.927

It seems the latency reading reported in Reaper was rounded down, because I'm using 4 blocks of 64 samples.

You can do this with ASIO, WASAPI, etc. to figure out the number of blocks/periods.

This is why when someone says they're using a "64-sample buffer", they're *not* using a 64-sample buffer. Depending on the driver, you could be using 3 blocks of 64 (4.4 ms round-trip latency) or 5 blocks of 64 (7.3 ms round-trip latency), and so on. So the blocksize only tells part of the story, one factor. You can potentially use a larger blocksize for which the ASIO driver specifies fewer blocks/periods than when switching to a lower blocksize, meaning your latency can be equal (or even less) in that case.

Then there's an "overhead" of sorts for the system you're using. A USB device in ALSA for instance will require a bit more of a buffer than a well-designed ASIO driver in Windows (RME comes to mind). But a PCIe device in ALSA doesn't require that much of a buffer (on my system for instance it's 12 samples total). Here's a way to determine your actual device latency, and how to compensate for it appropriately:

https://www.youtube.com/watch?v=TzS--D765Zw

In Jon's example he's using 48000 Hz samplerate, 128 samples blocksize, and the reported latency is 509 samples.

509 / 128 = 3.98 blocks (so the driver is using 4 blocks/periods)

He then has to compensate another 65 samples after doing the test (for the overhead of the audio system he's using).

His driver was reporting 10.6 ms round-trip latency, but it was actually 12 ms round-trip latency, for that setting of "128" (which has 4 periods/blocks, plus the overhead of the driver system for the device).

If you try this ReaInsert test with a USB device in ALSA and the number keeps changing: you're not insane. If you let ALSA be released when playback is stopped in any way, then when ALSA "engages" again, that "hidden buffer" of ALSA may be a slightly different value the next time. It's not worth worrying about though, since it's probably only going to be around 10 samples difference (1/5 of a ms). Apparently that's normal for any USB-based class-compliant driver. Manufacturer-specific ASIO drivers for a USB device, or just using a PCIe device (with ASIO, WASAPI, ALSA, etc.) probably won't show this behavior.

All this means most people who say they're using a "X-sample buffer" or getting "Y ms latency" probably don't know the real X or Y values; the numbers are higher. On my system in ALSA with a Focusrite 2i2, I can use it at 8 ms round-trip (measured, total) latency realistically speaking (good for even high-CPU projects). With a PCIe device I can use it at around 6 ms round-trip (measured, total).

And if someone is using ASIO4ALL, well...the number they get from ASIO4ALL's reported latency is only the portion of latency that ASIO4ALL reports (it doesn't count the buffer for the WASAPI driver it's using, or the system overhead). You've probably heard people claim they're getting 2 ms latency with ASIO4ALL, for instance. That's definitely not true. I doubt that anyone is getting an actual latency of 2 ms with any degree of reliable performance for their DAW's audio system, and 100% definitely not with ASIO4ALL.

I imagine some combinations of blocksize/periods work better than others, and that's why that "periods" (blocks) number is "preset" for a given blocksize in an ASIO driver in Windows. Or for Coreaudio in OSX for that matter. So just because we have the ability in ALSA to choose the number of periods/blocks, that doesn't mean we can necessarily get away with lower latency than in Windows or OSX if we also want stable performance.

Last edited by JamesPeters; 05-22-2021 at 12:56 PM.
JamesPeters is offline   Reply With Quote
Old 05-23-2021, 02:26 PM   #4
timothys_monster
Human being with feelings
 
timothys_monster's Avatar
 
Join Date: Jan 2012
Location: Germany
Posts: 1,130
Default

Wow, what an elaborate answer. Thanks to both of you, guys! Now I get it and will investigate further on the perfect balance of samples and periods for my audio interface.

Cheers!
timothys_monster is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 05:30 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.