Skip to content
Snippets Groups Projects

bl00mbox: fix delay up proper

Merged moon2 requested to merge bl00mbox_delay_fix_for_real into main
3 files
+ 15
18
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -21,7 +21,6 @@ radspa_descriptor_t delay_desc = {
void delay_run(radspa_t * delay, uint16_t num_samples, uint32_t render_pass_id){
radspa_signal_t * output_sig = radspa_signal_get_by_index(delay, DELAY_OUTPUT);
if(output_sig->buffer == NULL) return;
delay_data_t * data = delay->plugin_data;
int16_t * buf = delay->plugin_table;
radspa_signal_t * input_sig = radspa_signal_get_by_index(delay, DELAY_INPUT);
@@ -33,9 +32,16 @@ void delay_run(radspa_t * delay, uint16_t num_samples, uint32_t render_pass_id){
static int16_t ret = 0;
uint32_t buffer_size = delay->plugin_table_len;
uint32_t time = radspa_signal_get_value(time_sig, 0, render_pass_id);
int32_t buffer_size = delay->plugin_table_len;
int32_t time = radspa_signal_get_value(time_sig, 0, render_pass_id);
if(time < 0) time = -time;
if(time > data->max_delay) time = data->max_delay;
if(time != data->time_prev){
data->read_head_position = data->write_head_position;
data->read_head_position -= time * (48000/1000);
if(data->read_head_position < 0) data->read_head_position += buffer_size;
data->time_prev = time;
}
int16_t fb = radspa_signal_get_value(feedback_sig, 0, render_pass_id);
int16_t level = radspa_signal_get_value(level_sig, 0, render_pass_id);
@@ -47,17 +53,8 @@ void delay_run(radspa_t * delay, uint16_t num_samples, uint32_t render_pass_id){
data->write_head_position++;
while(data->write_head_position >= buffer_size) data->write_head_position -= buffer_size; // maybe faster than %
if(time != data->time_prev){
data->read_head_position = data->write_head_position;
data->read_head_position = - time * (48000/1000);
if(data->read_head_position < 0) data->read_head_position += buffer_size;
data->time_prev = time;
} else {
data->read_head_position++;
}
data->read_head_position++;
while(data->read_head_position >= buffer_size) data->read_head_position -= buffer_size;
//int16_t * buf = &(data->buffer);
int16_t dry = radspa_signal_get_value(input_sig, i, render_pass_id);
int16_t wet = buf[data->read_head_position];
@@ -80,7 +77,7 @@ radspa_t * delay_create(uint32_t init_var){
if(delay == NULL) return NULL;
delay_data_t * plugin_data = delay->plugin_data;
plugin_data->time_prev = UINT32_MAX;
plugin_data->time_prev = -1;
plugin_data->max_delay = init_var;
delay->render = delay_run;
radspa_signal_set(delay, DELAY_OUTPUT, "output", RADSPA_SIGNAL_HINT_OUTPUT, 0);
Loading