finalize bw_one_pole + adjust example Makefiles + fix stupid bug in bw_dist
This commit is contained in:
parent
26f98b3ec7
commit
af2d21e45c
1
TODO
1
TODO
@ -29,6 +29,7 @@ finally:
|
|||||||
* debugging - also check outputs different (incl bw_buf)
|
* debugging - also check outputs different (incl bw_buf)
|
||||||
* check all examples again
|
* check all examples again
|
||||||
* clearly specify that state is tied to a particular set of coeffs (1:N)
|
* clearly specify that state is tied to a particular set of coeffs (1:N)
|
||||||
|
* state that sample rate is finite and > 0
|
||||||
* thank scientific paper authors
|
* thank scientific paper authors
|
||||||
|
|
||||||
build system:
|
build system:
|
||||||
|
@ -31,6 +31,7 @@ D8 := ${BUILD_TOOLS_DIR}/d8
|
|||||||
CXXFLAGS := \
|
CXXFLAGS := \
|
||||||
-fPIC \
|
-fPIC \
|
||||||
-DNDEBUG \
|
-DNDEBUG \
|
||||||
|
-DBW_NO_DEBUG \
|
||||||
-I${ROOT_DIR}/../src \
|
-I${ROOT_DIR}/../src \
|
||||||
-I${COMMON_DIR} \
|
-I${COMMON_DIR} \
|
||||||
-I${ROOT_DIR}/../../../include \
|
-I${ROOT_DIR}/../../../include \
|
||||||
|
@ -13,12 +13,14 @@ include ${SYSTEM_FILES_DIR}/Makefile
|
|||||||
|
|
||||||
CPPFLAGS += \
|
CPPFLAGS += \
|
||||||
-DNDEBUG \
|
-DNDEBUG \
|
||||||
|
-DBW_NO_DEBUG \
|
||||||
-I${ROOT_DIR} \
|
-I${ROOT_DIR} \
|
||||||
-I${ROOT_DIR}/../src \
|
-I${ROOT_DIR}/../src \
|
||||||
-I${ROOT_DIR}/../../../include
|
-I${ROOT_DIR}/../../../include
|
||||||
|
|
||||||
CFLAGS += \
|
CFLAGS += \
|
||||||
-DNDEBUG \
|
-DNDEBUG \
|
||||||
|
-DBW_NO_DEBUG \
|
||||||
-I${ROOT_DIR} \
|
-I${ROOT_DIR} \
|
||||||
-I${ROOT_DIR}/../src \
|
-I${ROOT_DIR}/../src \
|
||||||
-I${ROOT_DIR}/../../../include \
|
-I${ROOT_DIR}/../../../include \
|
||||||
|
@ -6,8 +6,6 @@ TEMPLATE_DIR := ${ROOT_DIR}/../../common/vst3/template.vst3
|
|||||||
BUILD_PLUGIN_DIR := build/${NAME}.vst3
|
BUILD_PLUGIN_DIR := build/${NAME}.vst3
|
||||||
|
|
||||||
CXXFLAGS := \
|
CXXFLAGS := \
|
||||||
-DRELEASE=1 \
|
|
||||||
-DNDEBUG \
|
|
||||||
-I${ROOT_DIR} \
|
-I${ROOT_DIR} \
|
||||||
-I${ROOT_DIR}/../src \
|
-I${ROOT_DIR}/../src \
|
||||||
-I${COMMON_DIR} \
|
-I${COMMON_DIR} \
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
CC := clang
|
CC := clang
|
||||||
CFLAGS := \
|
CFLAGS := \
|
||||||
|
-DNDEBUG \
|
||||||
-DBW_NO_DEBUG \
|
-DBW_NO_DEBUG \
|
||||||
-I${ROOT_DIR}/../src \
|
-I${ROOT_DIR}/../src \
|
||||||
-I${ROOT_DIR}/../../common/web \
|
-I${ROOT_DIR}/../../common/web \
|
||||||
|
@ -4,3 +4,6 @@ NAME := bw_example_fx_one_pole
|
|||||||
SOURCES = ${SOURCES_COMMON} ${ROOT_DIR}/../src/bw_example_fx_one_pole.c
|
SOURCES = ${SOURCES_COMMON} ${ROOT_DIR}/../src/bw_example_fx_one_pole.c
|
||||||
|
|
||||||
include ${ROOT_DIR}/../../common/vst3/vst3.mk
|
include ${ROOT_DIR}/../../common/vst3/vst3.mk
|
||||||
|
|
||||||
|
CXXFLAGS += -DRELEASE=1 -DNDEBUG -DBW_NO_DEBUG
|
||||||
|
#CXXFLAGS += -DDEVELOPMENT=1 -DBW_DEBUG_DEEP
|
||||||
|
@ -4,3 +4,6 @@ NAME := bw_example_fxpp_one_pole
|
|||||||
SOURCES = ${SOURCES_COMMON} ${ROOT_DIR}/../src/bw_example_fxpp_one_pole.cpp
|
SOURCES = ${SOURCES_COMMON} ${ROOT_DIR}/../src/bw_example_fxpp_one_pole.cpp
|
||||||
|
|
||||||
include ${ROOT_DIR}/../../common/vst3/vst3.mk
|
include ${ROOT_DIR}/../../common/vst3/vst3.mk
|
||||||
|
|
||||||
|
CXXFLAGS += -DRELEASE=1 -DNDEBUG -DBW_NO_DEBUG
|
||||||
|
#CXXFLAGS += -DDEVELOPMENT=1 -DBW_DEBUG_DEEP
|
||||||
|
@ -227,7 +227,7 @@ static inline void bw_dist_init(bw_dist_coeffs *BW_RESTRICT coeffs) {
|
|||||||
bw_clip_set_gain(&coeffs->clip_coeffs, 1.f / 4.25f);
|
bw_clip_set_gain(&coeffs->clip_coeffs, 1.f / 4.25f);
|
||||||
bw_clip_set_gain_compensation(&coeffs->clip_coeffs, 1);
|
bw_clip_set_gain_compensation(&coeffs->clip_coeffs, 1);
|
||||||
bw_satur_set_gain(&coeffs->satur_coeffs, 1.f / 0.7f);
|
bw_satur_set_gain(&coeffs->satur_coeffs, 1.f / 0.7f);
|
||||||
bw_satur_set_gain_compensation(&coeffs->clip_coeffs, 1);
|
bw_satur_set_gain_compensation(&coeffs->satur_coeffs, 1);
|
||||||
bw_lp1_set_cutoff(&coeffs->lp1_coeffs, 475.f + (20e3f - 475.f) * 0.125f);
|
bw_lp1_set_cutoff(&coeffs->lp1_coeffs, 475.f + (20e3f - 475.f) * 0.125f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
* <li>Removed usage of reserved identifiers.</li>
|
* <li>Removed usage of reserved identifiers.</li>
|
||||||
* <li>Now using backward Euler rather than impulse invariant
|
* <li>Now using backward Euler rather than impulse invariant
|
||||||
* method.</li>
|
* method.</li>
|
||||||
|
* <li>Added more debugging code.</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* </li>
|
* </li>
|
||||||
* <li>Version <strong>0.6.0</strong>:
|
* <li>Version <strong>0.6.0</strong>:
|
||||||
@ -264,6 +265,8 @@ static inline void bw_one_pole_set_cutoff(
|
|||||||
* `bw_one_pole_set_tau()` with same `coeffs` and
|
* `bw_one_pole_set_tau()` with same `coeffs` and
|
||||||
* value = 1 / (2 * pi * `value`) (net of numerical errors).
|
* value = 1 / (2 * pi * `value`) (net of numerical errors).
|
||||||
*
|
*
|
||||||
|
* `value` must be non-negative.
|
||||||
|
*
|
||||||
* Default value: `INFINITY`.
|
* Default value: `INFINITY`.
|
||||||
*
|
*
|
||||||
* #### bw_one_pole_set_cutoff_up()
|
* #### bw_one_pole_set_cutoff_up()
|
||||||
@ -278,6 +281,8 @@ static inline void bw_one_pole_set_cutoff_up(
|
|||||||
* This is equivalent to calling `bw_one_pole_set_tau_up()` with same
|
* This is equivalent to calling `bw_one_pole_set_tau_up()` with same
|
||||||
* `coeffs` and value = 1 / (2 * pi * `value`) (net of numerical errors).
|
* `coeffs` and value = 1 / (2 * pi * `value`) (net of numerical errors).
|
||||||
*
|
*
|
||||||
|
* `value` must be non-negative.
|
||||||
|
*
|
||||||
* Default value: `INFINITY`.
|
* Default value: `INFINITY`.
|
||||||
*
|
*
|
||||||
* #### bw_one_pole_set_cutoff_down()
|
* #### bw_one_pole_set_cutoff_down()
|
||||||
@ -292,6 +297,8 @@ static inline void bw_one_pole_set_cutoff_down(
|
|||||||
* This is equivalent to calling `bw_one_pole_set_tau_down()` with same
|
* This is equivalent to calling `bw_one_pole_set_tau_down()` with same
|
||||||
* `coeffs` and value = 1 / (2 * pi * `value`) (net of numerical errors).
|
* `coeffs` and value = 1 / (2 * pi * `value`) (net of numerical errors).
|
||||||
*
|
*
|
||||||
|
* `value` must be non-negative.
|
||||||
|
*
|
||||||
* Default value: `INFINITY`.
|
* Default value: `INFINITY`.
|
||||||
*
|
*
|
||||||
* #### bw_one_pole_set_tau()
|
* #### bw_one_pole_set_tau()
|
||||||
@ -308,6 +315,8 @@ static inline void bw_one_pole_set_tau(
|
|||||||
* `bw_one_pole_set_cutoff()` with same `coeffs` and
|
* `bw_one_pole_set_cutoff()` with same `coeffs` and
|
||||||
* value = 1 / (2 * pi * `value`) (net of numerical errors).
|
* value = 1 / (2 * pi * `value`) (net of numerical errors).
|
||||||
*
|
*
|
||||||
|
* `value` must be non-negative.
|
||||||
|
*
|
||||||
* Default value: `0.f`.
|
* Default value: `0.f`.
|
||||||
*
|
*
|
||||||
* #### bw_one_pole_set_tau_up()
|
* #### bw_one_pole_set_tau_up()
|
||||||
@ -322,6 +331,8 @@ static inline void bw_one_pole_set_tau_up(
|
|||||||
* This is equivalent to calling `bw_one_pole_set_cutoff_up()` with same
|
* This is equivalent to calling `bw_one_pole_set_cutoff_up()` with same
|
||||||
* `coeffs` and value = 1 / (2 * pi * `value`) (net of numerical errors).
|
* `coeffs` and value = 1 / (2 * pi * `value`) (net of numerical errors).
|
||||||
*
|
*
|
||||||
|
* `value` must be non-negative.
|
||||||
|
*
|
||||||
* Default value: `0.f`.
|
* Default value: `0.f`.
|
||||||
*
|
*
|
||||||
* #### bw_one_pole_set_tau_down()
|
* #### bw_one_pole_set_tau_down()
|
||||||
@ -336,6 +347,8 @@ static inline void bw_one_pole_set_tau_down(
|
|||||||
* This is equivalent to calling `bw_one_pole_set_cutoff_down()` with same
|
* This is equivalent to calling `bw_one_pole_set_cutoff_down()` with same
|
||||||
* `coeffs` and value = 1 / (2 * pi * `value`) (net of numerical errors).
|
* `coeffs` and value = 1 / (2 * pi * `value`) (net of numerical errors).
|
||||||
*
|
*
|
||||||
|
* `value` must be non-negative.
|
||||||
|
*
|
||||||
* Default value: `0.f`.
|
* Default value: `0.f`.
|
||||||
*
|
*
|
||||||
* #### bw_one_pole_set_sticky_thresh()
|
* #### bw_one_pole_set_sticky_thresh()
|
||||||
@ -351,6 +364,8 @@ static inline void bw_one_pole_set_sticky_thresh(
|
|||||||
* `bw_one_pole_set_sticky_mode()`), the output is forcefully set to be equal
|
* `bw_one_pole_set_sticky_mode()`), the output is forcefully set to be equal
|
||||||
* to the input value.
|
* to the input value.
|
||||||
*
|
*
|
||||||
|
* Valid range: [`0.f`, `1e18f`].
|
||||||
|
*
|
||||||
* Default value: `0.f`.
|
* Default value: `0.f`.
|
||||||
*
|
*
|
||||||
* #### bw_one_pole_set_sticky_mode()
|
* #### bw_one_pole_set_sticky_mode()
|
||||||
@ -470,6 +485,7 @@ static inline void bw_one_pole_init(
|
|||||||
coeffs->reset_id = coeffs->hash + 1;
|
coeffs->reset_id = coeffs->hash + 1;
|
||||||
#endif
|
#endif
|
||||||
BW_ASSERT_DEEP(bw_one_pole_coeffs_is_valid(coeffs));
|
BW_ASSERT_DEEP(bw_one_pole_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state == bw_one_pole_coeffs_state_init);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void bw_one_pole_set_sample_rate(
|
static inline void bw_one_pole_set_sample_rate(
|
||||||
@ -478,6 +494,7 @@ static inline void bw_one_pole_set_sample_rate(
|
|||||||
BW_ASSERT(coeffs != NULL);
|
BW_ASSERT(coeffs != NULL);
|
||||||
BW_ASSERT_DEEP(bw_one_pole_coeffs_is_valid(coeffs));
|
BW_ASSERT_DEEP(bw_one_pole_coeffs_is_valid(coeffs));
|
||||||
BW_ASSERT_DEEP(coeffs->state >= bw_one_pole_coeffs_state_init);
|
BW_ASSERT_DEEP(coeffs->state >= bw_one_pole_coeffs_state_init);
|
||||||
|
BW_ASSERT(bw_is_finite(sample_rate) && sample_rate > 0.f);
|
||||||
|
|
||||||
coeffs->fs_2pi = 0.15915494309189535f * sample_rate;
|
coeffs->fs_2pi = 0.15915494309189535f * sample_rate;
|
||||||
|
|
||||||
@ -485,6 +502,7 @@ static inline void bw_one_pole_set_sample_rate(
|
|||||||
coeffs->state = bw_one_pole_coeffs_state_set_sample_rate;
|
coeffs->state = bw_one_pole_coeffs_state_set_sample_rate;
|
||||||
#endif
|
#endif
|
||||||
BW_ASSERT_DEEP(bw_one_pole_coeffs_is_valid(coeffs));
|
BW_ASSERT_DEEP(bw_one_pole_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state == bw_one_pole_coeffs_state_set_sample_rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void bw_one_pole_do_update_coeffs_ctrl(
|
static inline void bw_one_pole_do_update_coeffs_ctrl(
|
||||||
@ -516,6 +534,7 @@ static inline void bw_one_pole_reset_coeffs(
|
|||||||
coeffs->reset_id++;
|
coeffs->reset_id++;
|
||||||
#endif
|
#endif
|
||||||
BW_ASSERT_DEEP(bw_one_pole_coeffs_is_valid(coeffs));
|
BW_ASSERT_DEEP(bw_one_pole_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state == bw_one_pole_coeffs_state_reset_coeffs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void bw_one_pole_reset_state(
|
static inline void bw_one_pole_reset_state(
|
||||||
@ -538,6 +557,7 @@ static inline void bw_one_pole_reset_state(
|
|||||||
BW_ASSERT_DEEP(bw_one_pole_coeffs_is_valid(coeffs));
|
BW_ASSERT_DEEP(bw_one_pole_coeffs_is_valid(coeffs));
|
||||||
BW_ASSERT_DEEP(coeffs->state >= bw_one_pole_coeffs_state_reset_coeffs);
|
BW_ASSERT_DEEP(coeffs->state >= bw_one_pole_coeffs_state_reset_coeffs);
|
||||||
BW_ASSERT_DEEP(bw_one_pole_state_is_valid(state));
|
BW_ASSERT_DEEP(bw_one_pole_state_is_valid(state));
|
||||||
|
BW_ASSERT_DEEP(coeffs->reset_id == state->coeffs_reset_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void bw_one_pole_update_coeffs_ctrl(
|
static inline void bw_one_pole_update_coeffs_ctrl(
|
||||||
@ -810,7 +830,8 @@ static inline void bw_one_pole_process_multi(
|
|||||||
BW_ASSERT(coeffs != NULL);
|
BW_ASSERT(coeffs != NULL);
|
||||||
BW_ASSERT_DEEP(bw_one_pole_coeffs_is_valid(coeffs));
|
BW_ASSERT_DEEP(bw_one_pole_coeffs_is_valid(coeffs));
|
||||||
BW_ASSERT_DEEP(coeffs->state >= bw_one_pole_coeffs_state_reset_coeffs);
|
BW_ASSERT_DEEP(coeffs->state >= bw_one_pole_coeffs_state_reset_coeffs);
|
||||||
//...
|
BW_ASSERT(state != NULL);
|
||||||
|
BW_ASSERT(x != NULL);
|
||||||
|
|
||||||
bw_one_pole_update_coeffs_ctrl(coeffs);
|
bw_one_pole_update_coeffs_ctrl(coeffs);
|
||||||
if (y != NULL) {
|
if (y != NULL) {
|
||||||
@ -910,7 +931,8 @@ static inline void bw_one_pole_process_multi(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//...
|
BW_ASSERT_DEEP(bw_one_pole_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state >= bw_one_pole_coeffs_state_reset_coeffs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void bw_one_pole_set_cutoff(bw_one_pole_coeffs *BW_RESTRICT coeffs, float value) {
|
static inline void bw_one_pole_set_cutoff(bw_one_pole_coeffs *BW_RESTRICT coeffs, float value) {
|
||||||
@ -1017,7 +1039,8 @@ static inline void bw_one_pole_set_sticky_thresh(
|
|||||||
BW_ASSERT(coeffs != NULL);
|
BW_ASSERT(coeffs != NULL);
|
||||||
BW_ASSERT_DEEP(bw_one_pole_coeffs_is_valid(coeffs));
|
BW_ASSERT_DEEP(bw_one_pole_coeffs_is_valid(coeffs));
|
||||||
BW_ASSERT_DEEP(coeffs->state >= bw_one_pole_coeffs_state_init);
|
BW_ASSERT_DEEP(coeffs->state >= bw_one_pole_coeffs_state_init);
|
||||||
//...
|
BW_ASSERT(!bw_is_nan(value));
|
||||||
|
BW_ASSERT(value >= 0.f && value <= 1e18f);
|
||||||
|
|
||||||
if (coeffs->sticky_thresh != value) {
|
if (coeffs->sticky_thresh != value) {
|
||||||
coeffs->sticky_thresh = value;
|
coeffs->sticky_thresh = value;
|
||||||
@ -1034,7 +1057,7 @@ static inline void bw_one_pole_set_sticky_mode(
|
|||||||
BW_ASSERT(coeffs != NULL);
|
BW_ASSERT(coeffs != NULL);
|
||||||
BW_ASSERT_DEEP(bw_one_pole_coeffs_is_valid(coeffs));
|
BW_ASSERT_DEEP(bw_one_pole_coeffs_is_valid(coeffs));
|
||||||
BW_ASSERT_DEEP(coeffs->state >= bw_one_pole_coeffs_state_init);
|
BW_ASSERT_DEEP(coeffs->state >= bw_one_pole_coeffs_state_init);
|
||||||
//...
|
BW_ASSERT(value == bw_one_pole_sticky_mode_abs || value == bw_one_pole_sticky_mode_rel);
|
||||||
|
|
||||||
coeffs->sticky_mode = value;
|
coeffs->sticky_mode = value;
|
||||||
|
|
||||||
@ -1057,9 +1080,34 @@ static inline char bw_one_pole_coeffs_is_valid(
|
|||||||
#ifdef BW_DEBUG_DEEP
|
#ifdef BW_DEBUG_DEEP
|
||||||
if (coeffs->hash != bw_hash_sdbm("bw_one_pole_coeffs"))
|
if (coeffs->hash != bw_hash_sdbm("bw_one_pole_coeffs"))
|
||||||
return 0;
|
return 0;
|
||||||
|
if (coeffs->state < bw_one_pole_coeffs_state_init || coeffs->state > bw_one_pole_coeffs_state_reset_coeffs)
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (coeffs->cutoff_up < 0.f)
|
||||||
|
return 0;
|
||||||
|
if (coeffs->cutoff_down < 0.f)
|
||||||
|
return 0;
|
||||||
|
if (coeffs->sticky_thresh < 0.f || coeffs->sticky_thresh > 1e18f)
|
||||||
|
return 0;
|
||||||
|
if (coeffs->sticky_mode != bw_one_pole_sticky_mode_abs && coeffs->sticky_mode != bw_one_pole_sticky_mode_rel)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#ifdef BW_DEBUG_DEEP
|
||||||
|
if (coeffs->state >= bw_one_pole_coeffs_state_set_sample_rate) {
|
||||||
|
if (!bw_is_finite(coeffs->fs_2pi) || coeffs->fs_2pi < 0.f)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (coeffs->state >= bw_one_pole_coeffs_state_reset_coeffs) {
|
||||||
|
if (!bw_is_finite(coeffs->mA1u) || coeffs->mA1u < 0.f || coeffs->mA1u > 1.f)
|
||||||
|
return 0;
|
||||||
|
if (!bw_is_finite(coeffs->mA1d) || coeffs->mA1d < 0.f || coeffs->mA1d > 1.f)
|
||||||
|
return 0;
|
||||||
|
if (!bw_is_finite(coeffs->st2) || coeffs->st2 < 0.f)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
(void)coeffs;
|
|
||||||
//...
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user