float pipe_tick(struct pipe* p) { int silencecounter = p->silencecounter; double airflow = p->airflow; double const airflowtarget = p->airflowtarget; airflow += (airflowtarget-airflow) * p->airflowspeed; /* p->fir_state[3]=p->fir_state[2]; p->fir_state[2]=p->fir_state[1]; p->fir_state[1]=p->fir_state[0]; p->fir_state[0]=delay_read(&p->delay); double const fdout = 1.0e-6 + p->fir_state[0]*p->fir_coeff[0] + p->fir_state[1]*p->fir_coeff[1] + p->fir_state[2]*p->fir_coeff[2] + p->fir_state[3]*p->fir_coeff[3]; */ double const fdout = thiran1_tick(&p->fd_state, p->fd_coeff, delay_read(&p->delay)); double const delayout = onepole_tick(&p->airlossfilter1, onepole_tick(&p->airlossfilter2, fdout)); double const pipeout = onepole_tick(&p->reflectionfilter,delayout); double const reflected = pipeout - delayout; double const r = reflected-0.5; double const pipein = airflow * fastexp(-r*r) * (0.9+0.2*rand()/RAND_MAX); double const delayin = pipein + reflected; delay_write(&p->delay,delayin); if(airflow > 1.0e-4 || fabs(pipeout) > 1.0e-5) { silencecounter = p->delay.length*2+1; } else { silencecounter = silencecounter - 1; } p->silencecounter = silencecounter; p->airflow = airflow; return pipeout*p->gain; }
float mono_chorus_compute(monochorus_t *del, Lfo_t *lfo, float xin) { float yout; float x1; float x2; x2 = delay_read (del, del->baseDelay + Lfo_SampleCompute(lfo) + MARGIN); if (del->mode == 1) x1 = xin + del->fb * x2; // variable delay feedback signal or ... else x1 = xin + del->fb * delay_read (del, del->baseDelay + MARGIN); // fixed delay feedback signal x1 = (x1 > 1.0f) ? 1.0f : x1 ; //clip too loud samples x1 = (x1 < -1.0f) ? -1.0f : x1 ; yout = del->mix * x1 + del->fw * x2; //yout = del->mix * xin + del->fw * x2; // not good sounding... delay_write(del, x1); return yout; }