[Solved] If the PDC of FX oversampled by x times is not a multiple of x, the output i
If the PDC of an oversampled FX by x times is not a multiple of x, the output is delayed by (PDC%x/x) spls.
To be precise, when the oversampling of REAPER is 4x, PDC from 0 to 3 is actually 0, from 4 to 7 is actually 4, and from 40 to 43 is actually 40, so I think the cause is that the delay is shifted from the delay expected by the plug-in.
If this is used with 2x oversampling, the output should be 0.5 samples earlier, and if used with 4x oversampling, the output should be 0.25 samples earlier.
TL;DR: PDC is applied at the non-oversampled level, so yes, the output can be delayed by fractional samples.
The way the latency compensation works with oversampling is that the total latency of the chain is calculated:
1) Upsampling latency, in units of upsampled samplerate
2) FX latency at upsampled samplerate
3) The above values are summed and then converted back to the non-upsampled samplerate, via truncation.
4) The downsampling latency is added (in normal samplerate)
5) The total latency is compensated
If you set the FX chain's PDC mode to "per-FX (classic REAPER 1.0-6.19)", does that affect things? (I'd have to go dig into the code to see if it does, but it's time for bed.)
I suppose the fix for this would be to add additional latency to keep things whole-non-oversampled-sample-aligned. I'll think about that some.
Want to post your test project so we can play with it?
However, I ran into another problem during the verification.
Probably something went wrong from the first time I changed the Chain PDC mode.
I write this example in the hope that this is not a bug that only I can reproduce...
The first half of the video shows the current "per-chain compensation" behavior, but once the playback button is pressed and the PDC is changed in JSFX, the REAPER freezes in this video.
In this video, I have successfully changed the PDC, but it behaves like "per-FX (classic REAPER 1.0-6.19)" even though the Chain PDC mode is "per-chain compensation", and when I try to close the project REAPER crashes when I try to close the project.
REAPER crashes on "open project -> press play button -> change PDC -> close project".
I forgot to mention that I was verifying with samplerate: 96000 Hz and Buffer size: 1024 samples.
Also, I found a way to reliably crash REAPER from a new project using _mini_crush.jsfx.
samplerate: 96000 Hz | Buffer size: 1024 samples.
1: Load _mini_crush.jsfx
2: Set Chain oversampling to Oversample up to 705.6k/768k
3: Set Chain PDC Mode to Per-FX compensation (classic REAPER 1.0-6.19)
4: Set PDC to 1 in _mini_crush.jsfx
5: Press play button
6: Close the project
This method does not crash when Oversample up to 176.4k/192k, but crashes when Oversample up to 352.8k/384k and Oversample up to 705.6k/768k. (samplerate: 96000 Hz | Buffer size: 1024 samples)
As additional information, I restarted windows and it was still broken.