Skip to content

Commit

Permalink
Merge pull request #34 from moddevices/mod-cleanup
Browse files Browse the repository at this point in the history
Rework worker and cleanup
  • Loading branch information
mikeoliphant authored Jun 15, 2023
2 parents f2cecf5 + 739f43b commit 4dbe451
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 120 deletions.
14 changes: 8 additions & 6 deletions resources/neural_amp_modeler.ttl.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@
@prefix ui: <http://lv2plug.in/ns/extensions/ui#>.
@prefix units: <http://lv2plug.in/ns/extensions/units#>.
@prefix urid: <http://lv2plug.in/ns/ext/urid#>.
@prefix opts: <http://lv2plug.in/ns/ext/options#> .
@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#>.
@prefix mod: <http://moddevices.com/ns/mod#>.

<@NAM_LV2_ID@#model>
a lv2:Parameter;
a lv2:Parameter;
mod:fileTypes "nam,nammodel";
rdfs:label "Neural Model";
rdfs:range atom:Path.
rdfs:label "Neural Model";
rdfs:range atom:Path.

<@NAM_LV2_ID@>
a lv2:Plugin, lv2:SimulatorPlugin;
a lv2:Plugin, lv2:SimulatorPlugin, doap:Project;
doap:name "Neural Amp Modeler";
lv2:project <@NAM_LV2_ID@>;
lv2:minorVersion @PROJECT_VERSION_MINOR@;
Expand All @@ -33,8 +34,9 @@
];

lv2:requiredFeature urid:map, work:schedule;
lv2:optionalFeature lv2:hardRTCapable;
lv2:extensionData work:interface, state:interface;
lv2:optionalFeature lv2:hardRTCapable, opts:options, state:threadSafeRestore;
lv2:extensionData work:interface, state:interface, opts:interface;
opts:supportedOption <http://lv2plug.in/ns/ext/buf-size#maxBlockLength>;

rdfs:comment """
An LV2 implementation of Neural Amp Modeler.
Expand Down
20 changes: 14 additions & 6 deletions src/nam_lv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,14 @@ static void cleanup(LV2_Handle instance)

static const void* extension_data(const char* uri)
{
static const LV2_State_Interface state = {NAM::Plugin::save, NAM::Plugin::restore};
static const LV2_Worker_Interface worker = { NAM::Plugin::work, NAM::Plugin::work_response, NULL };
static const LV2_Options_Interface options = { NAM::Plugin::options_get, NAM::Plugin::options_set };
static const LV2_State_Interface state = { NAM::Plugin::save, NAM::Plugin::restore};
static const LV2_Worker_Interface worker = { NAM::Plugin::work, NAM::Plugin::work_response, NULL };

if (!strcmp(uri, LV2_STATE__interface)) {
if (!strcmp(uri, LV2_OPTIONS__interface))
return &options;
if (!strcmp(uri, LV2_STATE__interface))
return &state;
}

if (!strcmp(uri, LV2_WORKER__interface))
return &worker;

Expand All @@ -90,5 +91,12 @@ static const LV2_Descriptor descriptor =

LV2_SYMBOL_EXPORT const LV2_Descriptor* lv2_descriptor(uint32_t index)
{
return index == 0 ? &descriptor : nullptr;
if (index == 0) {
// Turn on fast tanh approximation
activations::Activation::enable_fast_tanh();

return &descriptor;
}

return nullptr;
}
Loading

0 comments on commit 4dbe451

Please sign in to comment.