-
Notifications
You must be signed in to change notification settings - Fork 58
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
Allow NAM_SAMPLE_FLOAT to switch model input to float instead of double #48
Conversation
Good stuff. JUCE, for instance, uses float buffers, so keeping an extra double-precision buffer as an adapter for NAM is a bit annoying. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving since I've called it a nit, but I'd appreciate hearing back from you about having gain parameters be of NAM_SAMPLE
type. It feels odd, but I know I haven't seen enough DSP code to feel confident about conventions in the space.
NAM/convnet.cpp
Outdated
@@ -99,7 +99,7 @@ convnet::ConvNet::ConvNet(const int channels, const std::vector<int>& dilations, | |||
{ | |||
} | |||
|
|||
convnet::ConvNet::ConvNet(const double loudness, const int channels, const std::vector<int>& dilations, | |||
convnet::ConvNet::ConvNet(const NAM_SAMPLE loudness, const int channels, const std::vector<int>& dilations, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I don't like loudness
being of "sample" type--it's a parameter of the model.
But I get that it mainly serves to do arithmetic with samples, so I can live with it.
NAM/dsp.cpp
Outdated
void DSP::process(double** inputs, double** outputs, const int num_channels, const int num_frames, | ||
const double input_gain, const double output_gain, | ||
void DSP::process(NAM_SAMPLE** inputs, NAM_SAMPLE** outputs, const int num_channels, const int num_frames, | ||
const NAM_SAMPLE input_gain, const NAM_SAMPLE output_gain, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it looks weird having all of these parameters being called "samples". Can you point me to somewhere else that follows this convention? It just doesn't sound right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure either, and I'm fine either way. "loudness" is an internal parameter anyway, and "input_gain" and "output_gain" should be probably be removed since the plugin just passes "1.0" and handles gain itself (as does my LV2 plugin).
By the way, what about |
No - the models operate with floats regardless of the input sample precision. |
Ok, I've reverted the parameters to double. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👍🏻
This PR adds a NAM_SAMPLE #define that is used instead of "double" for input samples for model processing.
If NAM_SAMPLE_FLOAT is defined, this will switch NAM_SAMPLE to "float". Otherwise it remains "double", so no there is no change in existing behavior.
This allows processing loops using "float" to avoid having to convert buffers to "double".