-
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,15 +23,15 @@ DSP::DSP() | |
{ | ||
} | ||
|
||
DSP::DSP(const double loudness) | ||
DSP::DSP(const NAM_SAMPLE loudness) | ||
: mLoudness(loudness) | ||
, mNormalizeOutputLoudness(false) | ||
, _stale_params(true) | ||
{ | ||
} | ||
|
||
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 commentThe 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 commentThe 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). |
||
const std::unordered_map<std::string, double>& params) | ||
{ | ||
this->_get_params_(params); | ||
|
@@ -58,7 +58,7 @@ void DSP::_get_params_(const std::unordered_map<std::string, double>& input_para | |
} | ||
} | ||
|
||
void DSP::_apply_input_level_(double** inputs, const int num_channels, const int num_frames, const double gain) | ||
void DSP::_apply_input_level_(NAM_SAMPLE** inputs, const int num_channels, const int num_frames, const NAM_SAMPLE gain) | ||
{ | ||
// Must match exactly; we're going to use the size of _input_post_gain later | ||
// for num_frames. | ||
|
@@ -83,13 +83,14 @@ void DSP::_process_core_() | |
this->_core_dsp_output[i] = this->_input_post_gain[i]; | ||
} | ||
|
||
void DSP::_apply_output_level_(double** outputs, const int num_channels, const int num_frames, const double gain) | ||
void DSP::_apply_output_level_(NAM_SAMPLE** outputs, const int num_channels, const int num_frames, | ||
const NAM_SAMPLE gain) | ||
{ | ||
const double loudnessGain = pow(10.0, -(this->mLoudness - TARGET_DSP_LOUDNESS) / 20.0); | ||
const double finalGain = this->mNormalizeOutputLoudness ? gain * loudnessGain : gain; | ||
const NAM_SAMPLE loudnessGain = (NAM_SAMPLE)pow(10.0, -(this->mLoudness - TARGET_DSP_LOUDNESS) / 20.0); | ||
const NAM_SAMPLE finalGain = this->mNormalizeOutputLoudness ? gain * loudnessGain : gain; | ||
for (int c = 0; c < num_channels; c++) | ||
for (int s = 0; s < num_frames; s++) | ||
outputs[c][s] = double(finalGain * this->_core_dsp_output[s]); | ||
outputs[c][s] = (NAM_SAMPLE)(finalGain * this->_core_dsp_output[s]); | ||
} | ||
|
||
// Buffer ===================================================================== | ||
|
@@ -99,7 +100,7 @@ Buffer::Buffer(const int receptive_field) | |
{ | ||
} | ||
|
||
Buffer::Buffer(const double loudness, const int receptive_field) | ||
Buffer::Buffer(const NAM_SAMPLE loudness, const int receptive_field) | ||
: DSP(loudness) | ||
{ | ||
this->_set_receptive_field(receptive_field); | ||
|
@@ -176,7 +177,7 @@ Linear::Linear(const int receptive_field, const bool _bias, const std::vector<fl | |
{ | ||
} | ||
|
||
Linear::Linear(const double loudness, const int receptive_field, const bool _bias, const std::vector<float>& params) | ||
Linear::Linear(const NAM_SAMPLE loudness, const int receptive_field, const bool _bias, const std::vector<float>& params) | ||
: Buffer(loudness, receptive_field) | ||
{ | ||
if (params.size() != (receptive_field + (_bias ? 1 : 0))) | ||
|
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.