void shapee_init(t_shapee *x, short initialized) { int i; x->D = x->vs; x->N = x->vs * x->overlap; x->Nw = x->N * x->winfac; limit_fftsize(&x->N,&x->Nw,OBJECT_NAME); x->N2 = (x->N)>>1; x->Nw2 = (x->Nw)>>1; x->inCount = -(x->Nw); x->mult = 1. / (float) x->N; if(!initialized){ x->mute = 0; x->Wanal = (float *) getbytes( MAX_Nw * sizeof(float) ); x->Wsyn = (float *) getbytes( MAX_Nw * sizeof(float) ); x->Hwin = (float *) getbytes( MAX_Nw * sizeof(float) ); x->inputOne = (float *) getbytes( MAX_Nw * sizeof(float) ); x->inputTwo = (float *) getbytes( MAX_Nw * sizeof(float) ); x->bufferOne = (float *) getbytes( MAX_N * sizeof(float) ); x->bufferTwo = (float *) getbytes( MAX_N * sizeof(float) ); x->channelOne = (float *) getbytes( (MAX_N+2) * sizeof(float) ); x->channelTwo = (float *) getbytes( (MAX_N+2) * sizeof(float) ); x->output = (float *) getbytes( MAX_Nw * sizeof(float) ); x->bitshuffle = (int *) getbytes( MAX_N * 2 * sizeof( int ) ); x->trigland = (float *) getbytes( MAX_N * 2 * sizeof( float ) ); } memset((char *)x->inputOne,0,x->Nw * sizeof(float)); memset((char *)x->inputTwo,0,x->Nw * sizeof(float)); memset((char *)x->output,0,x->Nw * sizeof(float)); init_rdft(x->N, x->bitshuffle, x->trigland); makehanning(x->Hwin, x->Wanal, x->Wsyn, x->Nw, x->N, x->D, 1);// wants an ODD window }
void leaker_init(t_leaker *x, short initialized) { int i; if(!power_of_two(x->overlap)) x->overlap = 4; if(!power_of_two(x->winfac)) x->winfac = 2; x->N = x->D * x->overlap; x->Nw = x->N * x->winfac; limit_fftsize(&x->N,&x->Nw,OBJECT_NAME); x->N2 = (x->N)>>1; x->Nw2 = (x->Nw)>>1; x->inCount = -(x->Nw); x->mult = 1. / (float) x->N; x->c_fundamental = (float) x->R/( (x->N2)<<1 ); x->c_factor_in = (float) x->R/((float)x->D * TWOPI); x->c_factor_out = TWOPI * (float) x->D / (float) x->R; if(!initialized) { x->mute = 0; x->bypass = 0; x->fade_connected = 0; x->fade_value = 0; x->input1 = (float *) getbytes(MAX_Nw * sizeof(float)); x->buffer1 = (float *) getbytes(MAX_N * sizeof(float)); x->channel1 = (float *) getbytes((MAX_N+2) * sizeof(float)); x->input2 = (float *) getbytes(MAX_Nw * sizeof(float)); x->buffer2 = (float *) getbytes(MAX_N * sizeof(float)); x->channel2 = (float *) getbytes((MAX_N+2) * sizeof(float)); x->Wanal = (float *) getbytes(MAX_Nw * sizeof(float)); x->Wsyn = (float *) getbytes(MAX_Nw * sizeof(float)); x->Hwin = (float *) getbytes(MAX_Nw * sizeof(float)); x->output = (float *) getbytes(MAX_Nw * sizeof(float)); x->bitshuffle = (int *) getbytes (MAX_N * 2 * sizeof( int )); x->trigland = (float *) getbytes(MAX_N * 2 * sizeof( float )); x->sieve = (int *) getbytes((MAX_N2 + 1) * sizeof(int)); x->c_lastphase_in1 = (float *) getbytes((MAX_N2+1) * sizeof(float)); x->c_lastphase_in2 = (float *) getbytes((MAX_N2+1) * sizeof(float)); x->c_lastphase_out = (float *) getbytes((MAX_N2+1) * sizeof(float)); } memset((char *)x->input1,0,x->Nw); memset((char *)x->input2,0,x->Nw); memset((char *)x->output,0,x->Nw); memset((char *)x->c_lastphase_in1,0,(x->N2+1) * sizeof(float)); memset((char *)x->c_lastphase_in2,0,(x->N2+1) * sizeof(float)); memset((char *)x->c_lastphase_out,0,(x->N2+1) * sizeof(float)); init_rdft(x->N, x->bitshuffle, x->trigland); makehanning(x->Hwin, x->Wanal, x->Wsyn, x->Nw, x->N, x->D, 0); if(initialized != 2){ for(i = 0; i < x->N2; i++){ x->sieve[i] = i; } } }
void crossx_init(t_crossx *x, short initialized) { int i; x->D = x->vs; x->N = x->D * x->overlap; x->Nw = x->N * x->winfac; limit_fftsize(&x->N,&x->Nw,OBJECT_NAME); x->N2 = (x->N)>>1; x->Nw2 = (x->Nw)>>1; x->inCount = -(x->Nw); x->mult = 1. / (float) x->N; x->c_fundamental = (float) x->R/( (x->N2)<<1 ); x->c_factor_in = (float) x->R/((float)x->D * TWOPI); x->c_factor_out = TWOPI * (float) x->D / (float) x->R; if(!initialized){ x->threshie = .001 ; x->autonorm = 0; x->mute = 0; x->Wanal = (float *) getbytes((MAX_Nw) * sizeof(float)); x->Wsyn = (float *) getbytes((MAX_Nw) * sizeof(float)); x->Hwin = (float *) getbytes((MAX_Nw) * sizeof(float)); x->output = (float *) getbytes((MAX_Nw) * sizeof(float)); x->bitshuffle = (int *) getbytes((MAX_N * 2)* sizeof(int)); x->trigland = (float *) getbytes((MAX_N * 2)* sizeof(float)); x->input1 = (float *) getbytes(MAX_Nw * sizeof(float)); x->buffer1 = (float *) getbytes(MAX_N * sizeof(float)); x->channel1 = (float *) getbytes((MAX_N+2) * sizeof(float)); x->input2 = (float *) getbytes(MAX_Nw * sizeof(float)); x->buffer2 = (float *) getbytes(MAX_N * sizeof(float)); x->channel2 = (float *) getbytes((MAX_N+2) * sizeof(float)); x->last_channel = (float *) getbytes((MAX_N+2) * sizeof(float)); x->c_lastphase_in1 = (float *) getbytes((MAX_N2+1) * sizeof(float)); x->c_lastphase_in2 = (float *) getbytes((MAX_N2+1) * sizeof(float)); x->c_lastphase_out = (float *) getbytes((MAX_N2+1) * sizeof(float)); } memset((char *)x->input1,0,x->Nw * sizeof(float)); memset((char *)x->input2,0,x->Nw * sizeof(float)); memset((char *)x->output,0,x->Nw * sizeof(float)); memset((char *)x->buffer1,0,x->N * sizeof(float)); memset((char *)x->buffer2,0,x->N * sizeof(float)); memset((char *)x->channel1,0,(x->N+2) * sizeof(float)); memset((char *)x->channel2,0,(x->N+2) * sizeof(float)); memset((char *)x->c_lastphase_in1,0,(x->N2+1) * sizeof(float)); memset((char *)x->c_lastphase_in2,0,(x->N2+1) * sizeof(float)); memset((char *)x->c_lastphase_out,0,(x->N2+1) * sizeof(float)); init_rdft( x->N, x->bitshuffle, x->trigland); makehanning( x->Hwin, x->Wanal, x->Wsyn, x->Nw, x->N, x->D, 0); }
void drown_init(t_drown *x, short initialized) { int i; int mem; x->D = x->vs; x->N = x->D * x->overlap; x->Nw = x->N * x->winfac; limit_fftsize(&x->N,&x->Nw,OBJECT_NAME); x->N2 = (x->N)>>1; x->Nw2 = (x->Nw)>>1; x->inCount = -(x->Nw); x->mult = 1. / (float) x->N; if(!initialized){ x->mute = 0; x->peakflag = 0; mem = (MAX_Nw) * sizeof(float); x->input = (float *) getbytes(mem); x->output = (float *) getbytes(mem); x->Wanal = (float *) getbytes(mem); x->Wsyn = (float *) getbytes(mem); x->Hwin = (float *) getbytes(mem); mem = (MAX_N) * sizeof(float); x->buffer = (float *) getbytes(mem); mem = (MAX_N+2) * sizeof(float); x->channel = (float *) getbytes(mem); mem = (MAX_N) * sizeof(int); x->bitshuffle = (int *) getbytes(mem); mem = (MAX_N) * sizeof(float); x->trigland = (float *) getbytes(mem); } memset((char *)x->input,0,x->Nw * sizeof(float)); memset((char *)x->output,0,x->Nw * sizeof(float)); makehanning( x->Hwin, x->Wanal, x->Wsyn, x->Nw, x->N, x->D, 0); init_rdft( x->N, x->bitshuffle, x->trigland); }
void thresher_init(t_thresher *x, short initialized) { int i; if(!x->D) x->D = 256; if(!x->R) x->R = 44100; if(!fftease_power_of_two(x->overlap) ) x->overlap = 4; if(!fftease_power_of_two(x->winfac) ) x->winfac = 1; x->N = x->D * x->overlap; x->Nw = x->N * x->winfac; limit_fftsize(&x->N,&x->Nw,OBJECT_NAME); x->N2 = (x->N)>>1; x->Nw2 = (x->Nw)>>1; x->in_count = -(x->Nw); x->mult = 1. / (float) x->N; x->tadv = (float) x->D / (float) x->R ; if(!initialized){ x->mute = 0; x->bypass = 0; if(!x->damping_factor){ x->damping_factor = .95; } if(!x->move_threshold){ x->move_threshold = .00001 ; } x->first_frame = 1; x->max_hold_time = DEFAULT_HOLD ; x->max_hold_frames = x->max_hold_time / x->tadv; x->c_fundamental = (float) x->R/( (x->N2)<<1 ); x->c_factor_in = (float) x->R/((float)x->D * TWOPI); x->c_factor_out = TWOPI * (float) x->D / (float) x->R; x->Wanal = (float *) getbytes( (MAX_Nw) * sizeof(float)); x->Wsyn = (float *) getbytes( (MAX_Nw) * sizeof(float)); x->Hwin = (float *) getbytes( (MAX_Nw) * sizeof(float)); x->input = (float *) getbytes( MAX_Nw * sizeof(float) ); x->output = (float *) getbytes( MAX_Nw * sizeof(float) ); x->buffer = (float *) getbytes( MAX_N * sizeof(float) ); x->channel = (float *) getbytes( (MAX_N+2) * sizeof(float) ); x->bitshuffle = (int *) getbytes( MAX_N * 2 * sizeof( int ) ); x->trigland = (float *) getbytes( MAX_N * 2 * sizeof( float ) ); x->c_lastphase_in = (float *) getbytes( (MAX_N2+1) * sizeof(float) ); x->c_lastphase_out = (float *) getbytes( (MAX_N2+1) * sizeof(float) ); x->composite_frame = (float *) getbytes( (MAX_N+2) * sizeof(float) ); x->frames_left = (int *) getbytes( (MAX_N+2) * sizeof(int) ); } memset((char *)x->input,0,x->Nw * sizeof(float)); memset((char *)x->output,0,x->Nw * sizeof(float)); memset((char *)x->c_lastphase_in,0,(x->N2+1) * sizeof(float)); memset((char *)x->c_lastphase_out,0,(x->N2+1) * sizeof(float)); memset((char *)x->frames_left,0,(x->N+2) * sizeof(float)); init_rdft(x->N, x->bitshuffle, x->trigland); makehanning(x->Hwin, x->Wanal, x->Wsyn, x->Nw, x->N, x->D, 0); }
void bthresher_init(t_bthresher *x, short initialized) { int i; if(!x->D) x->D = 256; if(!x->R) x->R = 44100; if(!power_of_two(x->overlap)) x->overlap = 4; if(!power_of_two(x->winfac)) x->winfac = 1; x->N = x->D * x->overlap; x->Nw = x->N * x->winfac; limit_fftsize(&x->N,&x->Nw,OBJECT_NAME); x->mult = 1. / (float) x->N; x->N2 = (x->N)>>1; x->Nw2 = (x->Nw)>>1; x->in_count = -(x->Nw); x->c_fundamental = (float) x->R/((x->N2)<<1 ); x->c_factor_in = (float) x->R/((float)x->D * TWOPI); x->c_factor_out = TWOPI * (float) x->D / (float) x->R; if(!initialized){ x->first_frame = 1; x->max_hold_time = 60.0 ; x->thresh_connected = 0; x->damping_connected = 0; x->thresh_scalar = 1; x->damp_scalar = 1; x->mute = 0; x->bypass = 0; x->inf_hold = 0; x->Wanal = (float *) getbytes((MAX_Nw) * sizeof(float)); x->Wsyn = (float *) getbytes((MAX_Nw) * sizeof(float)); x->Hwin = (float *) getbytes((MAX_Nw) * sizeof(float)); x->input = (float *) getbytes((MAX_Nw) * sizeof(float)); x->buffer = (float *) getbytes((MAX_N) * sizeof(float)); x->channel = (float *) getbytes(((MAX_N+2)) * sizeof(float)); x->output = (float *) getbytes((MAX_Nw) * sizeof(float)); x->bitshuffle = (int *) getbytes((MAX_N * 2) * sizeof(int)); x->trigland = (float *) getbytes((MAX_N * 2) * sizeof(float)); x->c_lastphase_in = (float *) getbytes((MAX_N2+1)* sizeof(float)); x->c_lastphase_out = (float *) getbytes((MAX_N2+1)* sizeof(float)); x->composite_frame = (float *) getbytes( (MAX_N+2)* sizeof(float)); x->frames_left = (int *) getbytes((MAX_N+2)* sizeof(int)); // TRIPLETS OF bin# damp_factor threshold x->list_data = (t_atom *) getbytes((MAX_N2 + 1) * 3 * sizeof(t_atom)); x->move_threshold = (float *) getbytes((MAX_N2+1)* sizeof(float)); x->damping_factor = (float *) getbytes((MAX_N2+1)* sizeof(float)); } if(initialized == 0 || initialized == 1){ for(i = 0; i < x->N2+1; i++) { x->move_threshold[i] = x->init_thresh; x->damping_factor[i] = x->init_damping; } } memset((char *)x->input,0,x->Nw * sizeof(float)); memset((char *)x->output,0,x->Nw * sizeof(float)); memset((char *)x->buffer,0,x->N * sizeof(float)); memset((char *)x->c_lastphase_in,0,(x->N2+1) * sizeof(float)); memset((char *)x->c_lastphase_out,0,(x->N2+1) * sizeof(float)); x->tadv = (float) x->D / (float) x->R; x->max_hold_frames = x->max_hold_time / x->tadv; init_rdft(x->N, x->bitshuffle, x->trigland); makehanning(x->Hwin, x->Wanal, x->Wsyn, x->Nw, x->N, x->D, 0); }
void pvtuner_init(t_pvtuner *x,short initialized) { int i, j; int mem; float curfreq; if(!x->R)//temp init if MSP functions returned zero x->R = 44100; if(!x->D) x->D = 256; if(!power_of_two(x->overlap)) x->overlap = 4; if(!power_of_two(x->winfac)) x->winfac = 2; x->Iinv = 1./x->D; x->N = x->D * x->overlap; x->Nw = x->N * x->winfac; limit_fftsize(&x->N,&x->Nw,OBJECT_NAME); x->N2 = (x->N)>>1; x->Nw2 = (x->Nw)>>1; x->inCount = -(x->Nw); x->mult = 1. / (float) x->N; x->c_fundamental = (float) x->R/(float)( (x->N2)<<1 ); x->c_factor_in = (float) x->R/((float)x->D * TWOPI); x->c_factor_out = TWOPI * (float) x->D / (float) x->R; if(!initialized) { x->P = 1.0 ; // default x->bypass_state = 0; x->mute = 0; x->L = 8192; x->synt = .000001; mem = (MAX_Nw)*sizeof(float); x->Wanal = (float *) getbytes(mem); x->Wsyn = (float *) getbytes(mem); x->Hwin = (float *) getbytes(mem); x->input = (float *) getbytes(mem); x->output = (float *) getbytes(mem); mem = (MAX_N)*sizeof(float); x->buffer = (float *) getbytes(mem); mem = (MAX_N+2)*sizeof(float); x->channel = (float *) getbytes(mem); mem = (MAX_N*2)*sizeof(int); x->bitshuffle = (int *) getbytes(mem); mem = (MAX_N*2)*sizeof(float); x->trigland = (float *) getbytes(mem); mem = (MAXTONES+1)*sizeof(float); x->pitchgrid = (float *) getbytes(mem); mem = (MAX_N+1)*sizeof(float); x->lastamp = (float *) getbytes(mem); x->lastfreq = (float *) getbytes(mem); x->bindex = (float *) getbytes(mem); mem = (x->L)*sizeof(float); x->table = (float *) getbytes(mem); mem = (MAX_N2+1)*sizeof(float); x->c_lastphase_in = (float *) getbytes(mem); x->c_lastphase_out = (float *)getbytes(mem); x->pbase = BASE_FREQ; pvtuner_diatonic(x);// default scale } memset((char *)x->input,0,x->Nw * sizeof(float)); memset((char *)x->output,0,x->Nw * sizeof(float)); memset((char *)x->lastamp,0,(x->N+1) * sizeof(float)); memset((char *)x->lastfreq,0,(x->N+1) * sizeof(float)); memset((char *)x->bindex,0,(x->N+1) * sizeof(float)); memset((char *)x->c_lastphase_in,0,(x->N2+1) * sizeof(float)); memset((char *)x->c_lastphase_out,0,(x->N2+1) * sizeof(float)); for ( i = 0; i < x->L; i++ ) { x->table[i] = (float) x->N * cos((float)i * TWOPI / (float)x->L); } if( x->hifreq < x->c_fundamental ) { x->hifreq = 3000.0 ; } x->hi_bin = 1; x->curfreq = 0; while( x->curfreq < x->hifreq ) { ++(x->hi_bin); x->curfreq += x->c_fundamental ; } x->lo_bin = 0; x->curfreq = 0; while( x->curfreq < x->lofreq ) { ++(x->lo_bin); x->curfreq += x->c_fundamental ; } if( x->hi_bin >= x->N2 ) x->hi_bin = x->N2 - 1; x->hi_tune_bin = x->hi_bin; x->myPInc = x->P*x->L/x->R; x->ffac = x->P * PI/x->N; init_rdft( x->N, x->bitshuffle, x->trigland); makehanning( x->Hwin, x->Wanal, x->Wsyn, x->Nw, x->N, x->D, 0); }
void cavoc_init(t_cavoc *x,short initialized) { int i; if(!x->D) x->D = 256; if(!x->R) x->R = 44100; if(!power_of_two(x->overlap)) x->overlap = 4; if(!power_of_two(x->winfac)) x->winfac = 1; x->N = x->D * x->overlap; x->Nw = x->N * x->winfac; limit_fftsize(&x->N,&x->Nw,OBJECT_NAME); x->mult = 1. / (float) x->N; x->N2 = (x->N)>>1; x->Nw2 = (x->Nw)>>1; x->in_count = -(x->Nw); x->c_fundamental = (float) x->R/(float)((x->N2)<<1); x->frame_duration = (float)x->D/(float) x->R; if(x->hold_time <= 100) /* in milliseconds */ x->hold_time = 100; cavoc_hold_time(x, x->hold_time); if(!initialized){ srand(time(0)); x->mute = 0; x->set_count = 0; x->external_trigger = 0; if( x->density < 0.0 ){ x->density = 0; } else if( x->density > 1.0 ){ x->density = 1.0; } x->start_breakpoint = 1.0 - x->density; x->Wanal = (float *) calloc( MAX_Nw, sizeof(float) ); x->Wsyn = (float *) calloc( MAX_Nw, sizeof(float) ); x->input = (float *) calloc( MAX_Nw, sizeof(float) ); x->Hwin = (float *) calloc( MAX_Nw, sizeof(float) ); x->buffer = (float *) calloc( MAX_N, sizeof(float) ); x->channel = (float *) calloc( MAX_N+2, sizeof(float) ); x->last_frame = (float *) calloc(MAX_N+2, sizeof(float)); x->output = (float *) calloc( MAX_Nw, sizeof(float) ); x->bitshuffle = (int *) calloc( MAX_N * 2, sizeof( int ) ); x->trigland = (float *) calloc( MAX_N * 2, sizeof( float ) ); x->c_lastphase_out = (float *) calloc( MAX_N2+1, sizeof(float) ); x->c_factor_out = TWOPI * (float) x->D / (float) x->R; x->rule = (short *) calloc(8, sizeof(short)); x->rule[2] = x->rule[3] = x->rule[5] = x->rule[6] = 1; x->rule[0] = x->rule[1] = x->rule[4] = x->rule[7] = 0; } memset((char *)x->input,0,x->Nw * sizeof(float)); memset((char *)x->output,0,x->Nw * sizeof(float)); memset((char *)x->buffer,0,x->N * sizeof(float)); memset((char *)x->c_lastphase_out,0,(x->N2+1) * sizeof(float)); memset((char *)x->last_frame,0,(x->N+2) * sizeof(float)); init_rdft( x->N, x->bitshuffle, x->trigland); makehanning( x->Hwin, x->Wanal, x->Wsyn, x->Nw, x->N, x->D, 0); for(i = 0; i < x->N2 + 1; i++){ if(cavoc_randf(0.0, 1.0) > x->start_breakpoint){ x->channel[ i * 2 ] = 1; ++(x->set_count); } else { x->channel[i * 2] = 0; } x->channel[i * 2 + 1] = x->c_fundamental * (float) (i / 2) * cavoc_randf(.9,1.1); } // post("turned on %d of a possible %d bins", x->set_count, x->N2+1 ); for( i = 0; i < x->N+2; i++ ){ x->last_frame[i] = x->channel[i]; } // post("cavoc~ FFT size: %d",x->N); }