From ed932acb5860bf8b9296169676499562a55d139e Mon Sep 17 00:00:00 2001 From: Miller Puckette Date: Mon, 6 Sep 2004 20:20:36 +0000 Subject: checking in version 0.38test5. Oops, I realize I forgot some more nice files, will add them and re-commit. svn path=/trunk/; revision=2010 --- pd/src/d_fft.c | 108 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 54 insertions(+), 54 deletions(-) (limited to 'pd/src/d_fft.c') diff --git a/pd/src/d_fft.c b/pd/src/d_fft.c index 7e5a95a3..6a5a1372 100644 --- a/pd/src/d_fft.c +++ b/pd/src/d_fft.c @@ -39,10 +39,10 @@ static t_int *sigfft_swap(t_int *w) float *in2 = (t_float *)(w[2]); int n = w[3]; for (;n--; in1++, in2++) - { - float f = *in1; - *in1 = *in2; - *in2 = f; + { + float f = *in1; + *in1 = *in2; + *in2 = f; } return (w+4); } @@ -73,16 +73,16 @@ static void sigfft_dspx(t_sigfft *x, t_signal **sp, t_int *(*f)(t_int *w)) float *out1 = sp[2]->s_vec; float *out2 = sp[3]->s_vec; if (out1 == in2 && out2 == in1) - dsp_add(sigfft_swap, 3, out1, out2, n); + dsp_add(sigfft_swap, 3, out1, out2, n); else if (out1 == in2) { - dsp_add(copy_perform, 3, in2, out2, n); - dsp_add(copy_perform, 3, in1, out1, n); + dsp_add(copy_perform, 3, in2, out2, n); + dsp_add(copy_perform, 3, in1, out1, n); } else { - if (out1 != in1) dsp_add(copy_perform, 3, in1, out1, n); - if (out2 != in2) dsp_add(copy_perform, 3, in2, out2, n); + if (out1 != in1) dsp_add(copy_perform, 3, in1, out1, n); + if (out2 != in2) dsp_add(copy_perform, 3, in2, out2, n); } dsp_add(f, 3, sp[2]->s_vec, sp[3]->s_vec, n); } @@ -100,12 +100,12 @@ static void sigifft_dsp(t_sigfft *x, t_signal **sp) static void sigfft_setup(void) { sigfft_class = class_new(gensym("fft~"), sigfft_new, 0, - sizeof(t_sigfft), 0, 0); + sizeof(t_sigfft), 0, 0); CLASS_MAINSIGNALIN(sigfft_class, t_sigfft, x_f); class_addmethod(sigfft_class, (t_method)sigfft_dsp, gensym("dsp"), 0); sigifft_class = class_new(gensym("ifft~"), sigifft_new, 0, - sizeof(t_sigfft), 0, 0); + sizeof(t_sigfft), 0, 0); CLASS_MAINSIGNALIN(sigifft_class, t_sigfft, x_f); class_addmethod(sigifft_class, (t_method)sigifft_dsp, gensym("dsp"), 0); class_sethelpsymbol(sigifft_class, gensym("fft~")); @@ -136,7 +136,7 @@ static t_int *sigrfft_flip(t_int *w) float *out = (t_float *)(w[2]); int n = w[3]; while (n--) *(--out) = *in++; - *(--out) = 0; /* to hell with it */ + *(--out) = 0; /* to hell with it */ return (w+4); } @@ -156,20 +156,20 @@ static void sigrfft_dsp(t_sigrfft *x, t_signal **sp) float *out2 = sp[2]->s_vec; if (n < 4) { - error("fft: minimum 4 points"); - return; + error("fft: minimum 4 points"); + return; } - if (in1 == out2) /* this probably never happens */ + if (in1 == out2) /* this probably never happens */ { - dsp_add(sigrfft_perform, 2, out2, n); - dsp_add(copy_perform, 3, out2, out1, n2); - dsp_add(sigrfft_flip, 3, out2 + (n2+1), out2 + n2, n2-1); + dsp_add(sigrfft_perform, 2, out2, n); + dsp_add(copy_perform, 3, out2, out1, n2); + dsp_add(sigrfft_flip, 3, out2 + (n2+1), out2 + n2, n2-1); } else { - if (in1 != out1) dsp_add(copy_perform, 3, in1, out1, n); - dsp_add(sigrfft_perform, 2, out1, n); - dsp_add(sigrfft_flip, 3, out1 + (n2+1), out2 + n2, n2-1); + if (in1 != out1) dsp_add(copy_perform, 3, in1, out1, n); + dsp_add(sigrfft_perform, 2, out1, n); + dsp_add(sigrfft_flip, 3, out1 + (n2+1), out2 + n2, n2-1); } dsp_add_zero(out1 + n2, n2); dsp_add_zero(out2 + n2, n2); @@ -178,7 +178,7 @@ static void sigrfft_dsp(t_sigrfft *x, t_signal **sp) static void sigrfft_setup(void) { sigrfft_class = class_new(gensym("rfft~"), sigrfft_new, 0, - sizeof(t_sigrfft), 0, 0); + sizeof(t_sigrfft), 0, 0); CLASS_MAINSIGNALIN(sigrfft_class, t_sigrfft, x_f); class_addmethod(sigrfft_class, (t_method)sigrfft_dsp, gensym("dsp"), 0); class_sethelpsymbol(sigrfft_class, gensym("fft~")); @@ -219,18 +219,18 @@ static void sigrifft_dsp(t_sigrifft *x, t_signal **sp) float *out1 = sp[2]->s_vec; if (n < 4) { - error("fft: minimum 4 points"); - return; + error("fft: minimum 4 points"); + return; } if (in2 == out1) { - dsp_add(sigrfft_flip, 3, out1+1, out1 + n, (n2-1)); - dsp_add(copy_perform, 3, in1, out1, n2); + dsp_add(sigrfft_flip, 3, out1+1, out1 + n, (n2-1)); + dsp_add(copy_perform, 3, in1, out1, n2); } else { - if (in1 != out1) dsp_add(copy_perform, 3, in1, out1, n2); - dsp_add(sigrfft_flip, 3, in2+1, out1 + n, n2-1); + if (in1 != out1) dsp_add(copy_perform, 3, in1, out1, n2); + dsp_add(sigrfft_flip, 3, in2+1, out1 + n, n2-1); } dsp_add(sigrifft_perform, 2, out1, n); } @@ -238,7 +238,7 @@ static void sigrifft_dsp(t_sigrifft *x, t_signal **sp) static void sigrifft_setup(void) { sigrifft_class = class_new(gensym("rifft~"), sigrifft_new, 0, - sizeof(t_sigrifft), 0, 0); + sizeof(t_sigrifft), 0, 0); CLASS_MAINSIGNALIN(sigrifft_class, t_sigrifft, x_f); class_addmethod(sigrifft_class, (t_method)sigrifft_dsp, gensym("dsp"), 0); class_sethelpsymbol(sigrifft_class, gensym("fft~")); @@ -282,27 +282,27 @@ static t_int *sigframp_perform(t_int *w) n -= 2; while (n--) { - float re, im, pow, freq; - lastreal = currentreal; - currentreal = nextreal; - nextreal = *inreal++; - lastimag = currentimag; - currentimag = nextimag; - nextimag = *inimag++; - re = currentreal - 0.5f * (lastreal + nextreal); - im = currentimag - 0.5f * (lastimag + nextimag); - pow = re * re + im * im; - if (pow > 1e-19) - { - float detune = ((lastreal - nextreal) * re + - (lastimag - nextimag) * im) / (2.0f * pow); - if (detune > 2 || detune < -2) freq = pow = 0; - else freq = fbin + detune; - } - else freq = pow = 0; - *outfreq++ = freq; - *outamp++ = oneovern2 * pow; - fbin += 1.0f; + float re, im, pow, freq; + lastreal = currentreal; + currentreal = nextreal; + nextreal = *inreal++; + lastimag = currentimag; + currentimag = nextimag; + nextimag = *inimag++; + re = currentreal - 0.5f * (lastreal + nextreal); + im = currentimag - 0.5f * (lastimag + nextimag); + pow = re * re + im * im; + if (pow > 1e-19) + { + float detune = ((lastreal - nextreal) * re + + (lastimag - nextimag) * im) / (2.0f * pow); + if (detune > 2 || detune < -2) freq = pow = 0; + else freq = fbin + detune; + } + else freq = pow = 0; + *outfreq++ = freq; + *outamp++ = oneovern2 * pow; + fbin += 1.0f; } while (m--) *outamp++ = *outfreq++ = 0; return (w+6); @@ -315,18 +315,18 @@ static void sigframp_dsp(t_sigframp *x, t_signal **sp) int n = sp[0]->s_n, n2 = (n>>1); if (n < 4) { - error("framp: minimum 4 points"); - return; + error("framp: minimum 4 points"); + return; } dsp_add(sigframp_perform, 5, sp[0]->s_vec, sp[1]->s_vec, - sp[2]->s_vec, sp[3]->s_vec, n2); + sp[2]->s_vec, sp[3]->s_vec, n2); dsp_add(sigsqrt_perform, 3, sp[3]->s_vec, sp[3]->s_vec, n2); } static void sigframp_setup(void) { sigframp_class = class_new(gensym("framp~"), sigframp_new, 0, - sizeof(t_sigframp), 0, 0); + sizeof(t_sigframp), 0, 0); CLASS_MAINSIGNALIN(sigframp_class, t_sigframp, x_f); class_addmethod(sigframp_class, (t_method)sigframp_dsp, gensym("dsp"), 0); } -- cgit v1.2.1