View Issue Details

IDProjectCategoryView StatusLast Update
0009619ardourbugspublic2024-01-25 17:37
Reporterbonsembiante Assigned To 
PrioritylowSeveritytweakReproducibilityalways
Status newResolutionopen 
PlatformUbuntuOSLinuxOS Version(any)
Product Version8.2 
Summary0009619: VST3 non-optimal calls to plugin methods worsen DSP performance
DescriptionTesting different setups to achieve low latency audio processing on Linux with Windows VST plugins (using yabridge), I discovered a significant difference between Reaper and Ardour performance when changing VST3 parameters. Both programs works well when I don't change any plugin parameter, but in Ardour when I make continuous and sudden changes of a parameter, lets say Master Volume knob in the plugin GUI, audio starts to sounds full of missing samples (a lot of jitter, multiples xruns). Also DSP load meter goes through 100%. When I stop moving the parameter, everything goes stable again. It is important to say that this problem is audible when I use a very low buffer size (32 samples for buffer and 44.1 kHz of sampling freq.). I did the tests with same OS.

Intrigued with that performance difference between Reaper and Ardour, I did some debug with Yabridge option to log method calls. I found that Ardour make many calls (between 7 or 8) to some methods for each plugin "performEdit" call to host, as opposed to Reaper that only makes 1 call after each "performEdit". I cloned Ardour repo, and commented two lines on libs/ardour/vst3_plugin.cc -> VST3PI::performEdit method: the call to normalizedParamToPlain and to OnParameterChange. This, of course, left me with no parameter synchronization inside Ardour state but also with no method calls after each "performEdit" call from plugin and also removed the jitter problem (and DSP load stop to increase on each parameter continuous and sudden change).

I have been a software developer for several years and I'm really available to make the necessary changes in Ardour code to fix this issue, but as it is my first time getting into Ardour code I thought that It would be important to share my analysis here so we can get the best approach for it.
Additional InformationIn order to evidence the issue, I did a bunch of tests using:

Ardour version: 8.2.85 (dbg) master version (latest commit cefab85dabcbee7ede26808a880b0265e5817472)
OS: Ubuntu 22.04
Audio device: Onboard, 2 periods, 1024 samples @ 48kHz [image attached: audio_device_config.png]
Yabridge version: 5.1.0
Wine version: 9.0 (Staging)
VST3 Plugin: Warmy EP1A v2 (Windows binary) [image attached: warmy_screenshot.png]

I ran ardev with environment variable YABRIDGE_DEBUG_LEVEL=1,+editor so a got yabridge debug info in stderr with plugin <-> host method calls.
I created only one Audio track and attached a instance of the VST plugin. Later, I prepared the stderr and then clicked in reset button of DSP meter. Almost inmediatly after that I moved the "Boost knob" of the plugin GUI from 0 to 10 and again to 0, moderately fast and in a continuous way. Then I took a screenshot of DPS meter and copied the Yabridge logs where "performEdit" and other method calls were displayed in that window of time when I make the knob movement. The results are the following.

No modified version of Ardour:
Minimum: 0.39 [ms]
Maximum: 5.2 [ms]
Average: 1.362 [ms]
Std.Dev: 0.392 [ms]
[image attached: 20240124_22-21_ardour-dbg-8.2.85_master_warmy_dsp-load.png]
Methods calls: https://pastebin.com/kr7prmwH

Modified version of Ardour (with that two lines commented):
Minimum: 0.49 [ms]
Maximum: 2.12 [ms]
Average: 1.261 [ms]
Std.Dev: 0.2 [ms]
[image attached: 20240124_22-35_ardour-dbg-8.2.85_modded_warmy_dsp-load.png]
Methods calls: https://pastebin.com/6GKdDC5D
Tagslatency, performance, VST3

Activities

bonsembiante

2024-01-25 04:21

reporter  

audio_device_config.png (32,905 bytes)   
audio_device_config.png (32,905 bytes)   
warmy_screenshot.png (300,045 bytes)

bonsembiante

2024-01-25 04:25

reporter   ~0028472

I will try to make a PR in Github with some code changes for a possible solution but any comments or guidelines that might be helpful for that are welcome.

x42

2024-01-25 04:33

administrator   ~0028473

Can you check that when you use automation, rather than manual changes, this is not an issue?

x42

2024-01-25 04:44

administrator   ~0028474

That is an interesting find. It'd be great to track down where those duplicate calls originate from.

bonsembiante

2024-01-25 05:22

reporter   ~0028475

Hi x42, thanks for replying.
I just did the test with the automation thing and yes, is an issue, it has the same behavior.
Also, I forgot to mention that the issue is not present only when using plugin internal GUI but also when using Ardour inline controls for a plugin parameter, but in this case the methods called between host and plugin have not the exact same sequence.

I did a dirty stack trace analysis for each plugin method call from ardour when a parameter is changed, maybe I could do it better so we can understand which core method or something like that is responsible of each plugin method call.

First of all, there are plenty calls to "normalizedParamToPlain" for the same value, so maybe a possible solution could be a kind of mapping where to store the plain value if we already have it. If not, we do the call, but only one time.

x42

2024-01-25 17:37

administrator   ~0028476

So the issue here is that various UI elements in Ardour request parameter conversion (interface_to_internal, internal_to_interface) ?

normalizedParamToPlain is usually cheap, some basic math, at most a few CPU instructions.
Except with yabridge, there is a context switch, which can introduce significant overheard.

Issue History

Date Modified Username Field Change
2024-01-25 04:21 bonsembiante New Issue
2024-01-25 04:21 bonsembiante File Added: 20240124_22-21_ardour-dbg-8.2.85_master_warmy_dsp-load.png
2024-01-25 04:21 bonsembiante File Added: 20240124_22-35_ardour-dbg-8.2.85_modded_warmy_dsp-load.png
2024-01-25 04:21 bonsembiante File Added: audio_device_config.png
2024-01-25 04:21 bonsembiante File Added: warmy_screenshot.png
2024-01-25 04:25 bonsembiante Note Added: 0028472
2024-01-25 04:27 bonsembiante Tag Attached: VST3
2024-01-25 04:27 bonsembiante Tag Attached: performance
2024-01-25 04:27 bonsembiante Tag Attached: latency
2024-01-25 04:33 x42 Note Added: 0028473
2024-01-25 04:44 x42 Note Added: 0028474
2024-01-25 05:22 bonsembiante Note Added: 0028475
2024-01-25 17:37 x42 Note Added: 0028476