mirror of
https://github.com/mikeoliphant/neural-amp-modeler-lv2.git
synced 2026-05-06 19:50:11 +02:00
mono i/o
This commit is contained in:
@@ -10,22 +10,12 @@
|
||||
@prefix units: <http://lv2plug.in/ns/extensions/units#>.
|
||||
@prefix urid: <http://lv2plug.in/ns/ext/urid#>.
|
||||
@prefix param: <http://lv2plug.in/ns/ext/parameters#>.
|
||||
@prefix pg: <http://lv2plug.in/ns/ext/port-groups#>.
|
||||
|
||||
<@NAM_LV2_ID@>
|
||||
a doap:Project;
|
||||
doap:maintainer <http://github.com/mikeoliphant>;
|
||||
doap:name "Neural Amp Modeler".
|
||||
|
||||
<@NAM_LV2_ID@#input>
|
||||
a pg:MonoGroup, pg:InputGroup;
|
||||
lv2:symbol "input".
|
||||
|
||||
<h@NAM_LV2_ID@#output>
|
||||
a pg:MonoGroup, pg:OutputGroup;
|
||||
lv2:symbol "output";
|
||||
pg:source <@NAM_LV2_ID@#input>.
|
||||
|
||||
<http://github.com/mikeoliphant/neural-amp-modeler-lv2>
|
||||
a lv2:Plugin, lv2:AmplifierPlugin;
|
||||
doap:name "Neural Amp Modeler";
|
||||
@@ -39,49 +29,24 @@
|
||||
|
||||
rdfs:comment "An LV2 implementation of Neural Amp Modeler";
|
||||
|
||||
pg:mainInput <@NAM_LV2_ID@#input>;
|
||||
pg:mainOutput <@NAM_LV2_ID@#output>;
|
||||
|
||||
# Control Ports
|
||||
# Audio Ports
|
||||
lv2:port [
|
||||
a lv2:InputPort, atom:AtomPort;
|
||||
atom:bufferType atom:Sequence;
|
||||
lv2:designation lv2:control ;
|
||||
lv2:index 0;
|
||||
lv2:symbol "control";
|
||||
lv2:name "control";
|
||||
rdfs:comment "UI -> DSP communication"
|
||||
], [
|
||||
a lv2:OutputPort, atom:AtomPort;
|
||||
atom:bufferType atom:Sequence;
|
||||
lv2:designation lv2:control ;
|
||||
lv2:index 1;
|
||||
lv2:symbol "notify";
|
||||
lv2:name "Notify";
|
||||
# amount of data sent in a single 8192 sample process block
|
||||
rsz:minimumSize 131428;
|
||||
rdfs:comment "DSP -> UI communication"
|
||||
], [
|
||||
a lv2:InputPort, lv2:AudioPort;
|
||||
lv2:index 2;
|
||||
lv2:index 0;
|
||||
lv2:symbol "input";
|
||||
lv2:name "Input";
|
||||
pg:group <http://github.com/mikeoliphant/neural-amp-modeler-lv2#input>;
|
||||
lv2:designation pg:left
|
||||
], [
|
||||
a lv2:OutputPort, lv2:AudioPort;
|
||||
lv2:index 3;
|
||||
lv2:index 1;
|
||||
lv2:symbol "output";
|
||||
lv2:name "Output";
|
||||
pg:group <http://github.com/mikeoliphant/neural-amp-modeler-lv2#output>;
|
||||
lv2:designation pg:left
|
||||
];
|
||||
|
||||
# Mixer
|
||||
lv2:port [
|
||||
a lv2:InputPort, lv2:ControlPort;
|
||||
lv2:designation param:wetDryRatio;
|
||||
lv2:index 4;
|
||||
lv2:index 2;
|
||||
lv2:symbol "mix";
|
||||
lv2:name "Mix";
|
||||
rdfs:comment "dry/wet ratio";
|
||||
|
||||
+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