feat: update faustlpf sources with faustdoctor

Signed-off-by: Christopher Arndt <chris@chrisarndt.de>
This commit is contained in:
Christopher Arndt 2024-11-25 15:26:40 +01:00
parent 9474b4481e
commit 29c20cb8fc
3 changed files with 299 additions and 326 deletions

View File

@ -1,7 +1,6 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// This file was generated using the Faust compiler (https://faust.grame.fr), // This file was generated using the Faust compiler (https://faust.grame.fr),
// and the Faust post-processor (https://github.com/SpotlightKid/faustpp). // and the Faust post-processor (https://github.com/SpotlightKid/faustdoctor).
// //
// Source: faustlpf.dsp // Source: faustlpf.dsp
// Name: FaustLPF // Name: FaustLPF
@ -9,22 +8,15 @@
// Copyright: Christopher Arndt, 2024 // Copyright: Christopher Arndt, 2024
// License: MIT // License: MIT
// Version: 0.1.0 // Version: 0.1.0
// FAUST version: 2.75.10 // FAUST version: 2.76.0
// 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 // FAUST compilation options: -a /home/chris/tmp/tmpnf8hapuk.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
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include "faustlpf.h" #include "faustlpf.h"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Begin the Faust code section // Begin the Faust code section
#if defined(__GNUC__) #if defined(__GNUC__)
# pragma GCC diagnostic push # pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wunused-parameter" # pragma GCC diagnostic ignored "-Wunused-parameter"
@ -54,7 +46,7 @@ extern "C" {
#include <stdlib.h> #include <stdlib.h>
static float faustlpf_faustpower2_f(float value) { static float faustlpf_faustpower2_f(float value) {
return value * value; return value * value;
} }
#ifndef FAUSTCLASS #ifndef FAUSTCLASS
@ -69,314 +61,314 @@ static float faustlpf_faustpower2_f(float value) {
faustlpf* newfaustlpf() { faustlpf* newfaustlpf() {
faustlpf* dsp = (faustlpf*)calloc(1, sizeof(faustlpf)); faustlpf* dsp = (faustlpf*)calloc(1, sizeof(faustlpf));
return dsp; return dsp;
} }
void deletefaustlpf(faustlpf* dsp) { void deletefaustlpf(faustlpf* dsp) {
free(dsp); free(dsp);
} }
void metadatafaustlpf(MetaGlue* m) { void metadatafaustlpf(MetaGlue* m) {
m->declare(m->metaInterface, "author", "Christopher Arndt"); m->declare(m->metaInterface, "author", "Christopher Arndt");
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, "compile_options", "-a /home/chris/tmp/tmpnf8hapuk.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, "copyright", "Christopher Arndt, 2024");
m->declare(m->metaInterface, "filename", "faustlpf.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: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: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"); m->declare(m->metaInterface, "filters.lib/fir:license", "MIT-style STK-4.3 license");
m->declare(m->metaInterface, "filters.lib/iir:author", "Julius O. Smith III"); m->declare(m->metaInterface, "filters.lib/iir:author", "Julius O. Smith III");
m->declare(m->metaInterface, "filters.lib/iir:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>"); m->declare(m->metaInterface, "filters.lib/iir:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>");
m->declare(m->metaInterface, "filters.lib/iir:license", "MIT-style STK-4.3 license"); m->declare(m->metaInterface, "filters.lib/iir:license", "MIT-style STK-4.3 license");
m->declare(m->metaInterface, "filters.lib/lowpass0_highpass1", "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>"); m->declare(m->metaInterface, "filters.lib/lowpass0_highpass1", "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>");
m->declare(m->metaInterface, "filters.lib/lowpass0_highpass1:author", "Julius O. Smith III"); m->declare(m->metaInterface, "filters.lib/lowpass0_highpass1:author", "Julius O. Smith III");
m->declare(m->metaInterface, "filters.lib/lowpass:author", "Julius O. Smith III"); m->declare(m->metaInterface, "filters.lib/lowpass:author", "Julius O. Smith III");
m->declare(m->metaInterface, "filters.lib/lowpass:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>"); m->declare(m->metaInterface, "filters.lib/lowpass:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>");
m->declare(m->metaInterface, "filters.lib/lowpass:license", "MIT-style STK-4.3 license"); m->declare(m->metaInterface, "filters.lib/lowpass:license", "MIT-style STK-4.3 license");
m->declare(m->metaInterface, "filters.lib/name", "Faust Filters Library"); m->declare(m->metaInterface, "filters.lib/name", "Faust Filters Library");
m->declare(m->metaInterface, "filters.lib/tf2:author", "Julius O. Smith III"); m->declare(m->metaInterface, "filters.lib/tf2:author", "Julius O. Smith III");
m->declare(m->metaInterface, "filters.lib/tf2:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>"); m->declare(m->metaInterface, "filters.lib/tf2:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>");
m->declare(m->metaInterface, "filters.lib/tf2:license", "MIT-style STK-4.3 license"); m->declare(m->metaInterface, "filters.lib/tf2:license", "MIT-style STK-4.3 license");
m->declare(m->metaInterface, "filters.lib/tf2s:author", "Julius O. Smith III"); m->declare(m->metaInterface, "filters.lib/tf2s:author", "Julius O. Smith III");
m->declare(m->metaInterface, "filters.lib/tf2s:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>"); m->declare(m->metaInterface, "filters.lib/tf2s:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>");
m->declare(m->metaInterface, "filters.lib/tf2s:license", "MIT-style STK-4.3 license"); m->declare(m->metaInterface, "filters.lib/tf2s:license", "MIT-style STK-4.3 license");
m->declare(m->metaInterface, "filters.lib/version", "1.3.0"); m->declare(m->metaInterface, "filters.lib/version", "1.3.0");
m->declare(m->metaInterface, "license", "MIT"); m->declare(m->metaInterface, "license", "MIT");
m->declare(m->metaInterface, "maths.lib/author", "GRAME"); m->declare(m->metaInterface, "maths.lib/author", "GRAME");
m->declare(m->metaInterface, "maths.lib/copyright", "GRAME"); m->declare(m->metaInterface, "maths.lib/copyright", "GRAME");
m->declare(m->metaInterface, "maths.lib/license", "LGPL with exception"); m->declare(m->metaInterface, "maths.lib/license", "LGPL with exception");
m->declare(m->metaInterface, "maths.lib/name", "Faust Math Library"); m->declare(m->metaInterface, "maths.lib/name", "Faust Math Library");
m->declare(m->metaInterface, "maths.lib/version", "2.8.0"); m->declare(m->metaInterface, "maths.lib/version", "2.8.0");
m->declare(m->metaInterface, "name", "FaustLPF"); m->declare(m->metaInterface, "name", "FaustLPF");
m->declare(m->metaInterface, "platform.lib/name", "Generic Platform Library"); m->declare(m->metaInterface, "platform.lib/name", "Generic Platform Library");
m->declare(m->metaInterface, "platform.lib/version", "1.3.0"); m->declare(m->metaInterface, "platform.lib/version", "1.3.0");
m->declare(m->metaInterface, "signals.lib/name", "Faust Signal Routing Library"); m->declare(m->metaInterface, "signals.lib/name", "Faust Signal Routing Library");
m->declare(m->metaInterface, "signals.lib/version", "1.6.0"); m->declare(m->metaInterface, "signals.lib/version", "1.6.0");
m->declare(m->metaInterface, "version", "0.1.0"); m->declare(m->metaInterface, "version", "0.1.0");
} }
int getSampleRatefaustlpf(faustlpf* RESTRICT dsp) { int getSampleRatefaustlpf(faustlpf* RESTRICT dsp) {
return dsp->fSampleRate; return dsp->fSampleRate;
} }
int getNumInputsfaustlpf(faustlpf* RESTRICT dsp) { int getNumInputsfaustlpf(faustlpf* RESTRICT dsp) {
return 1; return 1;
} }
int getNumOutputsfaustlpf(faustlpf* RESTRICT dsp) { int getNumOutputsfaustlpf(faustlpf* RESTRICT dsp) {
return 1; return 1;
} }
void classInitfaustlpf(int sample_rate) { void classInitfaustlpf(int sample_rate) {
} }
void instanceResetUserInterfacefaustlpf(faustlpf* dsp) { void instanceResetUserInterfacefaustlpf(faustlpf* dsp) {
dsp->fHslider0 = (FAUSTFLOAT)(1.5e+04f); dsp->fHslider0 = (FAUSTFLOAT)(1.5e+04f);
} }
void instanceClearfaustlpf(faustlpf* dsp) { void instanceClearfaustlpf(faustlpf* dsp) {
/* C99 loop */ /* C99 loop */
{ {
int l0; int l0;
for (l0 = 0; l0 < 4; l0 = l0 + 1) { for (l0 = 0; l0 < 4; l0 = l0 + 1) {
dsp->fRec1_perm[l0] = 0.0f; dsp->fRec1_perm[l0] = 0.0f;
} }
} }
/* C99 loop */ /* C99 loop */
{ {
int l1; int l1;
for (l1 = 0; l1 < 4; l1 = l1 + 1) { for (l1 = 0; l1 < 4; l1 = l1 + 1) {
dsp->fRec0_perm[l1] = 0.0f; dsp->fRec0_perm[l1] = 0.0f;
} }
} }
} }
void instanceConstantsfaustlpf(faustlpf* dsp, int sample_rate) { void instanceConstantsfaustlpf(faustlpf* dsp, int sample_rate) {
dsp->fSampleRate = sample_rate; dsp->fSampleRate = sample_rate;
dsp->fConst0 = fminf(1.92e+05f, fmaxf(1.0f, (float)(dsp->fSampleRate))); dsp->fConst0 = fminf(1.92e+05f, fmaxf(1.0f, (float)(dsp->fSampleRate)));
dsp->fConst1 = 44.1f / dsp->fConst0; dsp->fConst1 = 44.1f / dsp->fConst0;
dsp->fConst2 = 1.0f - dsp->fConst1; dsp->fConst2 = 1.0f - dsp->fConst1;
dsp->fConst3 = 3.1415927f / dsp->fConst0; dsp->fConst3 = 3.1415927f / dsp->fConst0;
} }
void instanceInitfaustlpf(faustlpf* dsp, int sample_rate) { void instanceInitfaustlpf(faustlpf* dsp, int sample_rate) {
instanceConstantsfaustlpf(dsp, sample_rate); instanceConstantsfaustlpf(dsp, sample_rate);
instanceResetUserInterfacefaustlpf(dsp); instanceResetUserInterfacefaustlpf(dsp);
instanceClearfaustlpf(dsp); instanceClearfaustlpf(dsp);
} }
void initfaustlpf(faustlpf* dsp, int sample_rate) { void initfaustlpf(faustlpf* dsp, int sample_rate) {
classInitfaustlpf(sample_rate); classInitfaustlpf(sample_rate);
instanceInitfaustlpf(dsp, sample_rate); instanceInitfaustlpf(dsp, sample_rate);
} }
void buildUserInterfacefaustlpf(faustlpf* dsp, UIGlue* ui_interface) { void buildUserInterfacefaustlpf(faustlpf* dsp, UIGlue* ui_interface) {
ui_interface->openVerticalBox(ui_interface->uiInterface, "FaustLPF"); ui_interface->openVerticalBox(ui_interface->uiInterface, "FaustLPF");
ui_interface->declare(ui_interface->uiInterface, &dsp->fHslider0, "1", ""); ui_interface->declare(ui_interface->uiInterface, &dsp->fHslider0, "1", "");
ui_interface->declare(ui_interface->uiInterface, &dsp->fHslider0, "scale", "log"); ui_interface->declare(ui_interface->uiInterface, &dsp->fHslider0, "scale", "log");
ui_interface->declare(ui_interface->uiInterface, &dsp->fHslider0, "style", "knob"); ui_interface->declare(ui_interface->uiInterface, &dsp->fHslider0, "style", "knob");
ui_interface->declare(ui_interface->uiInterface, &dsp->fHslider0, "symbol", "cutoff"); ui_interface->declare(ui_interface->uiInterface, &dsp->fHslider0, "symbol", "cutoff");
ui_interface->declare(ui_interface->uiInterface, &dsp->fHslider0, "tooltip", "Low-pass filter cutoff frequency"); ui_interface->declare(ui_interface->uiInterface, &dsp->fHslider0, "tooltip", "Low-pass filter cutoff frequency");
ui_interface->declare(ui_interface->uiInterface, &dsp->fHslider0, "unit", "Hz"); ui_interface->declare(ui_interface->uiInterface, &dsp->fHslider0, "unit", "Hz");
ui_interface->addHorizontalSlider(ui_interface->uiInterface, "Cutoff", &dsp->fHslider0, (FAUSTFLOAT)1.5e+04f, (FAUSTFLOAT)16.0f, (FAUSTFLOAT)1.5e+04f, (FAUSTFLOAT)0.1f); ui_interface->addHorizontalSlider(ui_interface->uiInterface, "Cutoff", &dsp->fHslider0, (FAUSTFLOAT)1.5e+04f, (FAUSTFLOAT)16.0f, (FAUSTFLOAT)1.5e+04f, (FAUSTFLOAT)0.1f);
ui_interface->closeBox(ui_interface->uiInterface); ui_interface->closeBox(ui_interface->uiInterface);
} }
void computefaustlpf(faustlpf* dsp, int count, FAUSTFLOAT** RESTRICT inputs, FAUSTFLOAT** RESTRICT outputs) { void computefaustlpf(faustlpf* dsp, int count, FAUSTFLOAT** RESTRICT inputs, FAUSTFLOAT** RESTRICT outputs) {
FAUSTFLOAT* input0_ptr = inputs[0]; FAUSTFLOAT* input0_ptr = inputs[0];
FAUSTFLOAT* output0_ptr = outputs[0]; FAUSTFLOAT* output0_ptr = outputs[0];
float fSlow0 = dsp->fConst1 * fmaxf(16.0f, fminf(1.5e+04f, (float)(dsp->fHslider0))); float fSlow0 = dsp->fConst1 * fmaxf(16.0f, fminf(1.5e+04f, (float)(dsp->fHslider0)));
float fRec1_tmp[36]; float fRec1_tmp[36];
float* fRec1 = &fRec1_tmp[4]; float* fRec1 = &fRec1_tmp[4];
float fZec0[32]; float fZec0[32];
float fZec1[32]; float fZec1[32];
float fZec2[32]; float fZec2[32];
float fRec0_tmp[36]; float fRec0_tmp[36];
float* fRec0 = &fRec0_tmp[4]; float* fRec0 = &fRec0_tmp[4];
int vindex = 0; int vindex = 0;
/* Main loop */ /* Main loop */
for (vindex = 0; vindex <= (count - 32); vindex = vindex + 32) { for (vindex = 0; vindex <= (count - 32); vindex = vindex + 32) {
FAUSTFLOAT* input0 = &input0_ptr[vindex]; FAUSTFLOAT* input0 = &input0_ptr[vindex];
FAUSTFLOAT* output0 = &output0_ptr[vindex]; FAUSTFLOAT* output0 = &output0_ptr[vindex];
int vsize = 32; int vsize = 32;
/* Recursive loop 0 */ /* Recursive loop 0 */
/* Pre code */ /* Pre code */
/* C99 loop */ /* C99 loop */
{ {
int j0; int j0;
for (j0 = 0; j0 < 4; j0 = j0 + 1) { for (j0 = 0; j0 < 4; j0 = j0 + 1) {
fRec1_tmp[j0] = dsp->fRec1_perm[j0]; fRec1_tmp[j0] = dsp->fRec1_perm[j0];
} }
} }
/* Compute code */ /* Compute code */
/* C99 loop */ /* C99 loop */
{ {
int i; int i;
for (i = 0; i < vsize; i = i + 1) { for (i = 0; i < vsize; i = i + 1) {
fRec1[i] = fSlow0 + dsp->fConst2 * fRec1[i - 1]; fRec1[i] = fSlow0 + dsp->fConst2 * fRec1[i - 1];
} }
} }
/* Post code */ /* Post code */
/* C99 loop */ /* C99 loop */
{ {
int j1; int j1;
for (j1 = 0; j1 < 4; j1 = j1 + 1) { for (j1 = 0; j1 < 4; j1 = j1 + 1) {
dsp->fRec1_perm[j1] = fRec1_tmp[vsize + j1]; dsp->fRec1_perm[j1] = fRec1_tmp[vsize + j1];
} }
} }
/* Vectorizable loop 1 */ /* Vectorizable loop 1 */
/* Compute code */ /* Compute code */
/* C99 loop */ /* C99 loop */
{ {
int i; int i;
for (i = 0; i < vsize; i = i + 1) { for (i = 0; i < vsize; i = i + 1) {
fZec0[i] = fast_tanf(dsp->fConst3 * fRec1[i]); fZec0[i] = fast_tanf(dsp->fConst3 * fRec1[i]);
} }
} }
/* Vectorizable loop 2 */ /* Vectorizable loop 2 */
/* Compute code */ /* Compute code */
/* C99 loop */ /* C99 loop */
{ {
int i; int i;
for (i = 0; i < vsize; i = i + 1) { for (i = 0; i < vsize; i = i + 1) {
fZec1[i] = 1.0f / fZec0[i]; fZec1[i] = 1.0f / fZec0[i];
} }
} }
/* Vectorizable loop 3 */ /* Vectorizable loop 3 */
/* Compute code */ /* Compute code */
/* C99 loop */ /* C99 loop */
{ {
int i; int i;
for (i = 0; i < vsize; i = i + 1) { for (i = 0; i < vsize; i = i + 1) {
fZec2[i] = (fZec1[i] + 1.4142135f) / fZec0[i] + 1.0f; fZec2[i] = (fZec1[i] + 1.4142135f) / fZec0[i] + 1.0f;
} }
} }
/* Recursive loop 4 */ /* Recursive loop 4 */
/* Pre code */ /* Pre code */
/* C99 loop */ /* C99 loop */
{ {
int j2; int j2;
for (j2 = 0; j2 < 4; j2 = j2 + 1) { for (j2 = 0; j2 < 4; j2 = j2 + 1) {
fRec0_tmp[j2] = dsp->fRec0_perm[j2]; fRec0_tmp[j2] = dsp->fRec0_perm[j2];
} }
} }
/* Compute code */ /* Compute code */
/* C99 loop */ /* C99 loop */
{ {
int i; int i;
for (i = 0; i < vsize; i = i + 1) { for (i = 0; i < vsize; i = i + 1) {
fRec0[i] = (float)(input0[i]) - (fRec0[i - 2] * ((fZec1[i] + -1.4142135f) / fZec0[i] + 1.0f) + 2.0f * fRec0[i - 1] * (1.0f - 1.0f / faustlpf_faustpower2_f(fZec0[i]))) / fZec2[i]; fRec0[i] = (float)(input0[i]) - (fRec0[i - 2] * ((fZec1[i] + -1.4142135f) / fZec0[i] + 1.0f) + 2.0f * fRec0[i - 1] * (1.0f - 1.0f / faustlpf_faustpower2_f(fZec0[i]))) / fZec2[i];
} }
} }
/* Post code */ /* Post code */
/* C99 loop */ /* C99 loop */
{ {
int j3; int j3;
for (j3 = 0; j3 < 4; j3 = j3 + 1) { for (j3 = 0; j3 < 4; j3 = j3 + 1) {
dsp->fRec0_perm[j3] = fRec0_tmp[vsize + j3]; dsp->fRec0_perm[j3] = fRec0_tmp[vsize + j3];
} }
} }
/* Vectorizable loop 5 */ /* Vectorizable loop 5 */
/* Compute code */ /* Compute code */
/* C99 loop */ /* C99 loop */
{ {
int i; int i;
for (i = 0; i < vsize; i = i + 1) { for (i = 0; i < vsize; i = i + 1) {
output0[i] = (FAUSTFLOAT)((fRec0[i - 2] + fRec0[i] + 2.0f * fRec0[i - 1]) / fZec2[i]); output0[i] = (FAUSTFLOAT)((fRec0[i - 2] + fRec0[i] + 2.0f * fRec0[i - 1]) / fZec2[i]);
} }
} }
} }
/* Remaining frames */ /* Remaining frames */
if (vindex < count) { if (vindex < count) {
FAUSTFLOAT* input0 = &input0_ptr[vindex]; FAUSTFLOAT* input0 = &input0_ptr[vindex];
FAUSTFLOAT* output0 = &output0_ptr[vindex]; FAUSTFLOAT* output0 = &output0_ptr[vindex];
int vsize = count - vindex; int vsize = count - vindex;
/* Recursive loop 0 */ /* Recursive loop 0 */
/* Pre code */ /* Pre code */
/* C99 loop */ /* C99 loop */
{ {
int j0; int j0;
for (j0 = 0; j0 < 4; j0 = j0 + 1) { for (j0 = 0; j0 < 4; j0 = j0 + 1) {
fRec1_tmp[j0] = dsp->fRec1_perm[j0]; fRec1_tmp[j0] = dsp->fRec1_perm[j0];
} }
} }
/* Compute code */ /* Compute code */
/* C99 loop */ /* C99 loop */
{ {
int i; int i;
for (i = 0; i < vsize; i = i + 1) { for (i = 0; i < vsize; i = i + 1) {
fRec1[i] = fSlow0 + dsp->fConst2 * fRec1[i - 1]; fRec1[i] = fSlow0 + dsp->fConst2 * fRec1[i - 1];
} }
} }
/* Post code */ /* Post code */
/* C99 loop */ /* C99 loop */
{ {
int j1; int j1;
for (j1 = 0; j1 < 4; j1 = j1 + 1) { for (j1 = 0; j1 < 4; j1 = j1 + 1) {
dsp->fRec1_perm[j1] = fRec1_tmp[vsize + j1]; dsp->fRec1_perm[j1] = fRec1_tmp[vsize + j1];
} }
} }
/* Vectorizable loop 1 */ /* Vectorizable loop 1 */
/* Compute code */ /* Compute code */
/* C99 loop */ /* C99 loop */
{ {
int i; int i;
for (i = 0; i < vsize; i = i + 1) { for (i = 0; i < vsize; i = i + 1) {
fZec0[i] = fast_tanf(dsp->fConst3 * fRec1[i]); fZec0[i] = fast_tanf(dsp->fConst3 * fRec1[i]);
} }
} }
/* Vectorizable loop 2 */ /* Vectorizable loop 2 */
/* Compute code */ /* Compute code */
/* C99 loop */ /* C99 loop */
{ {
int i; int i;
for (i = 0; i < vsize; i = i + 1) { for (i = 0; i < vsize; i = i + 1) {
fZec1[i] = 1.0f / fZec0[i]; fZec1[i] = 1.0f / fZec0[i];
} }
} }
/* Vectorizable loop 3 */ /* Vectorizable loop 3 */
/* Compute code */ /* Compute code */
/* C99 loop */ /* C99 loop */
{ {
int i; int i;
for (i = 0; i < vsize; i = i + 1) { for (i = 0; i < vsize; i = i + 1) {
fZec2[i] = (fZec1[i] + 1.4142135f) / fZec0[i] + 1.0f; fZec2[i] = (fZec1[i] + 1.4142135f) / fZec0[i] + 1.0f;
} }
} }
/* Recursive loop 4 */ /* Recursive loop 4 */
/* Pre code */ /* Pre code */
/* C99 loop */ /* C99 loop */
{ {
int j2; int j2;
for (j2 = 0; j2 < 4; j2 = j2 + 1) { for (j2 = 0; j2 < 4; j2 = j2 + 1) {
fRec0_tmp[j2] = dsp->fRec0_perm[j2]; fRec0_tmp[j2] = dsp->fRec0_perm[j2];
} }
} }
/* Compute code */ /* Compute code */
/* C99 loop */ /* C99 loop */
{ {
int i; int i;
for (i = 0; i < vsize; i = i + 1) { for (i = 0; i < vsize; i = i + 1) {
fRec0[i] = (float)(input0[i]) - (fRec0[i - 2] * ((fZec1[i] + -1.4142135f) / fZec0[i] + 1.0f) + 2.0f * fRec0[i - 1] * (1.0f - 1.0f / faustlpf_faustpower2_f(fZec0[i]))) / fZec2[i]; fRec0[i] = (float)(input0[i]) - (fRec0[i - 2] * ((fZec1[i] + -1.4142135f) / fZec0[i] + 1.0f) + 2.0f * fRec0[i - 1] * (1.0f - 1.0f / faustlpf_faustpower2_f(fZec0[i]))) / fZec2[i];
} }
} }
/* Post code */ /* Post code */
/* C99 loop */ /* C99 loop */
{ {
int j3; int j3;
for (j3 = 0; j3 < 4; j3 = j3 + 1) { for (j3 = 0; j3 < 4; j3 = j3 + 1) {
dsp->fRec0_perm[j3] = fRec0_tmp[vsize + j3]; dsp->fRec0_perm[j3] = fRec0_tmp[vsize + j3];
} }
} }
/* Vectorizable loop 5 */ /* Vectorizable loop 5 */
/* Compute code */ /* Compute code */
/* C99 loop */ /* C99 loop */
{ {
int i; int i;
for (i = 0; i < vsize; i = i + 1) { for (i = 0; i < vsize; i = i + 1) {
output0[i] = (FAUSTFLOAT)((fRec0[i - 2] + fRec0[i] + 2.0f * fRec0[i - 1]) / fZec2[i]); output0[i] = (FAUSTFLOAT)((fRec0[i - 2] + fRec0[i] + 2.0f * fRec0[i - 1]) / fZec2[i]);
} }
} }
} }
} }
#ifdef __cplusplus #ifdef __cplusplus
@ -389,8 +381,6 @@ void computefaustlpf(faustlpf* dsp, int count, FAUSTFLOAT** RESTRICT inputs, FAU
# pragma GCC diagnostic pop # pragma GCC diagnostic pop
#endif #endif
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// End the Faust code section // End the Faust code section

View File

@ -1,3 +1,17 @@
//------------------------------------------------------------------------------
// This file was generated using the Faust compiler (https://faust.grame.fr),
// and the Faust post-processor (https://github.com/SpotlightKid/faustdoctor).
//
// Source: faustlpf.dsp
// Name: FaustLPF
// Author: Christopher Arndt
// Copyright: Christopher Arndt, 2024
// License: MIT
// Version: 0.1.0
// FAUST version: 2.76.0
// FAUST compilation options: -a /home/chris/tmp/tmpkjrmmie8.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
//------------------------------------------------------------------------------
#ifndef __faustlpf_H__ #ifndef __faustlpf_H__
#define __faustlpf_H__ #define __faustlpf_H__
@ -19,19 +33,17 @@
#include <stdint.h> #include <stdint.h>
#include "faust/gui/CInterface.h" #include "faust/gui/CInterface.h"
typedef struct { typedef struct {
int fSampleRate; int fSampleRate;
float fConst0; float fConst0;
float fConst1; float fConst1;
float fConst2; float fConst2;
FAUSTFLOAT fHslider0; FAUSTFLOAT fHslider0;
float fRec1_perm[4]; float fRec1_perm[4];
float fConst3; float fConst3;
float fRec0_perm[4]; float fRec0_perm[4];
} faustlpf; } faustlpf;
faustlpf* newfaustlpf(); faustlpf* newfaustlpf();
void deletefaustlpf(faustlpf* dsp); void deletefaustlpf(faustlpf* dsp);
void metadatafaustlpf(MetaGlue* m); void metadatafaustlpf(MetaGlue* m);
@ -55,10 +67,6 @@ typedef struct {
int parameter_group(unsigned index) { int parameter_group(unsigned index) {
switch (index) { switch (index) {
case 0:
return 0;
default: default:
return -1; return -1;
} }
@ -66,10 +74,8 @@ int parameter_group(unsigned index) {
const char *parameter_label(unsigned index) { const char *parameter_label(unsigned index) {
switch (index) { switch (index) {
case 0: case 0:
return "Cutoff"; return "Cutoff";
default: default:
return 0; return 0;
} }
@ -77,10 +83,8 @@ const char *parameter_label(unsigned index) {
const char *parameter_short_label(unsigned index) { const char *parameter_short_label(unsigned index) {
switch (index) { switch (index) {
case 0: case 0:
return "Cutoff"; return "Cutoff";
default: default:
return 0; return 0;
} }
@ -88,11 +92,9 @@ const char *parameter_short_label(unsigned index) {
const char *parameter_style(unsigned index) { const char *parameter_style(unsigned index) {
switch (index) { switch (index) {
case 0: { case 0: {
return "knob"; return "knob";
} }
default: default:
return ""; return "";
} }
@ -100,10 +102,8 @@ const char *parameter_style(unsigned index) {
const char *parameter_symbol(unsigned index) { const char *parameter_symbol(unsigned index) {
switch (index) { switch (index) {
case 0: case 0:
return "cutoff"; return "cutoff";
default: default:
return ""; return "";
} }
@ -111,10 +111,8 @@ const char *parameter_symbol(unsigned index) {
const char *parameter_unit(unsigned index) { const char *parameter_unit(unsigned index) {
switch (index) { switch (index) {
case 0: case 0:
return "Hz"; return "Hz";
default: default:
return 0; return 0;
} }
@ -122,12 +120,10 @@ const char *parameter_unit(unsigned index) {
const ParameterRange *parameter_range(unsigned index) { const ParameterRange *parameter_range(unsigned index) {
switch (index) { switch (index) {
case 0: { case 0: {
static const ParameterRange range = { 15000.0, 16.0, 15000.0 }; static const ParameterRange range = { 15000.0, 16.0, 15000.0 };
return &range; return &range;
} }
default: default:
return 0; return 0;
} }
@ -135,7 +131,6 @@ const ParameterRange *parameter_range(unsigned index) {
bool parameter_is_trigger(unsigned index) { bool parameter_is_trigger(unsigned index) {
switch (index) { switch (index) {
default: default:
return false; return false;
} }
@ -143,7 +138,6 @@ bool parameter_is_trigger(unsigned index) {
bool parameter_is_boolean(unsigned index) { bool parameter_is_boolean(unsigned index) {
switch (index) { switch (index) {
default: default:
return false; return false;
} }
@ -151,7 +145,6 @@ bool parameter_is_boolean(unsigned index) {
bool parameter_is_enum(unsigned index) { bool parameter_is_enum(unsigned index) {
switch (index) { switch (index) {
default: default:
return false; return false;
} }
@ -159,7 +152,6 @@ bool parameter_is_enum(unsigned index) {
bool parameter_is_integer(unsigned index) { bool parameter_is_integer(unsigned index) {
switch (index) { switch (index) {
default: default:
return false; return false;
} }
@ -167,10 +159,8 @@ bool parameter_is_integer(unsigned index) {
bool parameter_is_logarithmic(unsigned index) { bool parameter_is_logarithmic(unsigned index) {
switch (index) { switch (index) {
case 0: case 0:
return true; return true;
default: default:
return false; return false;
} }
@ -178,10 +168,8 @@ bool parameter_is_logarithmic(unsigned index) {
FAUSTFLOAT get_parameter(faustlpf* dsp, unsigned index) { FAUSTFLOAT get_parameter(faustlpf* dsp, unsigned index) {
switch (index) { switch (index) {
case 0: case 0:
return dsp->fHslider0; return dsp->fHslider0;
default: default:
(void)dsp; (void)dsp;
return 0.0; return 0.0;
@ -190,11 +178,9 @@ FAUSTFLOAT get_parameter(faustlpf* dsp, unsigned index) {
void set_parameter(faustlpf* dsp, unsigned index, FAUSTFLOAT value) { void set_parameter(faustlpf* dsp, unsigned index, FAUSTFLOAT value) {
switch (index) { switch (index) {
case 0: case 0:
dsp->fHslider0 = value; dsp->fHslider0 = value;
break; break;
default: default:
(void)dsp; (void)dsp;
(void)value; (void)value;
@ -202,12 +188,10 @@ void set_parameter(faustlpf* dsp, unsigned index, FAUSTFLOAT value) {
} }
} }
FAUSTFLOAT get_cutoff(faustlpf* dsp) { FAUSTFLOAT get_cutoff(faustlpf* dsp) {
return dsp->fHslider0; return dsp->fHslider0;
} }
void set_cutoff(faustlpf* dsp, FAUSTFLOAT value) { void set_cutoff(faustlpf* dsp, FAUSTFLOAT value) {
dsp->fHslider0 = value; dsp->fHslider0 = value;
} }

View File

@ -2,8 +2,10 @@
type type
faustlpf* = object faustlpf* = object
ParameterRange* = object ParameterRange* = object
init*, min*, max*: cfloat init*, min*, max*: cfloat
SampleBuffer* = UncheckedArray[cfloat] SampleBuffer* = UncheckedArray[cfloat]
@ -29,8 +31,5 @@ proc parameter_unit*(index: cuint): cstring {.importc}
proc get_parameter*(dsp: ptr faustlpf, index: cuint): cfloat {.importc} proc get_parameter*(dsp: ptr faustlpf, index: cuint): cfloat {.importc}
proc set_parameter*(dsp: ptr faustlpf, index: cuint, value: cfloat) {.importc} proc set_parameter*(dsp: ptr faustlpf, index: cuint, value: cfloat) {.importc}
proc get_cutoff*(dsp: ptr faustlpf): cfloat {.importc} proc get_cutoff*(dsp: ptr faustlpf): cfloat {.importc}
proc set_cutoff*(dsp: ptr faustlpf, value: cfloat) {.importc} proc set_cutoff*(dsp: ptr faustlpf, value: cfloat) {.importc}