Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset method #96

Closed
sdatkinson opened this issue Dec 2, 2023 · 2 comments · Fixed by #111
Closed

Reset method #96

sdatkinson opened this issue Dec 2, 2023 · 2 comments · Fixed by #111
Assignees
Labels
enhancement New feature or request

Comments

@sdatkinson
Copy link
Owner

Define a method to reset the model. Proposed signature:

virtual void Reset(const double sampleRate, const int maxBlockSize);

This function would be responsible for

  • Resizing arrays
  • (Potentially?) doing the warm-up calculations. [_I'm not sure about this since 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.

@sdatkinson sdatkinson added the enhancement New feature or request label Dec 2, 2023
@mikeoliphant
Copy link
Contributor

Something like this has been needed for a while to solve issue #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.

@sdatkinson sdatkinson self-assigned this Sep 8, 2024
@sdatkinson
Copy link
Owner Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants