free-audio / clap

Audio Plugin API
https://cleveraudio.org/
MIT License
1.81k stars 103 forks source link

Strange distortion when automating CLAP plug-in parameters in DAW? #324

Open lewloiwc opened 1 year ago

lewloiwc commented 1 year ago

https://github.com/baconpaul/clap-c99-distortion https://nakst.gitlab.io/tutorial/clap-part-2.html I tried both of these in Bitwig and they behaved as I expected with direct mouse modification of parameters and modulation by modulation, but with automation I got this strange distortion. image

When I test the CLAP plugin in REAPER, it looks ok at first glance, but the automation in the moment of playback part does not seem to be working. image

Is the code for these two CLAP plugins written correctly? Or is the problem with your DAW such as Bitwig or REAPER?

What I'm imagining: -The code in the two Clap plugins is fine -Bitwig's CLAP plugin automation is buggy -REAPER's CLAP plugin has a bug where the automation of the part at the moment of playback does not work.

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

lewloiwc commented 1 year ago

I feel certain that there is at least a bug in Bitwig.

Purple is the value of the parameter and green is the number of times CLAP_EVENT_PARAM_VALUE was called. The manual operation was successfully called only once for BUFFER SIZE. image

Modulation was also successfully called every 128 samples in buffer size. image

However, automation calls every 128 samples in the first buffer, then calls only once in buffer size, and after a while it calls every 128 samples again. The parameter values are also unstable. image

What do you think?

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

lewloiwc commented 1 year ago

https://github.com/free-audio/interop-tracker/issues I just found this just now. I should probably post these issues over there, right? Can I move the issues? Or should I close the issue and repost it over there?

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

baconpaul commented 1 year ago

it probably does belong in the inter-op tracker yes. which version of bitwig and which OS would also help I am sure Does surge exhibit the same behavior? That's different code than the c99 distortion. But I looked at the c99 distortion and i looks alright (albeit a bit convoluted) in how it processes events. I would not rule out a bug there though.

lewloiwc commented 1 year ago

Windows 10 Home Bitwig Studio 4.4.10 Sample Rate: 96000 Hz / Buffer Size: 1024 Samples Surge XT 1.2.3.bb8dd2b

Also, when I was trying to check the Surge XT version, I noticed that you set the buffer size to 1024 samples, but Surge XT recognizes it as 32 samples, isn't that strange? image image

I checked Surge XT and found that this also had the same distortion when using automation. image

Modulation is still fine, but I am concerned that Surge XT is doing linear interpolation with 32 samples, probably because it recognizes the buffer size as 32 samples. image

mkruselj commented 1 year ago

but I am concerned that Surge XT is doing linear interpolation with 32 samples, probably because it recognizes the buffer size as 32

This is by design of Surge and expected, though. Internal DSP processing of Surge is running in 32 sample sized blocks. This has nothing to do with your audio driver buffer size, it's an internal processing buffer.

baconpaul commented 1 year ago

That’s correct. Production surge has an internal block of 32 and uses the sample time of events to interneave with profess calls appropriately no matter the parent block size

how are you making these charts?

lewloiwc commented 1 year ago

I didn't know Surge was designed that way! Thanks for letting me know!

The chart is made by setting the Surge XT oscillator to a high frequency sine wave, automating A Osc 1 Level, and viewing the output audio on a ReaJS oscilloscope. bwproject→https://drive.google.com/file/d/1-h8Zp8qPrFfLElhi75cgqB6ZvDhK7Q-W/view?usp=sharing

I also asked Bitwig Support and they said "We are not aware of a problem with commercially released CLAP plug-ins, I checked u-he MFM2, a commercially released CLAP plug-ins, and found the same distortion.

First, output an audio file with this setup. Windows 10 Home Bitwig Studio 4.4.10 Sample Rate: 96000 Hz / Buffer Size: 1024 Samples MFM2 2.5 (revision 13385) (CLAP) image bwproject→https://drive.google.com/file/d/1-ZLAaBPHRIkGOXoF44fjfQpnjtPzk0qU/view?usp=sharing

Next, check the output audio file with an oscilloscope. The shape now looks smooth and problem-free, but that is because MFM2 has smoothed the values with a 1-pole low-pass filter. image

This audio file is then used to calculate the curvature using the following calculation. B = A; A = input; output = A - B; image

If you zoom in on this, it will look like this image

Isn't this exactly the same distortion as this one? The shape of the distortion and the timing of the distortion are also the same? image

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