diff --git a/TODO b/TODO
index 41deb1a..05b34c4 100644
--- a/TODO
+++ b/TODO
@@ -39,7 +39,6 @@ code:
* check assumptions w.r.t. usage of math functions
* sample rate-constant coeffs? (pan case)
* sr-dependent vs cr-dependent coeffs? see synth poly example
-* src x != y?
build system:
* single header generation (vs modules in bwp... to think about)
diff --git a/include/bw_src.h b/include/bw_src.h
index c00a4d4..37b641a 100644
--- a/include/bw_src.h
+++ b/include/bw_src.h
@@ -39,6 +39,8 @@
* C-style arrays as arguments.
*
Removed usage of reserved identifiers.
* Removed useless computation when upsampling.
+ * Clarified that the same buffer cannot be used for both input and
+ * output.
*
*
* Version 0.6.0:
@@ -102,7 +104,7 @@ static inline void bw_src_reset_state(const bw_src_coeffs *BW_RESTRICT coeffs, b
*
* #### bw_src_process()
* ```>>> */
-static inline void bw_src_process(const bw_src_coeffs *BW_RESTRICT coeffs, bw_src_state *BW_RESTRICT state, const float *x, float *y, size_t *BW_RESTRICT n_in_samples, size_t *BW_RESTRICT n_out_samples);
+static inline void bw_src_process(const bw_src_coeffs *BW_RESTRICT coeffs, bw_src_state *BW_RESTRICT state, const float *BW_RESTRICT x, float *BW_RESTRICT y, size_t *BW_RESTRICT n_in_samples, size_t *BW_RESTRICT n_out_samples);
/*! <<<```
* Processes at most the first `n_in_samples` of the input buffer `x` and
* fills the output buffer `y` with at most `n_out_samples` using `coeffs`,
@@ -112,9 +114,11 @@ static inline void bw_src_process(const bw_src_coeffs *BW_RESTRICT coeffs, bw_sr
* number of consumed input samples and generated output samples,
* respectively.
*
+ * `x` and `y` must point to different buffers.
+ *
* #### bw_src_process_multi()
* ```>>> */
-static inline void bw_src_process_multi(const bw_src_coeffs *BW_RESTRICT coeffs, bw_src_state *BW_RESTRICT const *BW_RESTRICT state, const float * const *x, float * const *y, size_t n_channels, size_t *BW_RESTRICT n_in_samples, size_t *BW_RESTRICT n_out_samples);
+static inline void bw_src_process_multi(const bw_src_coeffs *BW_RESTRICT coeffs, bw_src_state *BW_RESTRICT const *BW_RESTRICT state, const float * const *BW_RESTRICT x, float *BW_RESTRICT const *BW_RESTRICT y, size_t n_channels, size_t *BW_RESTRICT n_in_samples, size_t *BW_RESTRICT n_out_samples);
/*! <<<```
* Processes at most the first `n_in_samples[i]` of each input buffer `x[i]`
* and fills the corresponding output buffer `y[i]` with at most
@@ -125,6 +129,8 @@ static inline void bw_src_process_multi(const bw_src_coeffs *BW_RESTRICT coeffs,
* contain the actual number of consumed input samples and generated output
* samples, respectively, for each of the `n_channels` input/output buffer
* couples.
+ *
+ * A given buffer cannot be used both as an input and output buffer.
* }}} */
#ifdef __cplusplus
@@ -200,7 +206,7 @@ static inline void bw_src_reset_state(const bw_src_coeffs *BW_RESTRICT coeffs, b
state->xz3 = x_0;
}
-static inline void bw_src_process(const bw_src_coeffs *BW_RESTRICT coeffs, bw_src_state *BW_RESTRICT state, const float *x, float *y, size_t *BW_RESTRICT n_in_samples, size_t *BW_RESTRICT n_out_samples) {
+static inline void bw_src_process(const bw_src_coeffs *BW_RESTRICT coeffs, bw_src_state *BW_RESTRICT state, const float *BW_RESTRICT x, float *BW_RESTRICT y, size_t *BW_RESTRICT n_in_samples, size_t *BW_RESTRICT n_out_samples) {
size_t i = 0;
size_t j = 0;
if (coeffs->k < 0) {
@@ -267,7 +273,7 @@ static inline void bw_src_process(const bw_src_coeffs *BW_RESTRICT coeffs, bw_sr
*n_out_samples = j;
}
-static inline void bw_src_process_multi(const bw_src_coeffs *BW_RESTRICT coeffs, bw_src_state *BW_RESTRICT const *BW_RESTRICT state, const float * const *x, float * const *y, size_t n_channels, size_t *BW_RESTRICT n_in_samples, size_t *BW_RESTRICT n_out_samples) {
+static inline void bw_src_process_multi(const bw_src_coeffs *BW_RESTRICT coeffs, bw_src_state *BW_RESTRICT const *BW_RESTRICT state, const float * const *BW_RESTRICT x, float *BW_RESTRICT const *BW_RESTRICT y, size_t n_channels, size_t *BW_RESTRICT n_in_samples, size_t *BW_RESTRICT n_out_samples) {
for (size_t i = 0; i < n_channels; i++)
bw_src_process(coeffs, state[i], x[i], y[i], n_in_samples + i, n_out_samples + i);
}
diff --git a/include/bw_src_int.h b/include/bw_src_int.h
index 07ac567..650fa78 100644
--- a/include/bw_src_int.h
+++ b/include/bw_src_int.h
@@ -44,6 +44,8 @@
* Added overladed C++ process()
function taking
* C-style arrays as arguments.
* Removed usage of reserved identifiers.
+ * Clarified that the same buffer cannot be used for both input and
+ * output.
*
*
* Version 0.6.0:
@@ -109,7 +111,7 @@ static inline void bw_src_int_reset_state(const bw_src_int_coeffs *BW_RESTRICT c
*
* #### bw_src_int_process()
* ```>>> */
-static inline size_t bw_src_int_process(const bw_src_int_coeffs *BW_RESTRICT coeffs, bw_src_int_state *BW_RESTRICT state, const float *x, float *y, size_t n_in_samples);
+static inline size_t bw_src_int_process(const bw_src_int_coeffs *BW_RESTRICT coeffs, bw_src_int_state *BW_RESTRICT state, const float *BW_RESTRICT x, float *BW_RESTRICT y, size_t n_in_samples);
/*! <<<```
* Processes the first `n_in_samples` of the input buffer `x` and fills the
* output buffer `y` using `coeffs`, while using and updating `state`.
@@ -118,11 +120,13 @@ static inline size_t bw_src_int_process(const bw_src_int_coeffs *BW_RESTRICT coe
* `n_in_samples` if `ratio` is positive, otherwise at most `n_in_samples`
* divided by `-ratio` and then rounded towards positive infinity.
*
+ * `x` and `y` must point to different buffers.
+ *
* Returns the number of generated output samples.
*
* #### bw_src_int_process_multi()
* ```>>> */
-static inline void bw_src_int_process_multi(const bw_src_int_coeffs *BW_RESTRICT coeffs, bw_src_int_state *BW_RESTRICT const *BW_RESTRICT state, const float * const *x, float * const *y, size_t *BW_RESTRICT n, size_t n_channels, size_t n_in_samples);
+static inline void bw_src_int_process_multi(const bw_src_int_coeffs *BW_RESTRICT coeffs, bw_src_int_state *BW_RESTRICT const *BW_RESTRICT state, const float * const *BW_RESTRICT x, float *BW_RESTRICT const *BW_RESTRICT y, size_t *BW_RESTRICT n, size_t n_channels, size_t n_in_samples);
/*! <<<```
* Processes the first `n_in_samples` of the `n_channels` input buffers `x`
* and fills the `n_channels` output buffers `y` using `coeffs`, while using
@@ -133,6 +137,8 @@ static inline void bw_src_int_process_multi(const bw_src_int_coeffs *BW_RESTRICT
* `n_in_samples` divided by `-ratio` and then rounded towards positive
* infinity.
*
+ * A given buffer cannot be used both as an input and output buffer.
+ *
* `n` is filled with the number of generated output samples for each output
* buffer, if not `NULL`.
* }}} */
@@ -204,7 +210,7 @@ static inline void bw_src_int_reset_state(const bw_src_int_coeffs *BW_RESTRICT c
}
}
-static inline size_t bw_src_int_process(const bw_src_int_coeffs *BW_RESTRICT coeffs, bw_src_int_state *BW_RESTRICT state, const float *x, float *y, size_t n_in_samples) {
+static inline size_t bw_src_int_process(const bw_src_int_coeffs *BW_RESTRICT coeffs, bw_src_int_state *BW_RESTRICT state, const float *BW_RESTRICT x, float *BW_RESTRICT y, size_t n_in_samples) {
size_t n = 0;
if (coeffs->ratio < 0) {
for (size_t i = 0; i < n_in_samples; i++) {
@@ -240,7 +246,7 @@ static inline size_t bw_src_int_process(const bw_src_int_coeffs *BW_RESTRICT coe
return n;
}
-static inline void bw_src_int_process_multi(const bw_src_int_coeffs *BW_RESTRICT coeffs, bw_src_int_state *BW_RESTRICT const *BW_RESTRICT state, const float * const *x, float * const *y, size_t *BW_RESTRICT n, size_t n_channels, size_t n_in_samples) {
+static inline void bw_src_int_process_multi(const bw_src_int_coeffs *BW_RESTRICT coeffs, bw_src_int_state *BW_RESTRICT const *BW_RESTRICT state, const float * const *BW_RESTRICT x, float *BW_RESTRICT const *BW_RESTRICT y, size_t *BW_RESTRICT n, size_t n_channels, size_t n_in_samples) {
if (n != NULL)
for (size_t i = 0; i < n_channels; i++)
n[i] = bw_src_int_process(coeffs, state[i], x[i], y[i], n_in_samples);