spotify / pedalboard

🎛 🔊 A Python library for audio.
https://spotify.github.io/pedalboard
GNU General Public License v3.0
5.11k stars 261 forks source link

Estimating Plugin Delay Compensation for VST3 Plugins #364

Closed yogeshpatki closed 1 month ago

yogeshpatki commented 1 month ago

Hi Team,

Want to preface this with: I am having a great time working with pedalboard so far.

I was wondering if there is a way to estimate Plugin Delay Compensation required when processing an audio through a VST3 Plugin? I am trying my hands at SoundTheory Gullfoss plugin, and the outputs I get when I pass any audio through pedalboard are delayed.

Per https://github.com/spotify/pedalboard/issues/230, Pedalboard is already accounting for plugin latency, but seems the plugin in question here does not report it. could you help me with a probable way of calculating the delay on the fly?

psobot commented 1 month ago

Hi @yogeshpatki!

This is a good question, but I'm not sure how best to answer it; I've downloaded a copy of Gullfoss and found that it reports its internal latency as 1,086 samples and Pedalboard does seem to properly adjust for it:

>>> import pedalboard
>>> p = pedalboard.VST3Plugin('/Library/Audio/Plug-Ins/VST3/Gullfoss Master.vst3')
>>> import numpy as np
>>> a = np.random.rand(44100, 2)
>>> a
array([[0.27086453, 0.31185174],
       [0.38092903, 0.07349355],
       [0.08006173, 0.74833794],
       ...,
       [0.58176284, 0.66194127],
       [0.1371319 , 0.27932754],
       [0.34133687, 0.15247069]])
>>> p
<pedalboard.VST3Plugin "Gullfoss Master" at 0x15b8065d8>
>>> p(a, 44100)
array([[0.27086452, 0.31185174],
       [0.38092902, 0.07349355],
       [0.08006173, 0.7483379 ],
       ...,
       [0.58176285, 0.6619413 ],
       [0.1371319 , 0.27932754],
       [0.34133688, 0.1524707 ]], dtype=float32)

(Note that in the output, the sample values are nearly identical, showing no delay introduced by Gullfoss.)

yogeshpatki commented 1 month ago

Thanks @psobot That is interesting. I realized the mistake I was making. I had called the p(a, 44100) multiple times, and with reset=False. Believe the buffered audio in plugin was the reason for the delay I was observing in the processed audio. Closing this issue!