From 5f2a413b4d7aff2f8e3c4a831c17f4de16cede6c Mon Sep 17 00:00:00 2001 From: Stefano D'Angelo Date: Wed, 13 Mar 2024 12:28:35 +0100 Subject: [PATCH] add gate param to bw_bd_reduce and examples + fix fxpp_bitcrush --- examples/fx_bitcrush/src/cmd.json | 2 +- examples/fx_bitcrush/src/lv2.json | 2 +- examples/fx_bitcrush/src/plugin.h | 3 + examples/fx_bitcrush/src/product.json | 10 +++ examples/fxpp_bitcrush/src/cmd.json | 2 +- examples/fxpp_bitcrush/src/impl.cpp | 5 +- examples/fxpp_bitcrush/src/lv2.json | 2 +- examples/fxpp_bitcrush/src/product.json | 10 +++ include/bw_bd_reduce.h | 88 ++++++++++++++++++++++++- 9 files changed, 117 insertions(+), 7 deletions(-) diff --git a/examples/fx_bitcrush/src/cmd.json b/examples/fx_bitcrush/src/cmd.json index 437bda7..3e0d454 100644 --- a/examples/fx_bitcrush/src/cmd.json +++ b/examples/fx_bitcrush/src/cmd.json @@ -1,6 +1,6 @@ { "cmd": { "busIds": [ "input", "output" ], - "parameterIds": [ "sr_ratio", "bit_depth" ] + "parameterIds": [ "sr_ratio", "bit_depth", "gate" ] } } diff --git a/examples/fx_bitcrush/src/lv2.json b/examples/fx_bitcrush/src/lv2.json index a587bb6..dc91929 100644 --- a/examples/fx_bitcrush/src/lv2.json +++ b/examples/fx_bitcrush/src/lv2.json @@ -7,6 +7,6 @@ "types": [ "@lv2:DistortionPlugin" ], "version": "0.0", "busSymbols": [ "input", "output" ], - "parameterSymbols": [ "sr_ratio", "bit_depth" ] + "parameterSymbols": [ "sr_ratio", "bit_depth", "gate" ] } } diff --git a/examples/fx_bitcrush/src/plugin.h b/examples/fx_bitcrush/src/plugin.h index 68c06af..f5b29b6 100644 --- a/examples/fx_bitcrush/src/plugin.h +++ b/examples/fx_bitcrush/src/plugin.h @@ -67,6 +67,9 @@ static void plugin_set_parameter(plugin *instance, size_t index, float value) { case 1: bw_bd_reduce_set_bit_depth(&instance->bd_reduce_coeffs, (char)value); break; + case 2: + bw_bd_reduce_set_gate_lin(&instance->bd_reduce_coeffs, value); + break; } } diff --git a/examples/fx_bitcrush/src/product.json b/examples/fx_bitcrush/src/product.json index f9955a2..eca7438 100644 --- a/examples/fx_bitcrush/src/product.json +++ b/examples/fx_bitcrush/src/product.json @@ -40,6 +40,16 @@ "maximum": 16.0, "integer": true, "map": "linear" + }, + { + "name": "Gate", + "shortName": "Gate", + "direction": "input", + "defaultValue": 0.0, + "minimum": 0.0, + "maximum": 1.0, + "optional": true, + "map": "linear" } ] } diff --git a/examples/fxpp_bitcrush/src/cmd.json b/examples/fxpp_bitcrush/src/cmd.json index 437bda7..3e0d454 100644 --- a/examples/fxpp_bitcrush/src/cmd.json +++ b/examples/fxpp_bitcrush/src/cmd.json @@ -1,6 +1,6 @@ { "cmd": { "busIds": [ "input", "output" ], - "parameterIds": [ "sr_ratio", "bit_depth" ] + "parameterIds": [ "sr_ratio", "bit_depth", "gate" ] } } diff --git a/examples/fxpp_bitcrush/src/impl.cpp b/examples/fxpp_bitcrush/src/impl.cpp index bb9e648..00814e5 100644 --- a/examples/fxpp_bitcrush/src/impl.cpp +++ b/examples/fxpp_bitcrush/src/impl.cpp @@ -66,6 +66,9 @@ void impl_set_parameter(impl handle, size_t index, float value) { case 1: instance->bd.setBitDepth((char)value); break; + case 2: + instance->bd.setGateLin(value); + break; } } @@ -78,7 +81,7 @@ float impl_get_parameter(impl handle, size_t index) { void impl_process(impl handle, const float **inputs, float **outputs, size_t n_samples) { Engine *instance = reinterpret_cast(handle); instance->sr.process(inputs, outputs, n_samples); - instance->bd.process(inputs, outputs, n_samples); + instance->bd.process(outputs, outputs, n_samples); } } diff --git a/examples/fxpp_bitcrush/src/lv2.json b/examples/fxpp_bitcrush/src/lv2.json index d6ddf3d..50fcc86 100644 --- a/examples/fxpp_bitcrush/src/lv2.json +++ b/examples/fxpp_bitcrush/src/lv2.json @@ -7,6 +7,6 @@ "types": [ "@lv2:DistortionPlugin" ], "version": "0.0", "busSymbols": [ "input", "output" ], - "parameterSymbols": [ "sr_ratio", "bit_depth" ] + "parameterSymbols": [ "sr_ratio", "bit_depth", "gate" ] } } diff --git a/examples/fxpp_bitcrush/src/product.json b/examples/fxpp_bitcrush/src/product.json index 13d5786..ff1b073 100644 --- a/examples/fxpp_bitcrush/src/product.json +++ b/examples/fxpp_bitcrush/src/product.json @@ -40,6 +40,16 @@ "maximum": 16.0, "integer": true, "map": "linear" + }, + { + "name": "Gate", + "shortName": "Gate", + "direction": "input", + "defaultValue": 0.0, + "minimum": 0.0, + "maximum": 1.0, + "optional": true, + "map": "linear" } ] } diff --git a/include/bw_bd_reduce.h b/include/bw_bd_reduce.h index 5dc1864..99c9828 100644 --- a/include/bw_bd_reduce.h +++ b/include/bw_bd_reduce.h @@ -20,17 +20,24 @@ /*! * module_type {{{ dsp }}} - * version {{{ 1.1.0 }}} + * version {{{ 1.2.0 }}} * requires {{{ bw_common bw_math }}} * description {{{ - * Bit depth reducer. + * Bit depth reducer with input gate. * * This is purely an audio effect, it doesn't actually produce an output * signal with a different encoding. The algorithm is deliberately crude to * obtain the characteristic noise due to lo-fi A/D quantization. + * + * It * }}} * changelog {{{ *