From fd7634671fec63c926e1dc326aad340c2b07da43 Mon Sep 17 00:00:00 2001 From: Gordon JC Pearce Date: Sat, 19 Oct 2024 19:49:39 +0100 Subject: [PATCH] add filter file --- plugin/filter.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 plugin/filter.cpp diff --git a/plugin/filter.cpp b/plugin/filter.cpp new file mode 100644 index 0000000..8c1cb11 --- /dev/null +++ b/plugin/filter.cpp @@ -0,0 +1,38 @@ +/* + Peacock-8 VA polysynth + + Copyright 2024 Gordon JC Pearce + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#include "ic29.hpp" + +void Voice::filter(float *buffer, uint32_t pos, uint32_t frames) { + for (uint32_t i = 0; i < frames; i++) { + for (uint8_t ovs = 0; ovs < 4; ovs++) { + fb = b4; + // hard clip + if (fb > 1) fb = 1; + if (fb < -1) fb = -1; + + fb = buffer[i+pos] - (fb * reso); + b1 = ((fb - b1) * cut) + b1; + b2 = ((b1 - b2) * cut) + b2; + b3 = ((b2 - b3) * cut) + b3; + b4 = ((b3 - b4) * cut) + b4; + } + + buffer[i+pos] = b4; + } +} \ No newline at end of file