diff --git a/NAM/dsp.cpp b/NAM/dsp.cpp index 6d10231..c10aa80 100644 --- a/NAM/dsp.cpp +++ b/NAM/dsp.cpp @@ -30,7 +30,7 @@ DSP::DSP(const double loudness) { } -void DSP::process(double** inputs, double** outputs, const int num_channels, const int num_frames, +void DSP::process(NAM_SAMPLE** inputs, NAM_SAMPLE** outputs, const int num_channels, const int num_frames, const double input_gain, const double output_gain, const std::unordered_map& params) { @@ -58,7 +58,7 @@ void DSP::_get_params_(const std::unordered_map& 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 double 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 double gain) { const double loudnessGain = pow(10.0, -(this->mLoudness - TARGET_DSP_LOUDNESS) / 20.0); const double 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 ===================================================================== diff --git a/NAM/dsp.h b/NAM/dsp.h index bf1c44e..39bf6b3 100644 --- a/NAM/dsp.h +++ b/NAM/dsp.h @@ -12,6 +12,12 @@ #include "activations.h" #include "json.hpp" +#ifdef NAM_SAMPLE_FLOAT +#define NAM_SAMPLE float +#else +#define NAM_SAMPLE double +#endif + enum EArchitectures { kLinear = 0, @@ -51,7 +57,7 @@ class DSP // 3. The core DSP algorithm is run (This is what should probably be // overridden in subclasses). // 4. The output level is applied and the result stored to `output`. - virtual void process(double** inputs, double** outputs, const int num_channels, const int num_frames, + virtual void process(NAM_SAMPLE** inputs, NAM_SAMPLE** outputs, const int num_channels, const int num_frames, const double input_gain, const double output_gain, const std::unordered_map& params); // Anything to take care of before next buffer comes in. @@ -87,7 +93,7 @@ class DSP // Apply the input gain // Result populates this->_input_post_gain - void _apply_input_level_(double** inputs, const int num_channels, const int num_frames, const double gain); + void _apply_input_level_(NAM_SAMPLE** inputs, const int num_channels, const int num_frames, const double gain); // i.e. ensure the size is correct. void _ensure_core_dsp_output_ready_(); @@ -98,7 +104,7 @@ class DSP virtual void _process_core_(); // Copy this->_core_dsp_output to output and apply the output volume - void _apply_output_level_(double** outputs, const int num_channels, const int num_frames, const double gain); + void _apply_output_level_(NAM_SAMPLE** outputs, const int num_channels, const int num_frames, const double gain); }; // Class where an input buffer is kept so that long-time effects can be