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

Reply
 
Thread Tools Display Modes
Old 05-04-2023, 06:15 AM   #1
Alkamist
Human being with feelings
 
Join Date: Dec 2011
Posts: 506
Default Potential bug with how CLAP plugins handle PDC

I've been making a plugin with CLAP that needs to pre-delay midi. The process is to set the required latency with the latency extension, and then grab the input events from the process and change their timing as needed.

I receive the input events ahead of time as expected, but the issue is, if I send them directly they don't go through ahead of time. In order to pre-delay them, I need to integer underflow the time field of the event header (which is a uint32_t). This pre-delays the events, but from this this discussion https://github.com/free-audio/clap/discussions/320 it seems like that might not be proper behavior.

I haven't tested on other DAWs but it seems like REAPER might not be handling event timing with PDC properly. I am on Windows 10.
Alkamist is offline   Reply With Quote
Old 05-04-2023, 07:04 AM   #2
schwa
Administrator
 
schwa's Avatar
 
Join Date: Mar 2007
Location: NY
Posts: 16,248
Default

I am not sure I am understanding the report correctly, but if your plugin has say 1024 samples of latency, and you are passing input MIDI events directly through to output, then that should mean that the output MIDI events will play back 1024 samples before the output audio. However, playback for events that are output by the plugin within the initial 1024 samples is not well defined. Those events might be discarded or delayed, because the plugin has reported that it won't be providing output until 1024 samples of input has been received. In other words, PDC can be used to change relative timing, but not absolute timing.
schwa is offline   Reply With Quote
Old 05-04-2023, 08:14 AM   #3
Alkamist
Human being with feelings
 
Join Date: Dec 2011
Posts: 506
Default

Quote:
Originally Posted by schwa View Post
I am not sure I am understanding the report correctly, but if your plugin has say 1024 samples of latency, and you are passing input MIDI events directly through to output, then that should mean that the output MIDI events will play back 1024 samples before the output audio. However, playback for events that are output by the plugin within the initial 1024 samples is not well defined. Those events might be discarded or delayed, because the plugin has reported that it won't be providing output until 1024 samples of input has been received. In other words, PDC can be used to change relative timing, but not absolute timing.
In my plugin, I am not doing any audio processing, I am only taking midi as input, and then adjusting the timing, and sending it as output.

I guess my confusion is, what procedure should I follow to negatively delay midi?

This is what I expected it would work like: I set the plugin latency to report X samples of latency, I grab events from the input events buffer and pass them immediately to the output events buffer, the events then show up X samples before they were received in the timeline. This is not how it is currently functioning.

How I am achieving what I want currently: I set the plugin latency to report X samples of latency, I grab events from the input events buffer and subtract X samples from the header time, which integer underflows it because it is a uint32_t, and pass them to the output events buffer, the events then show up X samples before they were received in the timeline.
Alkamist is offline   Reply With Quote
Old 05-04-2023, 08:23 AM   #4
schwa
Administrator
 
schwa's Avatar
 
Join Date: Mar 2007
Location: NY
Posts: 16,248
Default

OK, I see. I think the way MIDI is handled for plugins with latency is different between VST and CLAP plugins. We'll look at making this more consistent.
schwa is offline   Reply With Quote
Old 05-04-2023, 09:18 AM   #5
Alkamist
Human being with feelings
 
Join Date: Dec 2011
Posts: 506
Default

Quote:
Originally Posted by schwa View Post
OK, I see. I think the way MIDI is handled for plugins with latency is different between VST and CLAP plugins. We'll look at making this more consistent.
Thank you.
Alkamist 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 06:12 AM.


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