Commit 5e9124e9 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

cast dsp_add args to (t_int) for int types (like s_n of t_signal)

This gets rid of some undefined behavior that occurs from sending an
int as an argument to dsp_add which reads it back as a t_int. On certain
archs this will produce garbage values in the perform routine which can
cause crashes.
parent 99e0618c
......@@ -547,7 +547,7 @@ void autotune_dsp(t_autotune *x, t_signal **sp, short *count)
if(x->fs != sp[0]->s_sr) autotune_init(x, sp[0]->s_sr);
dsp_add(autotune_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
dsp_add(autotune_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, (t_int)sp[0]->s_n);
}
......
......@@ -230,7 +230,8 @@ static t_int *bassemu_perform(t_int *ww)
static void bassemu_dsp(t_bassemu *x, t_signal **sp)
{
x->sr = sp[0]->s_sr;
dsp_add(bassemu_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
dsp_add(bassemu_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec,
(t_int)sp[0]->s_n);
}
static void recalc(t_bassemu *x)
......
......@@ -99,7 +99,7 @@ static t_int *aenv_perform(t_int *w)
static void aenv_dsp(t_aenv *x, t_signal **sp)
{
dsp_add(aenv_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
dsp_add(aenv_perform, 3, x, sp[0]->s_vec, (t_int)sp[0]->s_n);
}
static void aenv_float(t_aenv *x, t_float f)
......
......@@ -337,7 +337,7 @@ static void partconv_dsp(t_partconv *x, t_signal **sp)
partconv_set(x, x->arrayname);
}
dsp_add(partconv_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
dsp_add(partconv_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, (t_int)sp[0]->s_n);
}
static void *partconv_new(t_symbol *s, int argc, t_atom *argv)
......
......@@ -258,7 +258,7 @@ static t_int *pvoc_perform(t_int *w)
static void pvoc_dsp(t_pvoc *x, t_signal **sp)
{
dsp_add(pvoc_perform, 5, x, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n);
dsp_add(pvoc_perform, 5, x, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, (t_int)sp[0]->s_n);
}
// adapted from jsarlo's windowing library
......
......@@ -88,7 +88,7 @@ static t_int *susloop_perform(t_int *w)
static void susloop_dsp(t_susloop *x, t_signal **sp)
{
dsp_add(susloop_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
dsp_add(susloop_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, (t_int)sp[0]->s_n);
}
static void *susloop_new(t_symbol *s, int argc, t_atom *argv)
......
......@@ -124,7 +124,7 @@ static t_int *svf_perform(t_int *w)
static void svf_dsp(t_svf *x, t_signal **sp)
{
dsp_add(svf_perform, 7, x, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, sp[4]->s_vec, sp[0]->s_n);
dsp_add(svf_perform, 7, x, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, sp[4]->s_vec, (t_int)sp[0]->s_n);
}
static void *svf_new(t_symbol *s, int argc, t_atom *argv)
......
......@@ -59,7 +59,7 @@ static t_int *zhzxh_perform(t_int *w)
static void zhzxh_dsp(t_zhzxh *x, t_signal **sp)
{
dsp_add(zhzxh_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
dsp_add(zhzxh_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, (t_int)sp[0]->s_n);
}
static void *zhzxh_new(t_symbol *s, int argc, t_atom *argv)
......
......@@ -77,7 +77,7 @@ static t_int *biquadseries_perform(t_int *w)
static void biquadseries_dsp(t_biquadseries *x, t_signal **sp)
{
dsp_add(biquadseries_perform, 4, x->biquadseries, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec);
dsp_add(biquadseries_perform, 4, x->biquadseries, (t_int)sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec);
}
void biquadseries_free(void)
......
......@@ -478,30 +478,30 @@ static void blosc_dsp(t_blosc *x, t_signal **sp)
if (x->x_ctl.c_waveform == gensym("syncsaw")){
x->x_ctl.c_scale = 1.0;
x->x_ctl.c_scale_update = 1.0;
dsp_add(blosc_perform_hardsync_saw, 5, &x->x_ctl, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec);
dsp_add(blosc_perform_hardsync_saw, 5, &x->x_ctl, (t_int)sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec);
}
/* 1 osc */
else if (x->x_ctl.c_waveform == gensym("pulse")){
x->x_ctl.c_scale = 1.0;
x->x_ctl.c_scale_update = 1.0;
dsp_add(blosc_perform_pulse, 4, &x->x_ctl, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec);
dsp_add(blosc_perform_pulse, 4, &x->x_ctl, (t_int)sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec);
}
else if (x->x_ctl.c_waveform == gensym("pulse2")){
x->x_ctl.c_phase_inc_scale *= 2;
x->x_ctl.c_scale = 1.0;
x->x_ctl.c_scale_update = -1.0;
dsp_add(blosc_perform_pulse, 4, &x->x_ctl, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec);
dsp_add(blosc_perform_pulse, 4, &x->x_ctl, (t_int)sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec);
}
else if (x->x_ctl.c_waveform == gensym("comparator")){
x->x_ctl.c_scale = 1.0;
x->x_ctl.c_scale_update = 1.0;
dsp_add(blosc_perform_comparator, 4, &x->x_ctl, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec);
dsp_add(blosc_perform_comparator, 4, &x->x_ctl, (t_int)sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec);
}
else{
x->x_ctl.c_scale = 1.0;
x->x_ctl.c_scale_update = 1.0;
dsp_add(blosc_perform_saw, 4, &x->x_ctl, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec);
dsp_add(blosc_perform_saw, 4, &x->x_ctl, (t_int)sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec);
}
......
......@@ -68,7 +68,8 @@ static t_int *filterortho_perform(t_int *w)
static void filterortho_dsp(t_filterortho *x, t_signal **sp)
{
dsp_add(filterortho_perform, 4, x->filterortho, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec);
dsp_add(filterortho_perform, 4, x->filterortho, (t_int)sp[0]->s_n,
sp[0]->s_vec, sp[1]->s_vec);
}
void filterortho_free(t_filterortho *x)
......
......@@ -30,7 +30,7 @@ static t_int *abs_perform(t_int *w)
static void abs_dsp(t_abs *x, t_signal **sp)
{
dsp_add(abs_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
dsp_add(abs_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, (t_int)sp[0]->s_n);
}
static void *abs_new(void)
......
......@@ -215,7 +215,7 @@ static void bdiag_dsp(t_bdiag *x, t_signal **sp)
}
dsp_add(bdiag_perform, 4, &x->x_ctl, sp[0]->s_n,
dsp_add(bdiag_perform, 4, &x->x_ctl, (t_int)sp[0]->s_n,
sp[0]->s_vec, sp[1]->s_vec);
}
......
......@@ -177,7 +177,7 @@ static void bfft_dsp(t_bfft *x, t_signal **sp)
in = out;
}
dsp_add(bfft_perform, 4, &x->x_ctl, n, in, out);
dsp_add(bfft_perform, 4, &x->x_ctl, (t_int)n, in, out);
}
......@@ -196,7 +196,7 @@ static void ibfft_dsp(t_bfft *x, t_signal **sp)
in = out;
}
dsp_add(ibfft_perform, 4, &x->x_ctl, n, in, out);
dsp_add(ibfft_perform, 4, &x->x_ctl, (t_int)n, in, out);
}
......@@ -214,7 +214,7 @@ static void fht_dsp(t_bfft *x, t_signal **sp)
in = out;
}
dsp_add(fht_perform, 4, &x->x_ctl, n, in, out);
dsp_add(fht_perform, 4, &x->x_ctl, (t_int)n, in, out);
}
......
......@@ -71,7 +71,7 @@ static void bitsplit_dsp(t_bitsplit *x, t_signal **sp)
for (i=0;i<x->x_ctl.c_outputs;i++){
x->x_ctl.c_output[i] = sp[i+1]->s_vec;
}
dsp_add(bitsplit_perform, 2, &x->x_ctl, sp[0]->s_n);
dsp_add(bitsplit_perform, 2, &x->x_ctl, (t_int)sp[0]->s_n);
}
......
......@@ -90,7 +90,7 @@ static void blocknorm_dsp(t_blocknorm *x, t_signal **sp)
x->x_ctl.c_input[i] = sp[i]->s_vec;
x->x_ctl.c_output[i] = sp[c+i]->s_vec;
}
dsp_add(blocknorm_perform, 2, &x->x_ctl, sp[0]->s_n);
dsp_add(blocknorm_perform, 2, &x->x_ctl, (t_int)sp[0]->s_n);
}
......
......@@ -102,7 +102,8 @@ static void matrix_dsp(t_matrix *x, t_signal **sp)
for (i=0;i<n;i++) x->x_ctl.c_A[i] = 1;
dsp_add(matrix_perform, 4, &x->x_ctl, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec);
dsp_add(matrix_perform, 4, &x->x_ctl, (t_int)sp[0]->s_n, sp[0]->s_vec,
sp[1]->s_vec);
}
......
......@@ -138,7 +138,7 @@ static void window_dsp(t_window *x, t_signal **sp)
window_type(x, x->x_type, x->x_typearg);
}
dsp_add(window_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, n);
dsp_add(window_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, (t_int)n);
}
static void window_free(t_window *x)
......
......@@ -91,7 +91,7 @@ static t_int *cheby_perform(t_int *w)
static void cheby_dsp(t_cheby *x, t_signal **sp)
{
dsp_add(cheby_perform, 4, &x->x_ctl, sp[0]->s_n,
dsp_add(cheby_perform, 4, &x->x_ctl, (t_int)sp[0]->s_n,
sp[0]->s_vec, sp[1]->s_vec);
}
......
......@@ -126,7 +126,7 @@ static t_int *cmath_perform_nifft(t_int *w)
static void cmath_dsp(t_cmath *x, t_signal **sp)
{
dsp_add(x->x_perf, 5, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec);
dsp_add(x->x_perf, 5, (t_int)sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec);
}
void cmath_free(void)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment