All pastes #25671 Raw Edit

my insanety

public c v1 · immutable
#25671 ·published 2005-10-16 14:33 UTC
rendered paste body
static t_int *adsr_perform(t_int *w){    t_adsr *x = (t_adsr *)(w[1]);    t_float *in = (t_float *)(w[2]);    t_float *out = (t_float *)(w[3]);    t_float count2;    int n = (int)(w[4]);    float *adsr=&x->adsr[0];    float *adsr2=&x->adsr2[0];     float *breakpt=&x->breakpt[0];    float *inc=&x->inc[0];    float count=x->count;    double sig=x->sig;     int stage= x->stage;    int play= x->play;    int interrupt= x->interrupt;    int interrupt_time = x->interrupt_time;    float interrupt_inc = x->interrupt_inc;     float scale = x->scale;    float phase = x->phase;        int mode = x->mode;    float total = (float)x->total;         /*there are 2 modes of this envelope, one triggerd by bang, abother driven with a       signal, please see the esle part of if(mode) where i am stuck.*/          if(mode) {    while (n--) {    if(play){      if(!interrupt) {   	if(count >= (*(adsr+stage) * scale)) {      		stage++;     		count = 0;      		} else count++;		if(stage > 3) {		stage = 0;		count = 0;		play = 0; 	} else sig = *(breakpt+stage) + (*(inc+stage) * (count / ((*(adsr+stage)) * scale)));		} else {	count++;	sig = sig + interrupt_inc; 			if(count >= interrupt_time){	interrupt = 0; 	play = 1; 	count = 0;	stage = 0;		}		}    } else sig = 0.;  	   	*out++ =  sig;    }            x->count = count;    x->sig = sig;    x->stage = stage;     x->play = play;     x->interrupt = interrupt;    } else {        while (n--){    count2 = *in++;         if (count2 >= *(adsr2+stage)) {    post("stage:%d, %f, %f", stage, count2, *(adsr2+stage));        /*        ok, here is where i am stuck:/ the print out in pd looks like this:        stage:0, 0.250000, 0.250000    stage:1, 0.500000, 0.500000    stage:2, 0.750000, 0.750000    stage:3, 1.000000, 1.000000    stage:0, 0.250023, 0.250000    stage:1, 0.500023, 0.500000    stage:2, 0.750023, 0.750000 <- point of stuck:/        i mean, i can't figure out why when "0.500023 > 0.500000" works but    "0.750023 > 0.750000" does not.        */        stage++;    }            if (stage > 3) {    stage = 0;     }        *out++ = stage;    }    x->stage = stage;     }        return (w+5);}