Use the C++ version of the LV2 libraries
This commit is contained in:
parent
391f9e9a0b
commit
c226177453
5 changed files with 23 additions and 54 deletions
40
dynamite.cc
40
dynamite.cc
|
@ -1,42 +1,6 @@
|
||||||
#include <lv2/core/lv2.h>
|
#include <lv2/core/lv2.h>
|
||||||
#include "plugin.hh"
|
#include "plugin.hh"
|
||||||
|
|
||||||
using Dynamite::Plugin;
|
using Dynamite::Drive;
|
||||||
|
|
||||||
static LV2_Handle
|
static int _ = Drive::register_class("https://github.com/aleksrutins/dynamite");
|
||||||
instantiate(const LV2_Descriptor* descriptor,
|
|
||||||
double rate,
|
|
||||||
const char* bundle_path,
|
|
||||||
const LV2_Feature* const* features)
|
|
||||||
{
|
|
||||||
return new Plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
cleanup(LV2_Handle instance)
|
|
||||||
{
|
|
||||||
delete (Plugin *)instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const void*
|
|
||||||
extension_data(const char *uri)
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const LV2_Descriptor descriptor = {
|
|
||||||
"https://github.com/aleksrutins/dynamite",
|
|
||||||
instantiate,
|
|
||||||
(void (*)(LV2_Handle, uint32_t, void*)) &Plugin::connect_port,
|
|
||||||
(void (*)(LV2_Handle)) &Plugin::activate,
|
|
||||||
(void (*)(LV2_Handle, uint32_t)) &Plugin::run,
|
|
||||||
(void (*)(LV2_Handle)) &Plugin::deactivate,
|
|
||||||
cleanup,
|
|
||||||
extension_data
|
|
||||||
};
|
|
||||||
|
|
||||||
LV2_SYMBOL_EXPORT
|
|
||||||
const LV2_Descriptor*
|
|
||||||
lv2_descriptor(uint32_t index) {
|
|
||||||
return index == 0 ? &descriptor : nullptr;
|
|
||||||
}
|
|
|
@ -38,4 +38,13 @@
|
||||||
lv2:default 0.0 ;
|
lv2:default 0.0 ;
|
||||||
lv2:minimum -20.0 ;
|
lv2:minimum -20.0 ;
|
||||||
lv2:maximum 20.0 ;
|
lv2:maximum 20.0 ;
|
||||||
|
] ,
|
||||||
|
[
|
||||||
|
a lv2:InputPort , lv2:ControlPort ;
|
||||||
|
lv2:index 3 ;
|
||||||
|
lv2:symbol "threshold" ;
|
||||||
|
lv2:name "Threshold" ;
|
||||||
|
lv2:default 1.0 ;
|
||||||
|
lv2:minimum -20.0 ;
|
||||||
|
lv2:maximum 60.0 ;
|
||||||
].
|
].
|
|
@ -28,6 +28,7 @@ shlib = shared_library('dynamite', srcs,
|
||||||
name_prefix : '',
|
name_prefix : '',
|
||||||
dependencies : [
|
dependencies : [
|
||||||
dependency('lv2'),
|
dependency('lv2'),
|
||||||
|
dependency('lv2-plugin'),
|
||||||
cc.find_library('m'),
|
cc.find_library('m'),
|
||||||
dependency('threads')
|
dependency('threads')
|
||||||
]
|
]
|
||||||
|
|
13
plugin.cc
13
plugin.cc
|
@ -1,14 +1,9 @@
|
||||||
#include <lv2/core/lv2.h>
|
|
||||||
#include "plugin.hh"
|
#include "plugin.hh"
|
||||||
#include "util.hh"
|
#include "util.hh"
|
||||||
|
|
||||||
namespace Dynamite {
|
namespace Dynamite {
|
||||||
void Plugin::activate() {
|
void Drive::connect_port(uint32_t port, void* data) {
|
||||||
|
switch((PluginPort)port) {
|
||||||
}
|
|
||||||
|
|
||||||
void Plugin::connect_port(PluginPort port, void* data) {
|
|
||||||
switch(port) {
|
|
||||||
case IN:
|
case IN:
|
||||||
input = (const float *)data;
|
input = (const float *)data;
|
||||||
break;
|
break;
|
||||||
|
@ -21,13 +16,11 @@ namespace Dynamite {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plugin::run(uint32_t n_samples) {
|
void Drive::run(uint32_t n_samples) {
|
||||||
const float coeff = dbCo(*drive);
|
const float coeff = dbCo(*drive);
|
||||||
|
|
||||||
for(uint32_t pos = 0; pos < n_samples; pos++) {
|
for(uint32_t pos = 0; pos < n_samples; pos++) {
|
||||||
output[pos] = input[pos] * coeff;
|
output[pos] = input[pos] * coeff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plugin::deactivate() {}
|
|
||||||
}
|
}
|
12
plugin.hh
12
plugin.hh
|
@ -1,19 +1,21 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include <lv2plugin.hpp>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
using namespace LV2;
|
||||||
|
|
||||||
namespace Dynamite {
|
namespace Dynamite {
|
||||||
enum PluginPort {
|
enum PluginPort {
|
||||||
IN, OUT, DRIVE
|
IN, OUT, DRIVE, THRESHOLD
|
||||||
};
|
};
|
||||||
|
|
||||||
class Plugin {
|
class Drive : public Plugin<Drive> {
|
||||||
const float *drive;
|
const float *drive;
|
||||||
const float *input;
|
const float *input;
|
||||||
float *output;
|
float *output;
|
||||||
public:
|
public:
|
||||||
void connect_port(PluginPort port, void* data);
|
Drive(double rate) : Plugin<Drive>(1) {}
|
||||||
void activate();
|
void connect_port(uint32_t port, void* data);
|
||||||
void run(uint32_t n_samples);
|
void run(uint32_t n_samples);
|
||||||
void deactivate();
|
|
||||||
};
|
};
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue