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 "plugin.hh"
|
||||
|
||||
using Dynamite::Plugin;
|
||||
using Dynamite::Drive;
|
||||
|
||||
static LV2_Handle
|
||||
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;
|
||||
}
|
||||
static int _ = Drive::register_class("https://github.com/aleksrutins/dynamite");
|
11
dynamite.ttl
11
dynamite.ttl
|
@ -38,4 +38,13 @@
|
|||
lv2:default 0.0 ;
|
||||
lv2:minimum -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 : '',
|
||||
dependencies : [
|
||||
dependency('lv2'),
|
||||
dependency('lv2-plugin'),
|
||||
cc.find_library('m'),
|
||||
dependency('threads')
|
||||
]
|
||||
|
|
13
plugin.cc
13
plugin.cc
|
@ -1,14 +1,9 @@
|
|||
#include <lv2/core/lv2.h>
|
||||
#include "plugin.hh"
|
||||
#include "util.hh"
|
||||
|
||||
namespace Dynamite {
|
||||
void Plugin::activate() {
|
||||
|
||||
}
|
||||
|
||||
void Plugin::connect_port(PluginPort port, void* data) {
|
||||
switch(port) {
|
||||
void Drive::connect_port(uint32_t port, void* data) {
|
||||
switch((PluginPort)port) {
|
||||
case IN:
|
||||
input = (const float *)data;
|
||||
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);
|
||||
|
||||
for(uint32_t pos = 0; pos < n_samples; pos++) {
|
||||
output[pos] = input[pos] * coeff;
|
||||
}
|
||||
}
|
||||
|
||||
void Plugin::deactivate() {}
|
||||
}
|
12
plugin.hh
12
plugin.hh
|
@ -1,19 +1,21 @@
|
|||
#pragma once
|
||||
#include <lv2plugin.hpp>
|
||||
#include <stdint.h>
|
||||
|
||||
using namespace LV2;
|
||||
|
||||
namespace Dynamite {
|
||||
enum PluginPort {
|
||||
IN, OUT, DRIVE
|
||||
IN, OUT, DRIVE, THRESHOLD
|
||||
};
|
||||
|
||||
class Plugin {
|
||||
class Drive : public Plugin<Drive> {
|
||||
const float *drive;
|
||||
const float *input;
|
||||
float *output;
|
||||
public:
|
||||
void connect_port(PluginPort port, void* data);
|
||||
void activate();
|
||||
Drive(double rate) : Plugin<Drive>(1) {}
|
||||
void connect_port(uint32_t port, void* data);
|
||||
void run(uint32_t n_samples);
|
||||
void deactivate();
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue