aboutsummaryrefslogtreecommitdiff
path: root/randomblock~.c
diff options
context:
space:
mode:
Diffstat (limited to 'randomblock~.c')
-rw-r--r--randomblock~.c83
1 files changed, 44 insertions, 39 deletions
diff --git a/randomblock~.c b/randomblock~.c
index dca780d..d9e2fe0 100644
--- a/randomblock~.c
+++ b/randomblock~.c
@@ -52,64 +52,69 @@ typedef struct _randomblock
t_int x_limit;
} t_randomblock;
- /* clean up */
-static void randomblock_free(t_randomblock *x)
+/* clean up */
+static void randomblock_free(t_randomblock *x)
{
}
static void *randomblock_new(t_float flimit)
{
- t_randomblock *x = (t_randomblock *)pd_new(randomblock_class);
- outlet_new(&x->x_obj, &s_signal);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("limit"));
- if ( flimit <= 0 || flimit > RAND_MAX ) {
- post( "randomblock~: wrong creation argument" );
- return NULL;
- }
- x->x_limit = (int) flimit;
- return(x);
+ t_randomblock *x = (t_randomblock *)pd_new(randomblock_class);
+ outlet_new(&x->x_obj, &s_signal);
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("limit"));
+ if ( flimit <= 0 || flimit > RAND_MAX )
+ {
+ post( "randomblock~: wrong creation argument" );
+ return NULL;
+ }
+ x->x_limit = (int) flimit;
+ return(x);
}
static void *randomblock_limit(t_randomblock* x, t_float flimit)
{
- if ( flimit < 0 || flimit > RAND_MAX ) {
- post( "randomblock~: wrong random limit" );
- return;
- } else {
- x->x_limit=(int)flimit;
- }
+ if ( flimit < 0 || flimit > RAND_MAX )
+ {
+ post( "randomblock~: wrong random limit" );
+ return;
+ }
+ else
+ {
+ x->x_limit=(int)flimit;
+ }
}
static t_int *randomblock_perform(t_int *w)
{
- t_float *out = (t_float*) w[1];
- int n = (int)(w[2]);
- t_randomblock *x = (t_randomblock*) w[3];
-
- int rvalue = rand();
- // post("random value : %d", rvalue );
- rvalue = rvalue%(x->x_limit-n);
- // post("modulated by %d : %d", (x->x_limit-n), rvalue );
- if ( rvalue < 0 ) rvalue=0;
-
- while (n--) {
- *(out)++=(float)rvalue++;
- }
-
- return (w+4);
+ t_float *out = (t_float*) w[1];
+ int n = (int)(w[2]);
+ t_randomblock *x = (t_randomblock*) w[3];
+
+ int rvalue = rand();
+ // post("random value : %d", rvalue );
+ rvalue = rvalue%(x->x_limit-n);
+ // post("modulated by %d : %d", (x->x_limit-n), rvalue );
+ if ( rvalue < 0 ) rvalue=0;
+
+ while (n--)
+ {
+ *(out)++=(float)rvalue++;
+ }
+
+ return (w+4);
}
static void randomblock_dsp(t_randomblock *x, t_signal **sp)
{
- dsp_add( randomblock_perform, 3, sp[0]->s_vec, sp[0]->s_n, x ) ;
+ dsp_add( randomblock_perform, 3, sp[0]->s_vec, sp[0]->s_n, x ) ;
}
void randomblock_tilde_setup(void)
{
- verbose(0, randomblock_version);
- randomblock_class = class_new(gensym("randomblock~"), (t_newmethod)randomblock_new,
- (t_method)randomblock_free,
- sizeof(t_randomblock), 0, A_DEFFLOAT, 0);
- class_addmethod( randomblock_class, (t_method)randomblock_dsp, gensym("dsp"), 0);
- class_addmethod( randomblock_class, (t_method)randomblock_limit, gensym("limit"), A_FLOAT, 0);
+ verbose(0, randomblock_version);
+ randomblock_class = class_new(gensym("randomblock~"), (t_newmethod)randomblock_new,
+ (t_method)randomblock_free,
+ sizeof(t_randomblock), 0, A_DEFFLOAT, 0);
+ class_addmethod( randomblock_class, (t_method)randomblock_dsp, gensym("dsp"), 0);
+ class_addmethod( randomblock_class, (t_method)randomblock_limit, gensym("limit"), A_FLOAT, 0);
}