From f40df2491ecc92628c7dd424d68f596ec33f8c71 Mon Sep 17 00:00:00 2001 From: Christopher Arndt Date: Sun, 29 Sep 2024 16:33:18 +0200 Subject: [PATCH] refactor: clean up faustlpf plugin Nim code a bit Signed-off-by: Christopher Arndt --- examples/faustlpf_plugin.nim | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/examples/faustlpf_plugin.nim b/examples/faustlpf_plugin.nim index 542e18d..657ef77 100644 --- a/examples/faustlpf_plugin.nim +++ b/examples/faustlpf_plugin.nim @@ -2,24 +2,21 @@ import nymph +{.emit: "#include \"lpf.h\"".} + +const + PluginUri = "urn:nymph:examples:faustlpf" + minFreq = 16.0 + maxFreq = 15_000.0 + type SampleBuffer = UncheckedArray[cfloat] -{.emit: "#include \"lpf.h\"".} -type - faustlpf {.importc, header: "lpf.h".}= object + faustlpf {.importc, header: "lpf.h".} = object + # struct field, which represents the value of the + # FAUST UI element, which controls the cutoff fHslider0: cfloat -proc newfaustlpf(): ptr faustlpf {.importc.} -proc deletefaustlpf(dsp: ptr faustlpf) {.importc.} -proc initfaustlpf(dsp: ptr faustlpf, sample_rate: cint) {.importc.} -proc instanceClearfaustlpf(dsp: ptr faustlpf) {.importc.} -#proc getNumInputsmydsp(dsp: ptr faustlpf): cint {.importc.} -#proc getNumOutputsmydsp(dsp: ptr faustlpf): cint {.importc.} -#proc getSampleRatefaustlpf(dsp: ptr faustlpf): cint {.importc.} -proc computefaustlpf(dsp: ptr faustlpf, count: cint, inputs, outputs: ptr ptr SampleBuffer) {.importc.} - -type PluginPort {.pure.} = enum Input, Output, Frequency @@ -30,10 +27,12 @@ type flt: ptr faustlpf -const - PluginUri = "urn:nymph:examples:faustlpf" - minFreq = 16.0 - maxFreq = 15_000.0 +# wrap only those functions from the C code, which we actually need +proc newfaustlpf(): ptr faustlpf {.importc.} +proc deletefaustlpf(dsp: ptr faustlpf) {.importc.} +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 instantiate(descriptor: ptr Lv2Descriptor; sampleRate: cdouble;