mirror of
https://github.com/mikeoliphant/neural-amp-modeler-lv2.git
synced 2026-05-06 19:50:11 +02:00
Using atom:Path to get model to load from DAW
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
@prefix param: <http://lv2plug.in/ns/ext/parameters#>.
|
||||
@prefix patch: <http://lv2plug.in/ns/ext/patch#>.
|
||||
@prefix state: <http://lv2plug.in/ns/ext/state#>.
|
||||
@prefix work: <http://lv2plug.in/ns/ext/worker#>.
|
||||
|
||||
<@NAM_LV2_ID@>
|
||||
a doap:Project;
|
||||
@@ -28,8 +29,9 @@
|
||||
lv2:microVersion @PROJECT_VERSION_PATCH@;
|
||||
doap:license <http://opensource.org/licenses/MIT>;
|
||||
|
||||
lv2:requiredFeature urid:map;
|
||||
lv2:requiredFeature urid:map, work:schedule;
|
||||
lv2:optionalFeature lv2:hardRTCapable;
|
||||
lv2:extensionData work:interface;
|
||||
|
||||
rdfs:comment "An LV2 implementation of Neural Amp Modeler";
|
||||
|
||||
|
||||
+31
-1
@@ -9,6 +9,7 @@
|
||||
#include <lv2/urid/urid.h>
|
||||
#include <lv2/log/log.h>
|
||||
#include <lv2/log/logger.h>
|
||||
#include <lv2/worker/worker.h>
|
||||
|
||||
#include "nam_plugin.hpp"
|
||||
|
||||
@@ -64,7 +65,36 @@ static void cleanup(LV2_Handle instance) {
|
||||
delete static_cast<NAM::Plugin*>(instance);
|
||||
}
|
||||
|
||||
static const void* extension_data(const char*) { return nullptr; }
|
||||
static LV2_Worker_Status
|
||||
work(LV2_Handle instance,
|
||||
LV2_Worker_Respond_Function respond,
|
||||
LV2_Worker_Respond_Handle handle,
|
||||
uint32_t size,
|
||||
const void* data)
|
||||
{
|
||||
|
||||
return LV2_WORKER_SUCCESS;
|
||||
}
|
||||
|
||||
static LV2_Worker_Status
|
||||
work_response(LV2_Handle instance,
|
||||
uint32_t size,
|
||||
const void* data)
|
||||
{
|
||||
return LV2_WORKER_SUCCESS;
|
||||
}
|
||||
|
||||
static const void*
|
||||
extension_data(const char* uri)
|
||||
{
|
||||
static const LV2_Worker_Interface worker = { work, work_response, NULL };
|
||||
|
||||
if (!strcmp(uri, LV2_WORKER__interface)) {
|
||||
return &worker;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const LV2_Descriptor descriptor = {
|
||||
"http://github.com/mikeoliphant/neural-amp-modeler-lv2",
|
||||
|
||||
+41
-3
@@ -11,7 +11,6 @@
|
||||
namespace NAM {
|
||||
Plugin::Plugin(float rate)
|
||||
{
|
||||
namModel = get_dsp("C:\\Users\\oliph\\AppData\\Roaming\\GuitarSim\\NAM\\AC15Brkup.nam");
|
||||
}
|
||||
|
||||
void Plugin::map_uris(LV2_URID_Map* map) noexcept {
|
||||
@@ -30,7 +29,46 @@ namespace NAM {
|
||||
}
|
||||
|
||||
void Plugin::process(uint32_t n_samples) noexcept {
|
||||
namModel->process(ports.audio_in, ports.audio_out, n_samples, 1.0, 1.0, mNAMParams);
|
||||
namModel->finalize_(n_samples);
|
||||
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);
|
||||
|
||||
if (obj->body.otype == uris.patch_Set)
|
||||
{
|
||||
const LV2_Atom* property = NULL;
|
||||
const LV2_Atom* file_path = NULL;
|
||||
|
||||
lv2_atom_object_get(obj, uris.patch_property, &property, 0);
|
||||
|
||||
if (property && (property->type == uris.atom_URID))
|
||||
{
|
||||
if (((const LV2_Atom_URID*)property)->body == uris.model_Path)
|
||||
{
|
||||
lv2_atom_object_get(obj, uris.patch_value, &file_path, 0);
|
||||
|
||||
if (file_path && (file_path->size > 0))
|
||||
{
|
||||
namModel = get_dsp((const char*)LV2_ATOM_BODY_CONST(file_path));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (namModel == nullptr)
|
||||
{
|
||||
for (int i = 0; i < n_samples; i++)
|
||||
{
|
||||
ports.audio_out[i] = ports.audio_in[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
namModel->process(ports.audio_in, ports.audio_out, n_samples, 1.0, 1.0, mNAMParams);
|
||||
namModel->finalize_(n_samples);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user