mirror of
https://github.com/mikeoliphant/neural-amp-modeler-lv2.git
synced 2026-05-06 19:50:11 +02:00
General cleanup, no functional changes
Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
@@ -14,10 +14,10 @@
|
|||||||
@prefix mod: <http://moddevices.com/ns/mod#>.
|
@prefix mod: <http://moddevices.com/ns/mod#>.
|
||||||
|
|
||||||
<@NAM_LV2_ID@#model>
|
<@NAM_LV2_ID@#model>
|
||||||
a lv2:Parameter;
|
a lv2:Parameter;
|
||||||
mod:fileTypes "nam,nammodel";
|
mod:fileTypes "nam,nammodel";
|
||||||
rdfs:label "Neural Model";
|
rdfs:label "Neural Model";
|
||||||
rdfs:range atom:Path.
|
rdfs:range atom:Path.
|
||||||
|
|
||||||
<@NAM_LV2_ID@>
|
<@NAM_LV2_ID@>
|
||||||
a lv2:Plugin, lv2:SimulatorPlugin;
|
a lv2:Plugin, lv2:SimulatorPlugin;
|
||||||
|
|||||||
+1
-3
@@ -66,10 +66,8 @@ static const void* extension_data(const char* uri)
|
|||||||
static const LV2_State_Interface state = {NAM::Plugin::save, NAM::Plugin::restore};
|
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_Worker_Interface worker = { NAM::Plugin::work, NAM::Plugin::work_response, NULL };
|
||||||
|
|
||||||
if (!strcmp(uri, LV2_STATE__interface)) {
|
if (!strcmp(uri, LV2_STATE__interface))
|
||||||
return &state;
|
return &state;
|
||||||
}
|
|
||||||
|
|
||||||
if (!strcmp(uri, LV2_WORKER__interface))
|
if (!strcmp(uri, LV2_WORKER__interface))
|
||||||
return &worker;
|
return &worker;
|
||||||
|
|
||||||
|
|||||||
+11
-14
@@ -17,8 +17,6 @@ namespace NAM {
|
|||||||
|
|
||||||
bool Plugin::initialize(double rate, const LV2_Feature* const* features) noexcept
|
bool Plugin::initialize(double rate, const LV2_Feature* const* features) noexcept
|
||||||
{
|
{
|
||||||
logger.log = nullptr;
|
|
||||||
|
|
||||||
for (size_t i = 0; features[i]; ++i) {
|
for (size_t i = 0; features[i]; ++i) {
|
||||||
if (std::string(features[i]->URI) == std::string(LV2_URID__map))
|
if (std::string(features[i]->URI) == std::string(LV2_URID__map))
|
||||||
map = static_cast<LV2_URID_Map*>(features[i]->data);
|
map = static_cast<LV2_URID_Map*>(features[i]->data);
|
||||||
@@ -146,8 +144,8 @@ namespace NAM {
|
|||||||
|
|
||||||
void Plugin::process(uint32_t n_samples) noexcept
|
void Plugin::process(uint32_t n_samples) noexcept
|
||||||
{
|
{
|
||||||
lv2_atom_forge_set_buffer(&atom_forge,(uint8_t*)ports.notify,ports.notify->atom.size);
|
lv2_atom_forge_set_buffer(&atom_forge, (uint8_t*)ports.notify, ports.notify->atom.size);
|
||||||
lv2_atom_forge_sequence_head(&atom_forge,&sequence_frame,uris.units_frame);
|
lv2_atom_forge_sequence_head(&atom_forge, &sequence_frame, uris.units_frame);
|
||||||
|
|
||||||
LV2_ATOM_SEQUENCE_FOREACH(ports.control, event)
|
LV2_ATOM_SEQUENCE_FOREACH(ports.control, event)
|
||||||
{
|
{
|
||||||
@@ -173,7 +171,7 @@ namespace NAM {
|
|||||||
{
|
{
|
||||||
lv2_atom_object_get(obj, uris.patch_value, &file_path, 0);
|
lv2_atom_object_get(obj, uris.patch_value, &file_path, 0);
|
||||||
|
|
||||||
if (file_path && (file_path->size > 0) && (file_path->size < 1024))
|
if (file_path && (file_path->size > 0) && (file_path->size < MAX_FILE_NAME))
|
||||||
{
|
{
|
||||||
LV2LoadModelMsg msg = { kWorkTypeLoad, {} };
|
LV2LoadModelMsg msg = { kWorkTypeLoad, {} };
|
||||||
|
|
||||||
@@ -210,10 +208,7 @@ namespace NAM {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentModel == nullptr)
|
if (currentModel != nullptr)
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
currentModel->process(&ports.audio_out, &ports.audio_out, 1, n_samples, 1.0, 1.0, mNAMParams);
|
currentModel->process(&ports.audio_out, &ports.audio_out, 1, n_samples, 1.0, 1.0, mNAMParams);
|
||||||
currentModel->finalize_(n_samples);
|
currentModel->finalize_(n_samples);
|
||||||
@@ -286,7 +281,7 @@ namespace NAM {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifndef _WIN32 // Can't free library allocated memory on Windows
|
#ifndef _WIN32 // Can't free host-allocated memory on plugin side under Windows
|
||||||
free(apath);
|
free(apath);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -335,7 +330,7 @@ namespace NAM {
|
|||||||
|
|
||||||
LV2_State_Status result = LV2_STATE_SUCCESS;
|
LV2_State_Status result = LV2_STATE_SUCCESS;
|
||||||
|
|
||||||
if (pathLen < 1024)
|
if (pathLen < MAX_FILE_NAME)
|
||||||
{
|
{
|
||||||
// Schedule model to be loaded by the provided worker
|
// Schedule model to be loaded by the provided worker
|
||||||
NAM::LV2LoadModelMsg msg = { NAM::kWorkTypeLoad, {} };
|
NAM::LV2LoadModelMsg msg = { NAM::kWorkTypeLoad, {} };
|
||||||
@@ -345,7 +340,7 @@ namespace NAM {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lv2_log_error(&nam->logger, "Model path is too long (max 1024 chars)\n");
|
lv2_log_error(&nam->logger, "Model path is too long (max %u chars)\n", MAX_FILE_NAME);
|
||||||
|
|
||||||
result = LV2_STATE_ERR_UNKNOWN;
|
result = LV2_STATE_ERR_UNKNOWN;
|
||||||
}
|
}
|
||||||
@@ -358,7 +353,7 @@ namespace NAM {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifndef _WIN32 // Can't free library allocated memory on Windows
|
#ifndef _WIN32 // Can't free host-allocated memory on plugin side under Windows
|
||||||
free(path);
|
free(path);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -385,7 +380,9 @@ namespace NAM {
|
|||||||
LV2_Atom_Forge_Frame frame;
|
LV2_Atom_Forge_Frame frame;
|
||||||
|
|
||||||
lv2_atom_forge_object(&atom_forge, &frame, 0, uris.state_StateChanged);
|
lv2_atom_forge_object(&atom_forge, &frame, 0, uris.state_StateChanged);
|
||||||
/* object with no properties */
|
|
||||||
|
/* object with no properties */
|
||||||
|
|
||||||
lv2_atom_forge_pop(&atom_forge, &frame);
|
lv2_atom_forge_pop(&atom_forge, &frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-6
@@ -25,6 +25,7 @@
|
|||||||
#define MODEL_URI PlUGIN_URI "#model"
|
#define MODEL_URI PlUGIN_URI "#model"
|
||||||
|
|
||||||
namespace NAM {
|
namespace NAM {
|
||||||
|
static constexpr unsigned int MAX_FILE_NAME = 1024;
|
||||||
|
|
||||||
enum LV2WorkType {
|
enum LV2WorkType {
|
||||||
kWorkTypeLoad,
|
kWorkTypeLoad,
|
||||||
@@ -33,7 +34,7 @@ namespace NAM {
|
|||||||
|
|
||||||
struct LV2LoadModelMsg {
|
struct LV2LoadModelMsg {
|
||||||
LV2WorkType type;
|
LV2WorkType type;
|
||||||
char path[1024];
|
char path[MAX_FILE_NAME];
|
||||||
};
|
};
|
||||||
|
|
||||||
class Plugin {
|
class Plugin {
|
||||||
@@ -49,9 +50,9 @@ namespace NAM {
|
|||||||
|
|
||||||
Ports ports = {};
|
Ports ports = {};
|
||||||
|
|
||||||
LV2_URID_Map* map;
|
LV2_URID_Map* map = nullptr;
|
||||||
LV2_Log_Logger logger;
|
LV2_Log_Logger logger = {};
|
||||||
LV2_Worker_Schedule* schedule;
|
LV2_Worker_Schedule* schedule = nullptr;
|
||||||
|
|
||||||
std::unique_ptr<::DSP> currentModel;
|
std::unique_ptr<::DSP> currentModel;
|
||||||
std::unique_ptr<::DSP> stagedModel;
|
std::unique_ptr<::DSP> stagedModel;
|
||||||
@@ -82,8 +83,6 @@ namespace NAM {
|
|||||||
const LV2_Feature* const* features);
|
const LV2_Feature* const* features);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr size_t MAX_FILE_NAME = 1024;
|
|
||||||
|
|
||||||
struct URIs {
|
struct URIs {
|
||||||
LV2_URID atom_Object;
|
LV2_URID atom_Object;
|
||||||
LV2_URID atom_Float;
|
LV2_URID atom_Float;
|
||||||
|
|||||||
Reference in New Issue
Block a user