Compare commits

...

2 Commits

Author SHA1 Message Date
Christopher Arndt 9474b4481e feat: add parameter range support
Signed-off-by: Christopher Arndt <chris@chrisarndt.de>
2024-10-16 17:21:45 +02:00
Christopher Arndt b37954a27b fix: use FAUSTFLOAT macro in Nim faust wrapper
Signed-off-by: Christopher Arndt <chris@chrisarndt.de>
2024-10-16 17:21:39 +02:00
5 changed files with 40 additions and 21 deletions

View File

@ -3,14 +3,14 @@
// This file was generated using the Faust compiler (https://faust.grame.fr),
// and the Faust post-processor (https://github.com/SpotlightKid/faustpp).
//
// Source: lpf.dsp
// Source: faustlpf.dsp
// Name: FaustLPF
// Author: Christopher Arndt
// Copyright: Christopher Arndt, 2024
// License: MIT
// Version: 0.1.0
// FAUST version: 2.75.10
// FAUST compilation options: -a /home/chris/tmp/tmp9v2ck7tz.c -lang c -rui -ct 1 -fm def -cn faustlpf -es 1 -mcd 16 -mdd 1024 -mdy 33 -single -ftz 0 -vec -lv 0 -vs 32
// FAUST compilation options: -a /home/chris/tmp/tmpebxwoqng.c -lang c -rui -ct 1 -fm def -cn faustlpf -es 1 -mcd 16 -mdd 1024 -mdy 33 -single -ftz 0 -vec -lv 0 -vs 32
//------------------------------------------------------------------------------
@ -79,9 +79,9 @@ void deletefaustlpf(faustlpf* dsp) {
void metadatafaustlpf(MetaGlue* m) {
m->declare(m->metaInterface, "author", "Christopher Arndt");
m->declare(m->metaInterface, "compile_options", "-a /home/chris/tmp/tmp9v2ck7tz.c -lang c -rui -ct 1 -fm def -cn faustlpf -es 1 -mcd 16 -mdd 1024 -mdy 33 -single -ftz 0 -vec -lv 0 -vs 32");
m->declare(m->metaInterface, "compile_options", "-a /home/chris/tmp/tmpebxwoqng.c -lang c -rui -ct 1 -fm def -cn faustlpf -es 1 -mcd 16 -mdd 1024 -mdy 33 -single -ftz 0 -vec -lv 0 -vs 32");
m->declare(m->metaInterface, "copyright", "Christopher Arndt, 2024");
m->declare(m->metaInterface, "filename", "lpf.dsp");
m->declare(m->metaInterface, "filename", "faustlpf.dsp");
m->declare(m->metaInterface, "filters.lib/fir:author", "Julius O. Smith III");
m->declare(m->metaInterface, "filters.lib/fir:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>");
m->declare(m->metaInterface, "filters.lib/fir:license", "MIT-style STK-4.3 license");

View File

@ -47,6 +47,11 @@ void initfaustlpf(faustlpf* dsp, int sample_rate);
void buildUserInterfacefaustlpf(faustlpf* dsp, UIGlue* ui_interface);
void computefaustlpf(faustlpf* dsp, int count, FAUSTFLOAT** RESTRICT inputs, FAUSTFLOAT** RESTRICT outputs);
typedef struct {
FAUSTFLOAT init;
FAUSTFLOAT min;
FAUSTFLOAT max;
} ParameterRange;
int parameter_group(unsigned index) {
switch (index) {
@ -106,20 +111,31 @@ const char *parameter_symbol(unsigned index) {
const char *parameter_unit(unsigned index) {
switch (index) {
case 0:
return "Hz";
default:
return 0;
}
}
const ParameterRange *parameter_range(unsigned index) {
switch (index) {
case 0: {
static const ParameterRange range = { 15000.0, 16.0, 15000.0 };
return &range;
}
default:
return 0;
}
}
bool parameter_is_trigger(unsigned index) {
switch (index) {
default:
return false;
}
@ -127,7 +143,7 @@ bool parameter_is_trigger(unsigned index) {
bool parameter_is_boolean(unsigned index) {
switch (index) {
default:
return false;
}
@ -135,7 +151,7 @@ bool parameter_is_boolean(unsigned index) {
bool parameter_is_enum(unsigned index) {
switch (index) {
default:
return false;
}
@ -143,7 +159,7 @@ bool parameter_is_enum(unsigned index) {
bool parameter_is_integer(unsigned index) {
switch (index) {
default:
return false;
}
@ -151,34 +167,34 @@ bool parameter_is_integer(unsigned index) {
bool parameter_is_logarithmic(unsigned index) {
switch (index) {
case 0:
return true;
default:
return false;
}
}
float get_parameter(faustlpf* dsp, unsigned index) {
FAUSTFLOAT get_parameter(faustlpf* dsp, unsigned index) {
switch (index) {
case 0:
return dsp->fHslider0;
default:
(void)dsp;
return 0.0;
}
}
void set_parameter(faustlpf* dsp, unsigned index, float value) {
void set_parameter(faustlpf* dsp, unsigned index, FAUSTFLOAT value) {
switch (index) {
case 0:
dsp->fHslider0 = value;
break;
default:
(void)dsp;
(void)value;
@ -187,12 +203,12 @@ void set_parameter(faustlpf* dsp, unsigned index, float value) {
}
float get_cutoff(faustlpf* dsp) {
FAUSTFLOAT get_cutoff(faustlpf* dsp) {
return dsp->fHslider0;
}
void set_cutoff(faustlpf* dsp, float value) {
void set_cutoff(faustlpf* dsp, FAUSTFLOAT value) {
dsp->fHslider0 = value;
}

View File

@ -2,6 +2,8 @@
type
faustlpf* = object
ParameterRange* = object
init*, min*, max*: cfloat
SampleBuffer* = UncheckedArray[cfloat]
@ -11,6 +13,7 @@ proc initfaustlpf*(dsp: ptr faustlpf, sample_rate: cint) {.importc.}
proc instanceClearfaustlpf*(dsp: ptr faustlpf) {.importc.}
proc computefaustlpf*(dsp: ptr faustlpf, count: cint, inputs, outputs: ptr ptr SampleBuffer) {.importc.}
proc parameter_range*(index: cuint): ptr ParameterRange {.importc.}
proc parameter_group*(index: cuint): cint {.importc}
proc parameter_is_boolean*(index: cuint): bool {.importc}
proc parameter_is_enum*(index: cuint): bool {.importc}

View File

@ -50,7 +50,7 @@ proc activate(instance: Lv2Handle) {.cdecl.} =
proc run(instance: Lv2Handle; nSamples: cuint) {.cdecl.} =
let plug = cast[ptr FaustLPFPlugin](instance)
set_cutoff(plug.flt, plug.freq[])
plug.flt.set_cutoff(plug.freq[])
computefaustlpf(plug.flt, nSamples.cint, addr plug.input, addr plug.output)