#include "reverb.h" #include "reverb_wrapper.h" #include static int ch,n,L; static float *x[32], *y[32]; #if (GUI == UI_XYK) Reverb_common c_t; Reverb_taps t_t; Reverb_early e_t; Reverb_late l_t; Reverb_eq eq_t; void params_chg(Reverb_common *com, Reverb_taps *tap, Reverb_early *ear, Reverb_late *lat, Reverb_eq *eq, ReverbUI *ui) { com->dry = 1 - ui->wetdry_ratio / 100; com->early = ui->wetdry_ratio / 100; com->late = ui->wetdry_ratio / 100; com->input_mix_on = 0; com->input_mix = 0; com->high_cut_on = 0; com->high_cut = 0; com->low_cut_on = 0; com->low_cut = 0; com->cross_seed = 0; tap->multi_taps_on = 1; tap->taps_count = ui->density / 10.0f; tap->taps_delay = ui->pre_delay / 200.0f; tap->taps_decay = ui->reverb_time / 20.0f; tap->taps_length = ui->reverb_time / 20.0f; ear->early_difus_on = 1; ear->early_count = ui->density / 10.0f; ear->early_delay = ui->pre_delay / 200.0f; ear->early_feedback = 0.5; ear->early_mod_amt = ui->diffusion / 10.0f; ear->early_mod_rate = ui->diffusion / 10.0f; lat->late_mode = 1; lat->late_reflect_on = 1; lat->line_count = ui->density / 10.0f; lat->line_size = ui->reverb_time / 20.0f; lat->line_mod_amt = ui->diffusion / 10.0f; lat->line_mod_rate = ui->reverb_time / 20.0f; lat->difus_count = ui->density / 10.0f; lat->difus_delay = ui->pre_delay / 200.0f; lat->difus_feedback = ui->reverb_time / 20.0f; lat->difus_mod_amt = ui->diffusion / 10.0f; lat->difus_mod_rate = ui->diffusion / 10.0f; eq->low_shelf_on = 0; eq->high_shelf_on = 0; eq->low_pass_on = 0; eq->low_shelf_freq = 0; eq->low_shelf_gain = 0; eq->high_shelf_freq = 0; eq->high_shelf_gain = 0; eq->low_pass_freq = 0; } void reverb_wrapper_init(void **p, int channels, int frame_size, int sample_rate, double room_size, double wetdry_ratio, double reverb_time, double pre_delay, double high_damp_freq, double high_ratio, double diffusion, double density, double hpf, double lpf ) { ReverbUI ui = {room_size, wetdry_ratio, reverb_time, pre_delay, high_damp_freq, high_ratio, diffusion, density, hpf, lpf}; c_t.sample_rate = sample_rate; params_chg(&c_t, &t_t, &e_t, &l_t, &eq_t, &ui); *(Reverb **)p = reverb_new(channels, frame_size, &c_t, &t_t, &e_t, &l_t, &eq_t); ch = channels; n = frame_size; // FILE *file = fopen("debug.txt", "w"); // if (NULL == file) return; // // fprintf(file, "GUI params:\n"); // fprintf(file, "late_refl_on:%d.\n", l_t.late_reflect_on); // fprintf(file, "FS:%d dry:%2.2f early:%2.2f late:%2.2f inp_on:%d h_c_on:%d l_c_on:%d in_mix:%2.2f h_c:%2.2f l_c:%2.2f c_s:%2.2f.\n", // c_t.sample_rate, c_t.dry, c_t.early, c_t.late, c_t.input_mix_on, c_t.high_cut_on, \ // c_t.low_cut_on, c_t.input_mix, c_t.high_cut, c_t.low_cut, c_t.cross_seed); // fclose(file); } void reverb_wrapper_process(void *p, int sample_rate, double room_size, double wetdry_ratio, double reverb_time, double pre_delay, double high_damp_freq, double high_ratio, double diffusion, double density, double hpf, double lpf, float *src, float *dst) { int i; for(i = 0; i < ch; i ++) x[i] = src + i * n; for(i = 0; i < ch; i ++) y[i] = dst + i * n; reverb_process(p, x, y); ReverbUI uip = {room_size, wetdry_ratio, reverb_time, pre_delay, high_damp_freq, high_ratio, diffusion, density, hpf, lpf}; params_chg(&c_t, &t_t, &e_t, &l_t, &eq_t, &uip); Reverb params = {ch, n, {sample_rate, c_t.dry, c_t.early, c_t.late, c_t.input_mix_on, c_t.high_cut_on, c_t.low_cut_on, c_t.input_mix, c_t.high_cut, c_t.low_cut, c_t.cross_seed}, {t_t.multi_taps_on, t_t.taps_count, t_t.taps_delay, t_t.taps_decay, t_t.taps_length}, {e_t.early_difus_on, e_t.early_count, e_t.early_delay, e_t.early_feedback, e_t.early_mod_amt, e_t.early_mod_rate}, {l_t.late_mode, l_t.late_reflect_on, l_t.line_count, l_t.line_size, l_t.line_mod_amt, l_t.line_mod_rate}, {eq_t.low_shelf_on, eq_t.high_shelf_on, eq_t.low_pass_on, eq_t.low_shelf_freq, eq_t.low_shelf_gain, eq_t.high_shelf_freq, eq_t.high_shelf_gain, eq_t.low_pass_freq}, }; reverb_params_set(¶ms); } #else void reverb_wrapper_init(void **p, int channels, int frame_size, int sample_rate, double dry, double early, double late, int input_mix_on, int hight_cut_on, // 6 int low_cut_on, double input_mix, double high_cut_freq, double low_cut_freq, double cross_seed, int taps_on, double taps_count, double taps_pre_delay, double taps_decay, double taps_length, int early_difus_on, double early_difus_count, double early_difus_delay, // 13 double early_difus_feedback, double early_difus_mod_amt, double early_difus_mod_rate, int late_mode, int late_reflect_on, double late_line_count, double late_line_size, double late_line_mod_amt, double late_line_decay, double late_line_mod_rate, double late_difus_count, double late_difus_delay, // 12 double late_difus_feedback, double late_difus_mod_amt, double late_difus_mod_rate, int eq_low_shelf_on, int eq_high_shelf_on, int eq_low_pass_on, double eq_low_shelf_freq, double eq_low_shelf_gain, double eq_high_shelf_freq, double eq_high_shelf_gain, double eq_low_pass_freq // 11 ) { Reverb_common c_t = {sample_rate, dry, early, late, input_mix_on, hight_cut_on, low_cut_on, input_mix, high_cut_freq, low_cut_freq, cross_seed}; Reverb_taps t_t = {taps_on, taps_count, taps_pre_delay, taps_decay, taps_length}; Reverb_early e_t = {early_difus_on, early_difus_count, early_difus_delay, early_difus_feedback, early_difus_mod_amt, early_difus_mod_rate}; Reverb_late l_t = {late_mode, late_reflect_on, late_line_count, late_line_size, late_line_mod_amt, late_line_decay, late_line_mod_rate, late_difus_count, late_difus_delay, late_difus_feedback, late_difus_mod_amt, late_difus_mod_rate}; Reverb_eq eq_t = {eq_low_shelf_on, eq_high_shelf_on, eq_low_pass_on, eq_low_shelf_freq, eq_low_shelf_gain, eq_high_shelf_freq, eq_high_shelf_gain, eq_low_pass_freq}; *(Reverb **)p = reverb_new(channels, frame_size, &c_t, &t_t, &e_t, &l_t, &eq_t); ch = channels; n = frame_size; // FILE *file = fopen("second.txt", "w"); // if (NULL == file) return; // // fprintf(file, "GUI params:\n"); // fprintf(file, "difus_on:%d count:%2.4f delay:%2.4f feedback:%2.4f mod_amt:%2.4f mod_rate:%2.4f .\n", // e_t.early_difus_on, e_t.early_count, e_t.early_delay, e_t.early_feedback, e_t.early_mod_amt, e_t.early_mod_rate); // fclose(file); } void reverb_wrapper_process(void *p, int sample_rate, double dry, double early, double late, int input_mix_on, int hight_cut_on, // 6 int low_cut_on, double input_mix, double high_cut_freq, double low_cut_freq, double cross_seed, int taps_on, double taps_count, double taps_pre_delay, double taps_decay, double taps_length, int early_difus_on, double early_difus_count, double early_difus_delay, // 13 double early_difus_feedback, double early_difus_mod_amt, double early_difus_mod_rate, int late_mode, int late_reflect_on, double late_line_count, double late_line_size, double late_line_mod_amt, double late_line_decay, double late_line_mod_rate, double late_difus_count, double late_difus_delay, // 12 double late_difus_feedback, double late_difus_mod_amt, double late_difus_mod_rate, int eq_low_shelf_on, int eq_high_shelf_on, int eq_low_pass_on, double eq_low_shelf_freq, double eq_low_shelf_gain, double eq_high_shelf_freq, double eq_high_shelf_gain, double eq_low_pass_freq, float *src, float *dst) { int i; for(i = 0; i < ch; i ++) x[i] = src + i * n; for(i = 0; i < ch; i ++) y[i] = dst + i * n; reverb_process(p, x, y); Reverb params = {ch, n, {sample_rate, dry, early, late, input_mix_on, hight_cut_on, low_cut_on, input_mix, high_cut_freq, low_cut_freq, cross_seed}, {taps_on, taps_count, taps_pre_delay, taps_decay, taps_length}, {early_difus_on, early_difus_count, early_difus_delay, early_difus_feedback, early_difus_mod_amt, early_difus_mod_rate}, {late_mode, late_reflect_on, late_line_count, late_line_size, late_line_mod_amt, late_line_mod_rate}, {eq_low_shelf_on, eq_high_shelf_on, eq_low_pass_on, eq_low_shelf_freq, eq_low_shelf_gain, eq_high_shelf_freq, eq_high_shelf_gain, eq_low_pass_freq}, }; reverb_params_set(¶ms); } #endif void reverb_wrapper_delete(void *p) { reverb_delete(p); }