mirror of
https://github.com/mikeoliphant/neural-amp-modeler-lv2.git
synced 2026-05-15 04:50:46 +02:00
mono i/o
This commit is contained in:
+8
-12
@@ -20,14 +20,14 @@ constexpr auto _INPUT_BUFFER_SAFETY_FACTOR = 32;
|
||||
DSP::DSP() { this->_stale_params = true; }
|
||||
|
||||
void DSP::process(const NAMSample *input, NAMSample *output,
|
||||
const int num_channels, const int num_frames,
|
||||
const int num_frames,
|
||||
const double input_gain, const double output_gain,
|
||||
const std::unordered_map<std::string, double> ¶ms) {
|
||||
this->_get_params_(params);
|
||||
this->_apply_input_level_(input, num_channels, num_frames, input_gain);
|
||||
this->_apply_input_level_(input, num_frames, input_gain);
|
||||
this->_ensure_core_dsp_output_ready_();
|
||||
this->_process_core_();
|
||||
this->_apply_output_level_(output, num_channels, num_frames, output_gain);
|
||||
this->_apply_output_level_(output, num_frames, output_gain);
|
||||
}
|
||||
|
||||
void DSP::finalize_(const int num_frames) {}
|
||||
@@ -46,14 +46,12 @@ void DSP::_get_params_(
|
||||
}
|
||||
}
|
||||
|
||||
void DSP::_apply_input_level_(const NAMSample *input, const int num_channels,
|
||||
const int num_frames, const double gain) {
|
||||
void DSP::_apply_input_level_(const NAMSample *input, 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.
|
||||
if (this->_input_post_gain.size() != num_frames)
|
||||
this->_input_post_gain.resize(num_frames);
|
||||
// MONO ONLY
|
||||
const int channel = 0;
|
||||
|
||||
for (int i = 0; i < num_frames; i++)
|
||||
this->_input_post_gain[i] = float(gain * input[i]);
|
||||
}
|
||||
@@ -69,11 +67,9 @@ void DSP::_process_core_() {
|
||||
this->_core_dsp_output[i] = this->_input_post_gain[i];
|
||||
}
|
||||
|
||||
void DSP::_apply_output_level_(NAMSample *output, const int num_channels,
|
||||
const int num_frames, const double gain) {
|
||||
for (int c = 0; c < num_channels; c++)
|
||||
for (int s = 0; s < num_frames; s++)
|
||||
output[s] = NAMSample(gain * this->_core_dsp_output[s]);
|
||||
void DSP::_apply_output_level_(NAMSample *output, const int num_frames, const double gain) {
|
||||
for (int s = 0; s < num_frames; s++)
|
||||
output[s] = NAMSample(gain * this->_core_dsp_output[s]);
|
||||
}
|
||||
|
||||
// Buffer =====================================================================
|
||||
|
||||
@@ -42,8 +42,7 @@ public:
|
||||
// 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(const NAMSample *input, NAMSample *output,
|
||||
const int num_channels, const int num_frames,
|
||||
virtual void process(const NAMSample *input, NAMSample *output, const int num_frames,
|
||||
const double input_gain, const double output_gain,
|
||||
const std::unordered_map<std::string, double> ¶ms);
|
||||
// Anything to take care of before next buffer comes in.
|
||||
@@ -74,8 +73,7 @@ protected:
|
||||
|
||||
// Apply the input gain
|
||||
// Result populates this->_input_post_gain
|
||||
void _apply_input_level_(const NAMSample *input, const int num_channels,
|
||||
const int num_frames, const double gain);
|
||||
void _apply_input_level_(const NAMSample *input, const int num_frames, const double gain);
|
||||
|
||||
// i.e. ensure the size is correct.
|
||||
void _ensure_core_dsp_output_ready_();
|
||||
@@ -86,8 +84,7 @@ protected:
|
||||
virtual void _process_core_();
|
||||
|
||||
// Copy this->_core_dsp_output to output and apply the output volume
|
||||
void _apply_output_level_(NAMSample *output, const int num_channels,
|
||||
const int num_frames, const double gain);
|
||||
void _apply_output_level_(NAMSample *output, const int num_frames, const double gain);
|
||||
};
|
||||
|
||||
// Class where an input buffer is kept so that long-time effects can be
|
||||
|
||||
+1
-9
@@ -20,15 +20,7 @@ namespace NAM {
|
||||
}
|
||||
|
||||
void Plugin::process(uint32_t n_samples) noexcept {
|
||||
if (ports.control) {
|
||||
LV2_ATOM_SEQUENCE_FOREACH(ports.control, event) {
|
||||
if (event->body.type == uris.atom_Object) {
|
||||
const auto obj = reinterpret_cast<LV2_Atom_Object*>(&event->body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namModel->process(ports.audio_in, ports.audio_out, 1, n_samples, 1.0, 1.0, mNAMParams);
|
||||
namModel->process(ports.audio_in, ports.audio_out, n_samples, 1.0, 1.0, mNAMParams);
|
||||
namModel->finalize_(n_samples);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,6 @@ namespace NAM {
|
||||
static constexpr std::string_view URI = "http://github.com/mikeoliphant/neural-amp-modeler-lv2";
|
||||
|
||||
struct Ports {
|
||||
const LV2_Atom_Sequence* control;
|
||||
LV2_Atom_Sequence* notify;
|
||||
const float* audio_in;
|
||||
float* audio_out;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user