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

Processing interface cleanup #78

Merged
merged 5 commits into from
Oct 6, 2023

Conversation

mikeoliphant
Copy link
Contributor

This PR cleans up and simplifies the processing interface by doing the following:

  • Removes input/output gain parameters.
  • Removes model "params" dictionary parameter.
  • Switches from multi-channel inputs/outputs to single mono input/output.
  • Removes extra input/output buffers and input copy

The process call is now just simply:

void DSP::process(NAM_SAMPLE* input, NAM_SAMPLE* output, const int num_frames)

This mostly is just a benefit for simplicity of interface, although for simple models like LSTM, it might make for a small noticeable performance increase.

@sdatkinson - note that I just removed the model parameter dictionary from the process call. I didn't take out the internal code using it - I figured that is better done by you.

I've tested WaveNet and LSTM, but not ConvNet.

Resolves #77
Resolves #27
Gives us a start on #49

@sdatkinson
Copy link
Owner

Awesome! Based on the description, this sounds super. I'll have a look when I get a chance.

Copy link
Owner

@sdatkinson sdatkinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍🏻

Thanks for this PR!

@@ -107,7 +100,7 @@ class DSP
virtual void _process_core_();

// Copy this->_core_dsp_output to output and apply the output volume
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Since we're getting rid of gain, might be able to simplify this even more.

{
this->_get_params_(params);
this->_apply_input_level_(inputs, num_channels, num_frames, input_gain);
this->_input_samples = input;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I bet we can simplify this even more: I think that process() can be a pure virtual function.

}

void DSP::_process_core_()
{
// Default implementation is the null operation
for (size_t i = 0; i < this->_input_post_gain.size(); i++)
this->_core_dsp_output[i] = this->_input_post_gain[i];
for (size_t i = 0; i < _num_input_samples; i++)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: yeah, I'm probably going to PR to put this as the default implementation of process() and get rid of _process_core_() entirely 🙂

for (int c = 0; c < num_channels; c++)
for (int s = 0; s < num_frames; s++)
outputs[c][s] = (NAM_SAMPLE)(finalGain * this->_core_dsp_output[s]);
const double finalGain = this->mNormalizeOutputLoudness ? loudnessGain : 1.0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I see.

Question: What do you think about having this class not be responsible for normalizing? It can provide information, but leave it up to the plugin to do anything about it? I'm happy either way, but perhaps a tiny bit happier pushing it out of this library because of how it'd clean up all of the subclasses and make it a little simpler from a dev standpoint I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that was my preference from the beginning: #18 (comment) 😉

I think it makes sense for the plugin to do it, since it will already be doing output gain adjustment - so no additional pass necessary.

@sdatkinson sdatkinson merged commit 8904227 into sdatkinson:main Oct 6, 2023
1 check passed
@mikeoliphant
Copy link
Contributor Author

Overall, I agree that there is more simplification/restructuring that can/should be done. I avoided going too far at once in the interest of making some quick progress that could easily be merged.

@mikeoliphant mikeoliphant deleted the interface_cleanup branch October 16, 2023 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make core NAM interfaces mono Reduce input/output buffer copies in model processing
2 participants