avoid bw_minf() to compute samples in synth*

This commit is contained in:
Stefano D'Angelo 2024-03-07 16:57:50 +01:00
parent 5a4b9dc9b3
commit 93f571af18
6 changed files with 20 additions and 10 deletions

View File

@ -470,7 +470,9 @@ static void plugin_process(plugin *instance, const float **inputs, float **outpu
for (size_t i = 0; i < n_samples; ) {
float *out = outputs[0] + i;
int n = bw_minf(bw_minf(n_samples - i, BUFFER_SIZE), instance->sync_left);
size_t ni = n_samples - i;
size_t n = ni < BUFFER_SIZE ? ni : BUFFER_SIZE;
n = n < instance->sync_left ? n : instance->sync_left;
const char sync = instance->sync_left == instance->sync_count;
@ -499,7 +501,7 @@ static void plugin_process(plugin *instance, const float **inputs, float **outpu
// modulation signals
for (int j = 0; j < n; j++)
for (size_t j = 0; j < n; j++)
instance->buf[1][j] = instance->mod_wheel * (out[j] + instance->modulation_mix * (instance->buf[0][j] - out[j]));
if (sync)
instance->mod_k = instance->buf[1][0];

View File

@ -555,7 +555,9 @@ static void plugin_process(plugin *instance, const float **inputs, float **outpu
for (size_t i = 0; i < n_samples; ) {
float *out = outputs[0] + i;
int n = bw_minf(bw_minf(n_samples - i, BUFFER_SIZE), instance->sync_left);
size_t ni = n_samples - i;
size_t n = ni < BUFFER_SIZE ? ni : BUFFER_SIZE;
n = n < instance->sync_left ? n : instance->sync_left;
const char sync = instance->sync_left == instance->sync_count;
@ -586,7 +588,7 @@ static void plugin_process(plugin *instance, const float **inputs, float **outpu
// modulation signals
for (int j = 0; j < N_VOICES; j++) {
for (int k = 0; k < n; k++)
for (size_t k = 0; k < n; k++)
instance->b2[j][k] = instance->mod_wheel * (instance->b0[j][k] + instance->modulation_mix * (instance->b1[j][k] - instance->b0[j][k]));
}
if (sync)

View File

@ -152,7 +152,8 @@ static void plugin_process(plugin *instance, const float **inputs, float **outpu
for (size_t i = 0; i < n_samples; i += BUFFER_SIZE) {
float *out = outputs[0] + i;
int n = bw_minf(n_samples - i, BUFFER_SIZE);
size_t ni = n_samples - i;
size_t n = ni < BUFFER_SIZE ? ni : BUFFER_SIZE;
bw_phase_gen_process(&instance->phase_gen_coeffs, &instance->phase_gen_state, NULL, out, instance->buf, n);
bw_osc_pulse_process(&instance->osc_pulse_coeffs, out, instance->buf, out, n);

View File

@ -451,7 +451,9 @@ void impl_process(impl handle, const float **inputs, float **outputs, size_t n_s
char g[1] = {instance->gate};
for (size_t i = 0; i < n_samples; ) {
float *out = outputs[0] + i;
int n = bw_minf(bw_minf(n_samples - i, BUFFER_SIZE), instance->syncLeft);
size_t ni = n_samples - i;
size_t n = ni < BUFFER_SIZE ? ni : BUFFER_SIZE;
n = n < instance->syncLeft ? n : instance->syncLeft;
const char sync = instance->syncLeft == instance->syncCount;
float *y[1] = {out};
@ -481,7 +483,7 @@ void impl_process(impl handle, const float **inputs, float **outputs, size_t n_s
// modulation signals
for (int j = 0; j < n; j++)
for (size_t j = 0; j < n; j++)
instance->buf[1][j] = instance->modWheel * (out[j] + instance->modulationMix * (instance->buf[0][j] - out[j]));
if (sync)
instance->modK = instance->buf[1][0];

View File

@ -526,7 +526,9 @@ void impl_process(impl handle, const float **inputs, float **outputs, size_t n_s
for (size_t i = 0; i < n_samples; ) {
float *out = outputs[0] + i;
int n = bw_minf(bw_minf(n_samples - i, BUFFER_SIZE), instance->syncLeft);
size_t ni = n_samples - i;
size_t n = ni < BUFFER_SIZE ? ni : BUFFER_SIZE;
n = n < instance->syncLeft ? n : instance->syncLeft;
const char sync = instance->syncLeft == instance->syncCount;
float *y[1] = {out};
@ -561,7 +563,7 @@ void impl_process(impl handle, const float **inputs, float **outputs, size_t n_s
// modulation signals
for (int j = 0; j < N_VOICES; j++) {
for (int k = 0; k < n; k++)
for (size_t k = 0; k < n; k++)
instance->b2[j][k] = instance->modWheel * (instance->b0[j][k] + instance->modulationMix * (instance->b1[j][k] - instance->b0[j][k]));
}
if (sync)

View File

@ -141,7 +141,8 @@ void impl_process(impl handle, const float **inputs, float **outputs, size_t n_s
for (size_t i = 0; i < n_samples; i += BUFFER_SIZE) {
float *out = outputs[0] + i;
int n = bw_minf(n_samples - i, BUFFER_SIZE);
size_t ni = n_samples - i;
size_t n = ni < BUFFER_SIZE ? ni : BUFFER_SIZE;
#ifdef WASM
float *y[1] = {out};