What's the 'delay' in preferences?
delay (msec) is to create the total buffer size. Its important for round trip latency where PD is looping the input to the output - the delay (msec) gets added with the block size (which for compatibility with other patches just keep at 64)
Usually JUCE based programs just give you a "block" of audio, PD is more under the hood about the DSP, the 64 block is a ring buffer that the main patch is at (which is why you have to subpatch to reblock) and the delay msec is padding for the CPU.
Normally you only run into it when you have to up the amount with the sine playing in 'Media, test audio and midi' when you first install PD until it stops sounding scratchy
but also theres another patch in the help browser under 7.stuff/tools/latency you can loop back the output of your audio to the in and play around with lowering it. Either with a loopback function on a dac, or like a wire plugged from out ot line or just have the mic and speakers setup where they could cause feedback if turned up too loud. Tests on the internet for mostly vintage DACS doing round trip latency were actually done in PD.
playing around with it I found Intel macs can go down to 3, and prosumer asio (like an old external edirol dac) can go down to the lowest, 2. Its up to the low level driver to give you the real round trip latency.
usually as long as you can get the sine wave to play in Media.. test audio and midi you are good. Its really only for processing audio in with minimal audible latency - super small delays go off the rails the second you really hit the CPU with polyphony, delay lines, small block sizes.
For a while I had it at as low as it was without being scratchy, but as I got into more complicated (and bloated) synth designs I just kept mine at 50 because when it was having problems more latency than that never helped but less could cause stutters/scratchy sounds.
Linux and Windows are usually set by default to 50 or 100 tho I dont have a problem above 23, offhand I think intel macs were set to 5 or 10. the new arm macs can run into a problem where the old default was too small and should have it higher as well. So the real winners were old intel macs.
use callbacks is only for some older audio drivers in linux
is Pd ok on macOS 15?
I have been using Pd with macOS 13 on my M1 MacBook Pro for a while without any issues, but I think my employer will likely be forcing me to "upgrade" to macOS 15 soon.
I seem to remember there being some issues with a macOS update at some point relatively recently, though this was maybe about macOS 14...I just wanted to ask very broadly whether anyone has had any issues with Pd on macOS 15?
plugdata latency and REAPER's plugin delay compensation (PDC)
@ddw_music Oh OK, well I redid the test using a 1033.6 Hz sine wave (1.5 cycles/64 sample block) and the result is consistent with a 64 sample shift (i.e. 180 degrees out of phase), plus it goes away when I set plugdata's latency to 0. I'm gonna check on the REAPER forum to see what they say about PDC--maybe the issue is that REAPER assumes a base 64 sample latency for all plugins so plugdata doesn't need to report that portion.
It would still be interesting to see if other DAWs behave similarly. Maybe I have to dig out my old laptop and struggle with Cubase again. 1033.6 Hz sine.wav
BTW, is there a way to set plugdata's reported latency to the host programmatically? I have an FFT resynthesis patch that uses different block sizes. Camomile has that facility.
Update: I think I'm seeing the same behavior in Audacity, but my understanding of Audacity is weak. I also tested an FFT resynthesis patch in REAPER using a 16384 block size and set plugdata's latency to 16320 (16384 - 64) ; that produced the alignment I was expecting. So I'm provisionally declaring that you should set plugdata's latency to the latency of your patch as measured between adc~ and dac~. In retrospect that seems completely obvious, but I was thrown by plugdata's default of 64.
gain~ latency (else library)
0 samples
Using same technique as @katjav 's latency-meter, which was 1 sample off, here is a fixed version:
https://forum.pdpatchrepo.info/topic/13814/catch-would-like-to-set-the-name-programmatically/20
And there is a latency-tester in PD's doc:
07.stuff/tools/latency.pd
As long as there is no windowing, reblocking or delay line involved, objects usually have no latency.
Where does latency come from in Pure Data?
TL;DR:
"Blocksize": hardware buffer size
"Delay": extra latency
Then, in the Pd audiosettings, you set the "Delay (msecs)". This sets the size of the buffer between Pd and the soundcard.
This is not true. (I don't blame anyone for making this mistake, as this is not obvious unless you know the Pd internals.)
By default, Pd uses the so-called "polling scheduler". The message system and DSP run in a dedicated thread which communicates with the actual audio callback via a (lock-free) ring buffer. "Delay" effectively controls the size of that buffer. It adds extra latency on top of the hardware buffer size.
The actual hardware buffer size is always controlled by the - confusingly named - "Blocksize" parameter. (Pd's internal blocksize is fixed at 64 samples.)
Alternatively, Pd may use the so-called "callback scheduler", which is enabled by the "Callbacks" option in the audio settings. In this case, the message system and DSP run directly in the audio callback and latency is only affected by "Blocksize". (This option has disappeared in Pd 0.54, but will likely reappear in the future after some scheduler bugfixes have been applied. See https://github.com/pure-data/pure-data/pull/1756.)
Tip: If you run Pd with the default "polling scheduler", then you should set "Blocksize" as low as possible and control latency with the "Delay", as it offers finer granularity.
Having issues with audio preferences and PD freezing up
Maybe 0.52-1 was running using Rosetta2 which is emulating Intel. A compiled external has to be for both the operating system and underlying architecture. Intel mac is x64, and M1/M2 is arm64/aarch64.
you can go look at these https://deken.puredata.info/ - you need ones that say 'Darwin-amd64-32' to run built for M1/M2 Macs .. But lets see the mac lore is they let you keep Rosetta for two versions of Mac OS, so for now you can stick with Rosetta2 (and that means install the Intel Mac version of PD and emulate it, at some point they will release like 13.3 or whatever theyre at (I'm still using mojave) and take it away but hopefully by then the externals you need will be compiled (or you can compile them yourself), otherwise stick with Big Sur or whatever you are on to keep Rosetta2 - I really haven't been paying attention.
Camomile VST3-generated CC messages altered on Mac M2
don't feel like you need to let it go -- but think about how to prove this - m2, m1 whatever is aarch64 - everything was recompiled nothing was the same - latency in coreaudio is not low anymore like it was with intel macs helping a lot of people in pd vanilla cant get audio working and fix it to up their delay msec. It's not an intel mac anymore and for example a lot of compiled externals dont work because they need to be compiled for OS+arch. (mac is d-arwin, windows is ms-icrosoft, linux is l)
its not a mac like you think it is, intel mac was a combination of x64_86 processor that said any 32 bit (86) was banned and couldnt run after mojave even tho it can - and openDarwin at the lowest level.
camomile uses libpd and is frozen in an older version of PD right now - the dev for it, going to college, life is too busy to poke this bear - personally I get it - puttin somthing out for free - honestly I dont understand how it even works without being recompiled for darwin aarch64 (even then it would be for like PD 0.50 because the dev is busy with a normal life) -
your best bet is to try and switch to plugdata because it started with camomile but is super up to date - runs as a VST, you can complain and it gets fixed and you can redownload the nightly (which is the most current stable/dev version with all the new fixes) and does all sorts of magic tricks imo
Where does latency come from in Pure Data?
The amount of input-->output latency comes from the soundcard driver settings, specifically, the hardware buffer size.
"Where does latency come from" is this:
The audio card driver processes blocks of audio. (If it didn't process blocks of audio, then it would have to call into audio apps once per sample. There is no general purpose computer that can handle 40000+ interrupts per second with reliable timing. The only choice is to clump the samples into blocks so that you can do e.g. a few dozen or hundred interrupts per second.)
Audio apps can't start processing a block of input until the entire block is received. Obviously this is at the end of the block's time window. You can't provide audio samples at the beginning of a block for audio which hasn't happened yet.
You can't hear a block of output until it's processed and sent to the driver.
| --- block 1 --- | --- block 2 --- |
| input.......... | |
| \| |
| \_output......... |
This is true for all audio apps: it isn't a Pd problem. Also Pd's block size cannot reduce latency below the soundcard's latency.
You can't completely get rid of latency, but with system tuning, you can get the hardware buffer down to 5 or 6 ms (sometimes even 2 or 3), which is a/ good enough and b/ as good as it's going to get, on current computers.
hjh
Round trip latency tests
yes, Katja's meter measures 1 sample latency additionally, so real latency is -1 sample.
here are threads of other forums:
https://forum.rme-audio.de/viewtopic.php?id=23459
linking to
https://web.archive.org/web/20160315074034/https://www.presonus.com/community/Learn/The-Truth-About-Digital-Audio-Latency
and an older comparision:
parts 1 2 3:
https://original.dawbench.com/audio-int-lowlatency.htm
Round trip latency tests
the patch looks legit:
in Real Life latency occurs in every part: converter, port, driver / os, pd.
Linux can be set up to be very responsive on audio with realtime-priority ect. (how can this be done in Win?)
USB(1 and 2) introduces 1 or 2 ms of fixed latency.
RME pci(e) cards are the fastest hardware and drivers you can get (Linux too). Marian could be sameish (no Linux, last time I asked).
Today there are USB3 / Thunderbold, too - but don't know about their latency.
If you have headroom, 96k should be faster.
Because of the complexity of the chain, I would be surprised if latency would be same anytime, or to put it differently:
If the patch relies on it, I'd do the measurement each time on startup (with a free io channel or switching patchbay), even more in a live-concert. But empiricism on your system could disprove it, - and now I realize that this actually is your question, but no, I can not share experience on reliability of latency in Windows.
@jameslo which post of katjav are you referring to?
Recurrently there has been some conversation about latency on the pd-list.