add gate param to bw_bd_reduce and examples + fix fxpp_bitcrush
This commit is contained in:
parent
a4a8ba96ca
commit
5f2a413b4d
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"cmd": {
|
"cmd": {
|
||||||
"busIds": [ "input", "output" ],
|
"busIds": [ "input", "output" ],
|
||||||
"parameterIds": [ "sr_ratio", "bit_depth" ]
|
"parameterIds": [ "sr_ratio", "bit_depth", "gate" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,6 @@
|
|||||||
"types": [ "@lv2:DistortionPlugin" ],
|
"types": [ "@lv2:DistortionPlugin" ],
|
||||||
"version": "0.0",
|
"version": "0.0",
|
||||||
"busSymbols": [ "input", "output" ],
|
"busSymbols": [ "input", "output" ],
|
||||||
"parameterSymbols": [ "sr_ratio", "bit_depth" ]
|
"parameterSymbols": [ "sr_ratio", "bit_depth", "gate" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,9 @@ static void plugin_set_parameter(plugin *instance, size_t index, float value) {
|
|||||||
case 1:
|
case 1:
|
||||||
bw_bd_reduce_set_bit_depth(&instance->bd_reduce_coeffs, (char)value);
|
bw_bd_reduce_set_bit_depth(&instance->bd_reduce_coeffs, (char)value);
|
||||||
break;
|
break;
|
||||||
|
case 2:
|
||||||
|
bw_bd_reduce_set_gate_lin(&instance->bd_reduce_coeffs, value);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +40,16 @@
|
|||||||
"maximum": 16.0,
|
"maximum": 16.0,
|
||||||
"integer": true,
|
"integer": true,
|
||||||
"map": "linear"
|
"map": "linear"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Gate",
|
||||||
|
"shortName": "Gate",
|
||||||
|
"direction": "input",
|
||||||
|
"defaultValue": 0.0,
|
||||||
|
"minimum": 0.0,
|
||||||
|
"maximum": 1.0,
|
||||||
|
"optional": true,
|
||||||
|
"map": "linear"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"cmd": {
|
"cmd": {
|
||||||
"busIds": [ "input", "output" ],
|
"busIds": [ "input", "output" ],
|
||||||
"parameterIds": [ "sr_ratio", "bit_depth" ]
|
"parameterIds": [ "sr_ratio", "bit_depth", "gate" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,9 @@ void impl_set_parameter(impl handle, size_t index, float value) {
|
|||||||
case 1:
|
case 1:
|
||||||
instance->bd.setBitDepth((char)value);
|
instance->bd.setBitDepth((char)value);
|
||||||
break;
|
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) {
|
void impl_process(impl handle, const float **inputs, float **outputs, size_t n_samples) {
|
||||||
Engine *instance = reinterpret_cast<Engine *>(handle);
|
Engine *instance = reinterpret_cast<Engine *>(handle);
|
||||||
instance->sr.process(inputs, outputs, n_samples);
|
instance->sr.process(inputs, outputs, n_samples);
|
||||||
instance->bd.process(inputs, outputs, n_samples);
|
instance->bd.process(outputs, outputs, n_samples);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,6 @@
|
|||||||
"types": [ "@lv2:DistortionPlugin" ],
|
"types": [ "@lv2:DistortionPlugin" ],
|
||||||
"version": "0.0",
|
"version": "0.0",
|
||||||
"busSymbols": [ "input", "output" ],
|
"busSymbols": [ "input", "output" ],
|
||||||
"parameterSymbols": [ "sr_ratio", "bit_depth" ]
|
"parameterSymbols": [ "sr_ratio", "bit_depth", "gate" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,16 @@
|
|||||||
"maximum": 16.0,
|
"maximum": 16.0,
|
||||||
"integer": true,
|
"integer": true,
|
||||||
"map": "linear"
|
"map": "linear"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Gate",
|
||||||
|
"shortName": "Gate",
|
||||||
|
"direction": "input",
|
||||||
|
"defaultValue": 0.0,
|
||||||
|
"minimum": 0.0,
|
||||||
|
"maximum": 1.0,
|
||||||
|
"optional": true,
|
||||||
|
"map": "linear"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -20,17 +20,24 @@
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
* module_type {{{ dsp }}}
|
* module_type {{{ dsp }}}
|
||||||
* version {{{ 1.1.0 }}}
|
* version {{{ 1.2.0 }}}
|
||||||
* requires {{{ bw_common bw_math }}}
|
* requires {{{ bw_common bw_math }}}
|
||||||
* description {{{
|
* description {{{
|
||||||
* Bit depth reducer.
|
* Bit depth reducer with input gate.
|
||||||
*
|
*
|
||||||
* This is purely an audio effect, it doesn't actually produce an output
|
* This is purely an audio effect, it doesn't actually produce an output
|
||||||
* signal with a different encoding. The algorithm is deliberately crude to
|
* signal with a different encoding. The algorithm is deliberately crude to
|
||||||
* obtain the characteristic noise due to lo-fi A/D quantization.
|
* obtain the characteristic noise due to lo-fi A/D quantization.
|
||||||
|
*
|
||||||
|
* It
|
||||||
* }}}
|
* }}}
|
||||||
* changelog {{{
|
* changelog {{{
|
||||||
* <ul>
|
* <ul>
|
||||||
|
* <li>Version <strong>1.2.0</strong>:
|
||||||
|
* <ul>
|
||||||
|
* <li>Added gate parameter.</li>
|
||||||
|
* </ul>
|
||||||
|
* </li>
|
||||||
* <li>Version <strong>1.1.0</strong>:
|
* <li>Version <strong>1.1.0</strong>:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>Added silence_dc parameter.</li>
|
* <li>Added silence_dc parameter.</li>
|
||||||
@ -188,6 +195,30 @@ static inline void bw_bd_reduce_set_silence_dc(
|
|||||||
*
|
*
|
||||||
* Default value: non-`0` (non-null dc).
|
* Default value: non-`0` (non-null dc).
|
||||||
*
|
*
|
||||||
|
* #### bw_bd_reduce_set_gate_lin()
|
||||||
|
* ```>>> */
|
||||||
|
static inline void bw_bd_reduce_set_gate_lin(
|
||||||
|
bw_bd_reduce_coeffs * BW_RESTRICT coeffs,
|
||||||
|
float value);
|
||||||
|
/*! <<<```
|
||||||
|
* Sets the input gate threshold `value` (linear) in `coeffs`.
|
||||||
|
*
|
||||||
|
* Valid range: [`0.f`, `1.f`].
|
||||||
|
*
|
||||||
|
* Default value: `0.f`.
|
||||||
|
*
|
||||||
|
* #### bw_bd_reduce_set_gate_dBFS()
|
||||||
|
* ```>>> */
|
||||||
|
static inline void bw_bd_reduce_set_gate_dBFS(
|
||||||
|
bw_bd_reduce_coeffs * BW_RESTRICT coeffs,
|
||||||
|
float value);
|
||||||
|
/*! <<<```
|
||||||
|
* Sets the input gate threshold `value` (dBFS) in `coeffs`.
|
||||||
|
*
|
||||||
|
* Valid range: [`-INFINITY`, `0.f`].
|
||||||
|
*
|
||||||
|
* Default value: `-INFINITY`.
|
||||||
|
*
|
||||||
* #### bw_bd_reduce_coeffs_is_valid()
|
* #### bw_bd_reduce_coeffs_is_valid()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline char bw_bd_reduce_coeffs_is_valid(
|
static inline char bw_bd_reduce_coeffs_is_valid(
|
||||||
@ -236,6 +267,7 @@ struct bw_bd_reduce_coeffs {
|
|||||||
float k;
|
float k;
|
||||||
float ko;
|
float ko;
|
||||||
float max;
|
float max;
|
||||||
|
float gate;
|
||||||
|
|
||||||
// Parameters
|
// Parameters
|
||||||
char bit_depth;
|
char bit_depth;
|
||||||
@ -248,6 +280,7 @@ static inline void bw_bd_reduce_init(
|
|||||||
|
|
||||||
coeffs->bit_depth = 16;
|
coeffs->bit_depth = 16;
|
||||||
coeffs->ko = 0.5f;
|
coeffs->ko = 0.5f;
|
||||||
|
coeffs->gate = 0.f;
|
||||||
|
|
||||||
#ifdef BW_DEBUG_DEEP
|
#ifdef BW_DEBUG_DEEP
|
||||||
coeffs->hash = bw_hash_sdbm("bw_bd_reduce_coeffs");
|
coeffs->hash = bw_hash_sdbm("bw_bd_reduce_coeffs");
|
||||||
@ -330,6 +363,7 @@ static inline float bw_bd_reduce_process1(
|
|||||||
BW_ASSERT_DEEP(coeffs->state >= bw_bd_reduce_coeffs_state_reset_coeffs);
|
BW_ASSERT_DEEP(coeffs->state >= bw_bd_reduce_coeffs_state_reset_coeffs);
|
||||||
BW_ASSERT(bw_is_finite(x));
|
BW_ASSERT(bw_is_finite(x));
|
||||||
|
|
||||||
|
x = bw_absf(x) < coeffs->gate ? 0.f : x;
|
||||||
const float y = coeffs->ki * (bw_floorf(coeffs->k * bw_clipf(x, -coeffs->max, coeffs->max)) + coeffs->ko);
|
const float y = coeffs->ki * (bw_floorf(coeffs->k * bw_clipf(x, -coeffs->max, coeffs->max)) + coeffs->ko);
|
||||||
|
|
||||||
BW_ASSERT_DEEP(bw_bd_reduce_coeffs_is_valid(coeffs));
|
BW_ASSERT_DEEP(bw_bd_reduce_coeffs_is_valid(coeffs));
|
||||||
@ -413,6 +447,36 @@ static inline void bw_bd_reduce_set_silence_dc(
|
|||||||
BW_ASSERT_DEEP(coeffs->state >= bw_bd_reduce_coeffs_state_init);
|
BW_ASSERT_DEEP(coeffs->state >= bw_bd_reduce_coeffs_state_init);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void bw_bd_reduce_set_gate_lin(
|
||||||
|
bw_bd_reduce_coeffs * BW_RESTRICT coeffs,
|
||||||
|
float value) {
|
||||||
|
BW_ASSERT(coeffs != BW_NULL);
|
||||||
|
BW_ASSERT_DEEP(bw_bd_reduce_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state >= bw_bd_reduce_coeffs_state_init);
|
||||||
|
BW_ASSERT(bw_is_finite(value));
|
||||||
|
BW_ASSERT(value >= 0.f && value <= 1.f);
|
||||||
|
|
||||||
|
coeffs->gate = value;
|
||||||
|
|
||||||
|
BW_ASSERT_DEEP(bw_bd_reduce_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state >= bw_bd_reduce_coeffs_state_init);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void bw_bd_reduce_set_gate_dBFS(
|
||||||
|
bw_bd_reduce_coeffs * BW_RESTRICT coeffs,
|
||||||
|
float value) {
|
||||||
|
BW_ASSERT(coeffs != BW_NULL);
|
||||||
|
BW_ASSERT_DEEP(bw_bd_reduce_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state >= bw_bd_reduce_coeffs_state_init);
|
||||||
|
BW_ASSERT(bw_is_finite(value));
|
||||||
|
BW_ASSERT(value <= 0.f);
|
||||||
|
|
||||||
|
coeffs->gate = bw_dB2linf(value);
|
||||||
|
|
||||||
|
BW_ASSERT_DEEP(bw_bd_reduce_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state >= bw_bd_reduce_coeffs_state_init);
|
||||||
|
}
|
||||||
|
|
||||||
static inline char bw_bd_reduce_coeffs_is_valid(
|
static inline char bw_bd_reduce_coeffs_is_valid(
|
||||||
const bw_bd_reduce_coeffs * BW_RESTRICT coeffs) {
|
const bw_bd_reduce_coeffs * BW_RESTRICT coeffs) {
|
||||||
BW_ASSERT(coeffs != BW_NULL);
|
BW_ASSERT(coeffs != BW_NULL);
|
||||||
@ -439,6 +503,8 @@ static inline char bw_bd_reduce_coeffs_is_valid(
|
|||||||
return 0;
|
return 0;
|
||||||
if (!bw_is_finite(coeffs->max) || coeffs->max < 0.5f || coeffs->max > 1.f)
|
if (!bw_is_finite(coeffs->max) || coeffs->max < 0.5f || coeffs->max > 1.f)
|
||||||
return 0;
|
return 0;
|
||||||
|
if (!bw_is_finite(coeffs->gate) || coeffs->gate < 0.f || coeffs->gate > 1.f)
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -486,6 +552,12 @@ public:
|
|||||||
|
|
||||||
void setSilenceDc(
|
void setSilenceDc(
|
||||||
char value);
|
char value);
|
||||||
|
|
||||||
|
void setGateLin(
|
||||||
|
float value);
|
||||||
|
|
||||||
|
void setGateDBFS(
|
||||||
|
float value);
|
||||||
/*! <<<...
|
/*! <<<...
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -546,6 +618,18 @@ inline void BDReduce<N_CHANNELS>::setSilenceDc(
|
|||||||
bw_bd_reduce_set_silence_dc(&coeffs, value);
|
bw_bd_reduce_set_silence_dc(&coeffs, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<size_t N_CHANNELS>
|
||||||
|
inline void BDReduce<N_CHANNELS>::setGateLin(
|
||||||
|
float value) {
|
||||||
|
bw_bd_reduce_set_gate_lin(&coeffs, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<size_t N_CHANNELS>
|
||||||
|
inline void BDReduce<N_CHANNELS>::setGateDBFS(
|
||||||
|
float value) {
|
||||||
|
bw_bd_reduce_set_gate_dBFS(&coeffs, value);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user