Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework worker and cleanup #34

Merged
merged 7 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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