From 100d344e3dd6b059d99c1c5c70f81eabbc004795 Mon Sep 17 00:00:00 2001 From: Mike Oliphant Date: Sat, 11 Mar 2023 10:53:05 -0800 Subject: [PATCH] Trying to get atom:Path to work for model laoding --- CMakeLists.txt | 2 +- resources/neural_amp_modeler.ttl.in | 28 ++++++++++++++++++++++------ src/nam_lv2.cpp | 2 +- src/nam_plugin.cpp | 10 ++++++++++ src/nam_plugin.hpp | 14 ++++++++++++-- 5 files changed, 46 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c1c3cfd..aca32b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.10) -project(NeuralAmpModeler VERSION 0.0.1) +project(NeuralAmpModelerLv2 VERSION 0.0.1) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") diff --git a/resources/neural_amp_modeler.ttl.in b/resources/neural_amp_modeler.ttl.in index d6c5d3b..7c2efea 100644 --- a/resources/neural_amp_modeler.ttl.in +++ b/resources/neural_amp_modeler.ttl.in @@ -35,18 +35,34 @@ patch:writable <@NAM_LV2_ID@#model>; + # Control + lv2:port [ + a atom:AtomPort, lv2:InputPort; + atom:bufferType atom:Sequence; + atom:supports patch:Message; + lv2:designation lv2:control; + lv2:index 0; + lv2:symbol "control"; + lv2:name "Control" + ], [ + a atom:AtomPort, lv2:OutputPort; + atom:bufferType atom:Sequence; + atom:supports patch:Message; + lv2:designation lv2:control; + lv2:index 1; + lv2:symbol "notify"; + lv2:name "Notify" + ]; + # Audio Ports lv2:port [ a lv2:InputPort, lv2:AudioPort; - lv2:index 0; + lv2:index 2; lv2:symbol "input"; lv2:name "Input"; ], [ a lv2:OutputPort, lv2:AudioPort; - lv2:index 1; + lv2:index 3; lv2:symbol "output"; lv2:name "Output"; - ]; - state:state [ - <@NAM_LV2_ID@#model> ; - ]. + ]. diff --git a/src/nam_lv2.cpp b/src/nam_lv2.cpp index 636508b..e6302bc 100644 --- a/src/nam_lv2.cpp +++ b/src/nam_lv2.cpp @@ -67,7 +67,7 @@ static void cleanup(LV2_Handle instance) { static const void* extension_data(const char*) { return nullptr; } static const LV2_Descriptor descriptor = { - NAM::Plugin::URI.data(), + "http://github.com/mikeoliphant/neural-amp-modeler-lv2", instantiate, connect_port, activate, diff --git a/src/nam_plugin.cpp b/src/nam_plugin.cpp index ce7fb63..2098dfa 100644 --- a/src/nam_plugin.cpp +++ b/src/nam_plugin.cpp @@ -4,6 +4,7 @@ // Lv2 #include +#include #include "nam_plugin.hpp" @@ -15,8 +16,17 @@ namespace NAM { void Plugin::map_uris(LV2_URID_Map* map) noexcept { lv2_atom_forge_init(&atom_forge, map); + uris.atom_Object = map->map(map->handle, LV2_ATOM__Object); uris.atom_Float = map->map(map->handle, LV2_ATOM__Float); + uris.atom_Int = map->map(map->handle, LV2_ATOM__Int); + uris.atom_Path = map->map(map->handle, LV2_ATOM__Path); + uris.atom_URID = map->map(map->handle, LV2_ATOM__URID); + uris.patch_Set = map->map(map->handle, LV2_PATCH__Set); + uris.patch_property = map->map(map->handle, LV2_PATCH__property); + uris.patch_value = map->map(map->handle, LV2_PATCH__value); + + uris.model_Path = map->map(map->handle, MODEL_URI); } void Plugin::process(uint32_t n_samples) noexcept { diff --git a/src/nam_plugin.hpp b/src/nam_plugin.hpp index f9dc98e..ea48ecb 100644 --- a/src/nam_plugin.hpp +++ b/src/nam_plugin.hpp @@ -13,13 +13,16 @@ #include "dsp.h" +#define PlUGIN_URI "http://github.com/mikeoliphant/neural-amp-modeler-lv2" +#define MODEL_URI PlUGIN_URI "#model" + namespace NAM { class Plugin { public: - 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; }; @@ -49,6 +52,13 @@ namespace NAM { struct URIs { LV2_URID atom_Object; LV2_URID atom_Float; + LV2_URID atom_Int; + LV2_URID atom_Path; + LV2_URID atom_URID; + LV2_URID patch_Set; + LV2_URID patch_property; + LV2_URID patch_value; + LV2_URID model_Path; }; URIs uris = {};