Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Bug Reports

Reply
 
Thread Tools
Old 04-05-2023, 06:40 AM   #1
lewloiwc
Human being with feelings
 
Join Date: Aug 2021
Posts: 136
Default [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.

In my estimation if the exact implementation,
Code:
@init
pdc_delay = 1;
pdc_bot_ch = 0;
pdc_top_ch = 2;
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.

Here is the JSFX used for verification
Code:
desc:_x_pdc_and_x_delay

slider1:x_slider=0<0,30,1>x



@init //----------------------------------------------------------------

ext_nodenorm = 1;

function delay(x0,x1,mem,delay)
(
    delay <= 0 ? (
        this.0 = x0;
        this.1 = x1;
    ) : (
        this.0 = mem[this.cnt];
        this.1 = mem[this.cnt + 1];
        
        mem[this.cnt] = x0;
        mem[this.cnt + 1] = x1;
        
        this.cnt < delay*2 - 2 ? (
            this.cnt += 2;
        ) : (
            this.cnt = 0;
        );
    );
);



@slider //----------------------------------------------------------------

pdc_delay = x_slider;
pdc_bot_ch = 0;
pdc_top_ch = 2;



@sample //----------------------------------------------------------------

delay.delay(spl0,spl1,0,x_slider);

spl0 = delay.0;
spl1 = delay.1;
Code:
desc:_pdc_and_delay

slider1:pdc_slider=0<0,30,1>PDC
slider2:delay_slider=0<0,30,1>Delay



@init //----------------------------------------------------------------

ext_nodenorm = 1;

function delay(x0,x1,mem,delay)
(
    delay <= 0 ? (
        this.0 = x0;
        this.1 = x1;
    ) : (
        this.0 = mem[this.cnt];
        this.1 = mem[this.cnt + 1];
        
        mem[this.cnt] = x0;
        mem[this.cnt + 1] = x1;
        
        this.cnt < delay*2 - 2 ? (
            this.cnt += 2;
        ) : (
            this.cnt = 0;
        );
    );
);



@slider //----------------------------------------------------------------

pdc_delay = pdc_slider;
pdc_bot_ch = 0;
pdc_top_ch = 2;



@sample //----------------------------------------------------------------

delay.delay(spl0,spl1,0,delay_slider);

spl0 = delay.0;
spl1 = delay.1;
Windows 10 Home | REAPER v6.78+dev0404/win64

Translated with www.DeepL.com/Translator (free version)

Last edited by lewloiwc; 04-10-2023 at 12:42 PM. Reason: [Solved]
lewloiwc is offline   Reply With Quote
Old 04-05-2023, 08:44 PM   #2
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 16,223
Default

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?

Last edited by Justin; 04-05-2023 at 08:51 PM.
Justin is offline   Reply With Quote
Old 04-06-2023, 01:20 AM   #3
lewloiwc
Human being with feelings
 
Join Date: Aug 2021
Posts: 136
Default

"per-FX (classic REAPER 1.0-6.19)" is working as I am looking for!

The first half is "per-chain compensation" and the second half is "per-FX (classic REAPER 1.0-6.19).

Download links for project files and effects.
https://drive.google.com/file/d/1-7d...ew?usp=sharing

--------------------------------

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".



https://drive.google.com/file/d/1-GR...ew?usp=sharing
This project file may crash REAPER just by opening it.


REAPER crashed when I opened the project file.


Perhaps "REAPER - Previously failed while loading project" would allow it to load? But when I close the project, REAPER crashes.

JSFX code used
Code:
desc:_mini_crush

slider1:pdc_slider=0<0,30,1>PDC

@slider

pdc_delay = pdc_slider;
pdc_bot_ch = 0;
pdc_top_ch = 2;
--------------------------------

Windows 10 Home | REAPER v6.78+dev0404/win64

Translated with www.DeepL.com/Translator (free version)
lewloiwc is offline   Reply With Quote
Old 04-06-2023, 01:59 AM   #4
lewloiwc
Human being with feelings
 
Join Date: Aug 2021
Posts: 136
Default

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.

Windows 10 Home | REAPER v6.78+dev0404/win64

Translated with www.DeepL.com/Translator (free version)

Last edited by lewloiwc; 04-06-2023 at 02:10 AM. Reason: Additional information and things that need to be written
lewloiwc is offline   Reply With Quote
Old 04-06-2023, 05:58 AM   #5
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 16,223
Default

thanks, looking into all of these!
Justin is offline   Reply With Quote
Old 04-06-2023, 10:23 AM   #6
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 16,223
Default

OK, I think all of the above issues should be fixed in the next +dev build, thanks for the reports!
Justin is offline   Reply With Quote
Old 04-06-2023, 12:06 PM   #7
lewloiwc
Human being with feelings
 
Join Date: Aug 2021
Posts: 136
Default

Thank you very much!

Translated with www.DeepL.com/Translator (free version)
lewloiwc is offline   Reply With Quote
Reply

Thread Tools

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 11:25 AM.


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