sdatkinson / NeuralAmpModelerPlugin

Plugin for Neural Amp Modeler
MIT License
1.98k stars 132 forks source link

[BUG] Timing not sample accurate #143

Closed axewav closed 1 year ago

axewav commented 1 year ago

NAM does not report PDC to host correctly, resulting in a delay vs an unprocessed track.

To reproduce:

More over, the delay seems to vary between captures. Typical delay seems to be around 9-13 samples.

sdatkinson commented 1 year ago

NAM does not report PDC to host correctly

What does it report, and what do you expect instead?

I suspect this is not actually an issue with the plugin. The trainer needs to align the output and input since most DAWs don't get the latency compensation exactly correct (and some don't do it at all). The model emulates the reamped rig with the calibrated time delay.

If you know what the time delay is for your DAW, you can provide it explicitly during training. Otherwise, you'll need to time-align by hand.

Closing this for now. However, if you can answer the PDC question above that there is a bug with the plugin, feel free to re-open.

axewav commented 1 year ago

Commenting a bit late, sorry about that.

Not sure how to explain this more clearly but I'll try. In VST plugins, if processing causes latency, plugins report the delay back to the host so the host can compensate and keep audio in sync. This is called Plugin Delay Compensation (PDC). I believe in iPlug2 framework this is done by calling the SetLatency method.

As far as I can see, NAM reports latency as 0, but in fact has latency of around 10 samples, resulting in a short delay that causes problems - the worst ones being phase issues for example when an unprocessed track is mixed with a track processesed by NAM.

Furthermore, to make things worse, this latency is not constant but seems to depend on the actual NAM model. Thus, setting PDC manually is not a real solution.

Now, I do not know whether this latency originates from the training process or in the plugin itself. But I believe it should be possible to fix this in the plugin, for example by processing a test signal and measuring the latency when a model file is opened and then calling SetLatency accrodingly.

Hope this helps!