From 739a8290a8b05645a2d055aed8e5eb76ba2e24e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Fri, 28 Aug 2015 17:55:26 +0000 Subject: one-true indentation svn path=/trunk/externals/zexy/; revision=17537 --- src/noisi~.c | 82 +++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 45 insertions(+), 37 deletions(-) (limited to 'src/noisi~.c') diff --git a/src/noisi~.c b/src/noisi~.c index b62d5d3..8577ac9 100644 --- a/src/noisi~.c +++ b/src/noisi~.c @@ -1,4 +1,4 @@ -/* +/* * noisi~: bandlimited noise generator * * (c) 1999-2011 IOhannes m zmölnig, forum::für::umläute, institute of electronic music and acoustics (iem) @@ -7,12 +7,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ @@ -20,11 +20,11 @@ /* 30041999 - two bandlimited noise gnerators based on DODGE/JERSE "computer music" c3.9 : RANDI & RANDH - + two bandlimited noise gnerators based on DODGE/JERSE "computer music" c3.9 : RANDI & RANDH + I do not care for copyrights - (all in all, the used noise~-code (in fact, the pseude-random-code) is from Miller Puckette - and I made only very few modifications so look out for the LICENSE.TXT delivered with + (all in all, the used noise~-code (in fact, the pseude-random-code) is from Miller Puckette + and I made only very few modifications so look out for the LICENSE.TXT delivered with puredata for further (c)-information forum für umläute 1999 @@ -40,13 +40,12 @@ /* general */ -typedef struct _nois -{ +typedef struct _nois { t_object x_obj; int val; t_sample current; t_sample decrement; - t_sample updater; + t_sample updater; t_sample to_go; } t_nois; @@ -54,10 +53,9 @@ typedef struct _nois static void set_noisfreq(t_nois *x, t_floatarg freq) { x->updater = (freq > 0) ? sys_getsr() / freq : 1; - if (x->updater < 1) - { - x->updater = 1; - } + if (x->updater < 1) { + x->updater = 1; + } x->to_go = 0; } @@ -69,20 +67,24 @@ static void set_noisseed(t_nois *x, t_floatarg seed) -/* ------------------------ noisi~ ----------------------------- */ +/* ------------------------ noisi~ ----------------------------- */ static t_class *noisi_class; -static inline t_sample int2sample(int i) { - return ((t_sample)(i & 0x7fffffff) - 0x40000000) * (t_sample)(1.0 / 0x40000000); +static inline t_sample int2sample(int i) +{ + return ((t_sample)(i & 0x7fffffff) - 0x40000000) * (t_sample)( + 1.0 / 0x40000000); } -static inline int update_intNoise(int i) { +static inline int update_intNoise(int i) +{ i *= 435898247; i += 382842987; return i; } -static t_int *noisi_perform(t_int *w){ +static t_int *noisi_perform(t_int *w) +{ t_nois *x = (t_nois *)(w[1]); t_sample *out = (t_sample *)(w[2]); int n = (int)(w[3]); @@ -94,18 +96,18 @@ static t_int *noisi_perform(t_int *w){ t_sample still_to_go = x->to_go; if (all_to_go == 1) { - /* this is "pure white" noise, so we have to calculate each sample */ + /* this is "pure white" noise, so we have to calculate each sample */ while (n--) { *out++ = int2sample(i_value=update_intNoise(i_value)); } } else if (n < still_to_go) { - /* signal won't change for the next 64 samples */ + /* signal won't change for the next 64 samples */ still_to_go -= n; - while (n--){ + while (n--) { *out++ = (f_value -= decrement); } } else if (all_to_go + still_to_go > n) { - /* only one update calculation necessary for 64 samples !!! */ + /* only one update calculation necessary for 64 samples !!! */ while (still_to_go-- > 0) { n--; *out++ = (f_value -= decrement); @@ -120,13 +122,13 @@ static t_int *noisi_perform(t_int *w){ *out++ = (f_value -= decrement); } } else { - /* anything else */ + /* anything else */ while (n--) { - if (still_to_go-- <= 0) { /* update only if all time has elapsed */ - still_to_go += all_to_go; - f_value=int2sample(i_value); - i_value=update_intNoise(i_value); - decrement = (f_value - int2sample(i_value)) / all_to_go; + if (still_to_go-- <= 0) { /* update only if all time has elapsed */ + still_to_go += all_to_go; + f_value=int2sample(i_value); + i_value=update_intNoise(i_value); + decrement = (f_value - int2sample(i_value)) / all_to_go; } *out++ = (f_value -= decrement); } @@ -136,16 +138,18 @@ static t_int *noisi_perform(t_int *w){ x->current = f_value; x->decrement = decrement; x->to_go = still_to_go; - + return (w+4); } -static void noisi_dsp(t_nois *x, t_signal **sp){ +static void noisi_dsp(t_nois *x, t_signal **sp) +{ dsp_add(noisi_perform, 3, x, sp[0]->s_vec, sp[0]->s_n); } -static void noisi_helper(void){ +static void noisi_helper(void) +{ post("\n"HEARTSYMBOL" noisi~\t:: a bandlimited interpolating pseudo-noise generator"); post("\t : sampling-frequency (in Hz)\n" "'help'\t : view this"); @@ -157,9 +161,10 @@ static void noisi_helper(void){ post("for further details see DODGE/JERSE \"computer music\" c3.9\n"); } -static void *noisi_new(t_floatarg f){ +static void *noisi_new(t_floatarg f) +{ t_nois *x = (t_nois *)pd_new(noisi_class); - + static int init = 4259; x->val = (init *= 17); @@ -169,13 +174,16 @@ static void *noisi_new(t_floatarg f){ return (x); } -void noisi_tilde_setup(void){ - noisi_class = class_new(gensym("noisi~"), (t_newmethod)noisi_new, 0, sizeof(t_nois), 0, A_DEFFLOAT, 0); +void noisi_tilde_setup(void) +{ + noisi_class = class_new(gensym("noisi~"), (t_newmethod)noisi_new, 0, + sizeof(t_nois), 0, A_DEFFLOAT, 0); class_addfloat(noisi_class, set_noisfreq); class_addmethod(noisi_class, (t_method)noisi_dsp, gensym("dsp"), 0); - class_addmethod(noisi_class, (t_method)set_noisseed, gensym("seed"), A_FLOAT, 0); + class_addmethod(noisi_class, (t_method)set_noisseed, gensym("seed"), + A_FLOAT, 0); class_addmethod(noisi_class, (t_method)noisi_helper, gensym("help"), 0); zexy_register("noisi~"); -- cgit v1.2.1