now lv2 works
This commit is contained in:
parent
238ec0fff4
commit
4a7cbd79ab
24
templates/lv2/make/Makefile
Normal file
24
templates/lv2/make/Makefile
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
include vars.mk
|
||||||
|
|
||||||
|
CC = gcc
|
||||||
|
CFLAGS = -fPIC -Wall -Wpedantic -Wextra -Wno-unused-parameter
|
||||||
|
|
||||||
|
BUNDLE_DIR = ${BUNDLE_NAME}.lv2
|
||||||
|
|
||||||
|
SO_FILE := ${BUNDLE_NAME}.so
|
||||||
|
|
||||||
|
all: build/${BUNDLE_DIR}/manifest.ttl build/${BUNDLE_DIR}/${SO_FILE}
|
||||||
|
|
||||||
|
build/${BUNDLE_DIR}/manifest.ttl: data/manifest.ttl | build/${BUNDLE_DIR}
|
||||||
|
cp $^ $@
|
||||||
|
|
||||||
|
build/${BUNDLE_DIR}/${SO_FILE}: src/lv2.c | build/${BUNDLE_DIR}
|
||||||
|
${CC} $^ -o $@ ${CFLAGS} -shared
|
||||||
|
|
||||||
|
build/${BUNDLE_DIR}:
|
||||||
|
mkdir -p $@
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -fr build
|
||||||
|
|
||||||
|
.PHONY: clean
|
1
templates/lv2/make/vars.mk
Normal file
1
templates/lv2/make/vars.mk
Normal file
@ -0,0 +1 @@
|
|||||||
|
BUNDLE_NAME := {{=it.product.bundleName}}
|
@ -1,4 +1,5 @@
|
|||||||
#include "lv2/core/lv2.h"
|
#include "lv2/core/lv2.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "data.h"
|
#include "data.h"
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
@ -6,7 +7,7 @@
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
plugin p;
|
plugin p;
|
||||||
#if DATA_PRODUCT_AUDIO_INPUT_CHANNELS_N > 0
|
#if DATA_PRODUCT_AUDIO_INPUT_CHANNELS_N > 0
|
||||||
float * x[DATA_PRODUCT_AUDIO_INPUT_CHANNELS_N];
|
const float * x[DATA_PRODUCT_AUDIO_INPUT_CHANNELS_N];
|
||||||
#endif
|
#endif
|
||||||
#if DATA_PRODUCT_AUDIO_OUTPUT_CHANNELS_N > 0
|
#if DATA_PRODUCT_AUDIO_OUTPUT_CHANNELS_N > 0
|
||||||
float * y[DATA_PRODUCT_AUDIO_OUTPUT_CHANNELS_N];
|
float * y[DATA_PRODUCT_AUDIO_OUTPUT_CHANNELS_N];
|
||||||
@ -15,11 +16,11 @@ typedef struct {
|
|||||||
float * c[DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N];
|
float * c[DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N];
|
||||||
#endif
|
#endif
|
||||||
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
||||||
float params[DATA_PRODUCT_CONTROL_INPUTS_N};
|
float params[DATA_PRODUCT_CONTROL_INPUTS_N];
|
||||||
#endif
|
#endif
|
||||||
} plugin_instance;
|
} plugin_instance;
|
||||||
|
|
||||||
static const LV2_Handle instantiate(const struct LV2_Descriptor * descriptor, double sample_rate, const char * bundle_path, const LV2_Feature * const * features) {
|
static LV2_Handle instantiate(const struct LV2_Descriptor * descriptor, double sample_rate, const char * bundle_path, const LV2_Feature * const * features) {
|
||||||
plugin_instance *instance = malloc(sizeof(plugin_instance));
|
plugin_instance *instance = malloc(sizeof(plugin_instance));
|
||||||
if (instance == NULL)
|
if (instance == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -56,8 +57,8 @@ static void connect_port(LV2_Handle instance, uint32_t port, void * data_locatio
|
|||||||
static void activate(LV2_Handle instance) {
|
static void activate(LV2_Handle instance) {
|
||||||
plugin_instance * i = (plugin_instance *)instance;
|
plugin_instance * i = (plugin_instance *)instance;
|
||||||
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
||||||
for (size_t j = 0; j < DATA_PRODUCT_CONTROL_INPUTS_N; j++)
|
for (size_t j = 0; j < DATA_PRODUCT_CONTROL_INPUTS_N; j++) {
|
||||||
i->params[j] = i->c[j] != NULL ? i->c[j] : param_defaults[j];
|
i->params[j] = i->c[j] != NULL ? *i->c[j] : param_defaults[j];
|
||||||
plugin_set_parameter(&i->p, j, i->params[j]);
|
plugin_set_parameter(&i->p, j, i->params[j]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -68,8 +69,8 @@ static void run(LV2_Handle instance, uint32_t sample_count) {
|
|||||||
plugin_instance * i = (plugin_instance *)instance;
|
plugin_instance * i = (plugin_instance *)instance;
|
||||||
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
||||||
for (size_t j = 0; j < DATA_PRODUCT_CONTROL_INPUTS_N; j++)
|
for (size_t j = 0; j < DATA_PRODUCT_CONTROL_INPUTS_N; j++)
|
||||||
if (i->c[j] != i->params[j]) {
|
if (*i->c[j] != i->params[j]) {
|
||||||
i->params[j] = i->c[j];
|
i->params[j] = *i->c[j];
|
||||||
plugin_set_parameter(&i->p, j, i->params[j]);
|
plugin_set_parameter(&i->p, j, i->params[j]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -62,4 +62,6 @@ module.exports = function (data, api) {
|
|||||||
api.copyFile(`src${sep}lv2.c`, `src${sep}lv2.c`);
|
api.copyFile(`src${sep}lv2.c`, `src${sep}lv2.c`);
|
||||||
api.generateFileFromTemplateFile(`src${sep}data.h`, `src${sep}data.h`, data);
|
api.generateFileFromTemplateFile(`src${sep}data.h`, `src${sep}data.h`, data);
|
||||||
api.copyFileIfNotExists(`src${sep}plugin.h`, `src${sep}plugin.h`);
|
api.copyFileIfNotExists(`src${sep}plugin.h`, `src${sep}plugin.h`);
|
||||||
|
api.copyFile(`make${sep}Makefile`, `Makefile`);
|
||||||
|
api.generateFileFromTemplateFile(`make${sep}vars.mk`, `vars.mk`, data);
|
||||||
};
|
};
|
||||||
|
35
test/plugin.h
Normal file
35
test/plugin.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
typedef struct plugin {
|
||||||
|
float gain;
|
||||||
|
char bypass;
|
||||||
|
} plugin;
|
||||||
|
|
||||||
|
void plugin_init(plugin *instance) {
|
||||||
|
instance->gain = 1.f;
|
||||||
|
instance->bypass = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void plugin_fini(plugin *instance) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void plugin_set_sample_rate(plugin *instance, float sample_rate) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void plugin_reset(plugin *instance) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void plugin_set_parameter(plugin *instance, size_t index, float value) {
|
||||||
|
switch (index) {
|
||||||
|
case 0:
|
||||||
|
instance->gain = value;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
instance->bypass = value >= 0.5f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void plugin_process(plugin *instance, const float **inputs, float **outputs, size_t n_samples) {
|
||||||
|
for (size_t i = 0; i < n_samples; i++) {
|
||||||
|
outputs[0][i] = instance->bypass ? inputs[0][i] : instance->gain * inputs[0][i];
|
||||||
|
}
|
||||||
|
}
|
@ -2,4 +2,6 @@
|
|||||||
|
|
||||||
dir=`dirname $0`
|
dir=`dirname $0`
|
||||||
$dir/../tibia $dir/product.json,$dir/company.json,$dir/vst3.json $dir/../templates/vst3 $dir/../out/vst3
|
$dir/../tibia $dir/product.json,$dir/company.json,$dir/vst3.json $dir/../templates/vst3 $dir/../out/vst3
|
||||||
|
cp $dir/plugin.h $dir/../out/vst3/src
|
||||||
$dir/../tibia $dir/product.json,$dir/company.json,$dir/lv2.json $dir/../templates/lv2 $dir/../out/lv2
|
$dir/../tibia $dir/product.json,$dir/company.json,$dir/lv2.json $dir/../templates/lv2 $dir/../out/lv2
|
||||||
|
cp $dir/plugin.h $dir/../out/lv2/src
|
||||||
|
Loading…
Reference in New Issue
Block a user