91 lines
1.7 KiB
C
91 lines
1.7 KiB
C
#include <stdint.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <math.h>
|
|
#include <lv2.h>
|
|
|
|
struct ducker
|
|
{
|
|
double sample_rate;
|
|
float on_factor;
|
|
float off_factor;
|
|
|
|
float *in_main_l;
|
|
float *in_main_r;
|
|
float *in_aux_l;
|
|
float *in_aux_r;
|
|
float *out_l;
|
|
float *out_r;
|
|
};
|
|
|
|
static LV2_Handle ducker_instantiate(
|
|
const LV2_Descriptor *descriptor,
|
|
double sample_rate,
|
|
const char *bundle_path,
|
|
const LV2_Feature *const *host_features)
|
|
{
|
|
/* Allocate local data */
|
|
struct ducker *d = malloc(sizeof *d);
|
|
if (d == NULL) {
|
|
return NULL;
|
|
}
|
|
|
|
memset(d, 0, sizeof *d);
|
|
|
|
d->sample_rate = sample_rate;
|
|
|
|
d->on_factor = 0.0006f * 44100.0f / sample_rate;
|
|
d->off_factor = 0.00028f * 44100.0f / sample_rate;
|
|
|
|
return (LV2_Handle)d;
|
|
}
|
|
|
|
static void ducker_connect_port(LV2_Handle lv2instance, uint32_t port, void *data)
|
|
{
|
|
struct ducker *d = (struct ducker *)lv2instance;
|
|
|
|
/* Audio ports */
|
|
switch (port) {
|
|
case 0: d->in_main_l = data; break;
|
|
case 1: d->in_main_r = data; break;
|
|
case 2: d->in_aux_l = data; break;
|
|
case 3: d->in_aux_r = data; break;
|
|
case 4: d->out_l = data; break;
|
|
case 5: d->out_r = data; break;
|
|
}
|
|
}
|
|
|
|
static void ducker_run(LV2_Handle lv2instance, uint32_t sample_count)
|
|
{
|
|
struct ducker *d = (struct ducker *)lv2instance;
|
|
|
|
while (sample_count--) {
|
|
}
|
|
}
|
|
|
|
static void ducker_cleanup(LV2_Handle lv2instance)
|
|
{
|
|
struct ducker *d = (struct ducker *)lv2instance;
|
|
|
|
free(d);
|
|
}
|
|
|
|
static const LV2_Descriptor s_lv2descriptor =
|
|
{
|
|
.URI = "http://fuzzle.org/~petern/ducker/1",
|
|
.instantiate = &ducker_instantiate,
|
|
.connect_port = &ducker_connect_port,
|
|
.run = &ducker_run,
|
|
.cleanup = &ducker_cleanup,
|
|
};
|
|
|
|
const LV2_Descriptor *lv2_descriptor(uint32_t index)
|
|
{
|
|
if (index == 0) {
|
|
return &s_lv2descriptor;
|
|
}
|
|
|
|
return NULL;
|
|
}
|