Closed sdatkinson closed 2 months ago
Something like this has been needed for a while to solve issue https://github.com/sdatkinson/NeuralAmpModelerCore/issues/49, so it will be a welcome change.
Will calling this be required before doing processing? As you say, get_dsp() doesn't currently know about block sizes. If it is required, maybe call it "Initialize" instead of "Reset"?
Any plugin implementation will want to call this new method independently of loading the model, since it should respond to sample rate and max block size changes upstream from the DAW.
Whether it makes sense for this method to do the pre-warm probably depends on whether or not changing the sample rate or block size would require another pre-warming pass.
Will calling this be required before doing processing?
Yes, ultimately. Knowing about the maximum buffer size (and reacting accordingly, e.g. pre-allocating arrays) should be handled through this function. However, I'm not going to require the pre-allocation work to be done to resolve this Issue. That can be handled under #49 (and any other Issues for other architectures).
Whether it makes sense for this method to do the pre-warm probably depends on whether or not changing the sample rate or block size would require another pre-warming pass.
Most models will need to warm-up after arrays are resized because the "warmed-up" values that they'll want to hold isn't necessarily zero. (Trivial example: a model that's just one ("ML") convolution layer (with a kernel and a bias vector) will warm up to the layer's bias value, and any multi-layer model like a WaveNet will propagate that bias through all the activations, skip-connections, etc).
The other thing to keep in mind is that a warmed-up model won't necessarily be outputting zeroes (as you noticed way back with the LSTM)--nor should it be expected to do so.
So, code that integrates a NAM with other processing might want to warm up the whole signal chain end to end--warming up a NAM by itself may not be enough. NeuralAmpModelerPlugin for example would want to warm up both the model and the following HPF together.
I was just thinking through is out loud, but based on that I think I'm going to go for not doing pre-warming as part of Reset
. The main thing that models will want to do ultimately is pre-allocation.
Define a method to reset the model. Proposed signature:
This function would be responsible for
get_dsp()
doesn't ask about the max block size, so we couldn't know what the max block size is at initialization, necessarily?Unfortunately, I can't really do anything with the sample rate for the models that are currently supported; however, this isn't typical for effects, and it could be useful for subclasses that can do something with it (e.g. the resampling class that I'm implementing in NeuralAmpModelerPlugin). So, having it as part of the signature may be helpful for extending the method.