Skip to content

Processing interface cleanup#78

Merged
sdatkinson merged 5 commits into
sdatkinson:mainfrom
mikeoliphant:interface_cleanup
Oct 6, 2023
Merged

Processing interface cleanup#78
sdatkinson merged 5 commits into
sdatkinson:mainfrom
mikeoliphant:interface_cleanup

Conversation

@mikeoliphant

Copy link
Copy Markdown
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
Copy Markdown
Owner

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

@sdatkinson sdatkinson left a comment

Copy link
Copy Markdown
Owner

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!

Comment thread NAM/dsp.h
@@ -107,7 +100,7 @@ class DSP
virtual void _process_core_();

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

Copy link
Copy Markdown
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.

Comment thread NAM/dsp.cpp
{
this->_get_params_(params);
this->_apply_input_level_(inputs, num_channels, num_frames, input_gain);
this->_input_samples = input;

Copy link
Copy Markdown
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.

Comment thread NAM/dsp.cpp
// 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
Copy Markdown
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 🙂

Comment thread NAM/dsp.cpp
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
Copy Markdown
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
Copy Markdown
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.

@mikeoliphant

Copy link
Copy Markdown
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