Commit 0a2e3e3c authored by Monty Montgomery's avatar Monty Montgomery

Minor improvements to deverber; not quite finished

 


git-svn-id: https://svn.xiph.org/trunk/postfish@7683 0101bb08-14d6-0310-b084-bc0e0c8e3800
parent c196b9d4
......@@ -209,7 +209,7 @@ void compute_iir_fast_attack2(float *x, int n, iir_state *is,
while(i<n){
double ya= (x[i]+x0*2.+x1)/a_g + y0*a_c0+y1*a_c1;
if(ya<y0){
if(x[i]<y0 && ya<y0){
state=1;
break;
}
......@@ -248,6 +248,70 @@ void compute_iir_fast_attack2(float *x, int n, iir_state *is,
}
/* this one is designed for fast decay, slow attack */
void compute_iir_fast_decay2(float *x, int n, iir_state *is,
iir_filter *attack, iir_filter *decay){
double a_c0=attack->c[0],d_c0=decay->c[0];
double a_c1=attack->c[1],d_c1=decay->c[1];
double a_g=attack->g, d_g=decay->g;
double x0=is->x[0],x1=is->x[1];
double y0=is->y[0],y1=is->y[1];
int state=is->state;
int i=0;
if(zerome(y0) && zerome(y1)){
y0=y1=0.;
}
if(x[0]<y0)state=1;
while(i<n){
if(state==1){
/* decay case */
while(i<n){
double yd= (x[i]+x0*2.+x1)/d_g + y0*d_c0+y1*d_c1;
if(x[i]>y0 && yd>y0){
state=0;
break;
}
x1=x0;x0=x[i];
y1=y0;x[i]=y0=yd;
i++;
}
}
if(state==0){
/* attack case */
if(y1>y0){
/* attack fixup needed because we're in discontinuous time */
y1=y0;
}
while(1){
double ya = (x[i]+x0*2.+x1)/a_g + y0*a_c0+y1*a_c1;
x1=x0;x0=x[i];
y1=y0;x[i]=y0=ya;
i++;
if(i>=n)break;
if(x[i]<y0){
state=1;
break;
}
}
}
}
is->x[0]=x0;is->x[1]=x1;
is->y[0]=y0;is->y[1]=y1;
is->state=state;
}
/* allow decay to proceed in freefall */
void compute_iir_freefall1(float *x, int n, iir_state *is,
iir_filter *decay){
......@@ -264,12 +328,17 @@ void compute_iir_freefall1(float *x, int n, iir_state *is,
while(i<n){
double yd;
yd = y0*d_c0;
if(x[i]>yd)yd=x[i];
yd = y0*d_c0;
x0=x[i];
x[i]=y0=yd;
/* if we're not in freefall, be sure x[i]_out == x[i]_in */
if(x[i]>yd){
yd=x[i];
}else{
x[i]=yd;
}
y0=yd;
i++;
}
......
......@@ -73,6 +73,8 @@ typedef struct {
extern double mkbessel(double raw_alpha,int order,double *ycoeff);
extern void compute_iir_fast_attack2(float *x, int n, iir_state *is,
iir_filter *attack, iir_filter *decay);
extern void compute_iir_fast_decay2(float *x, int n, iir_state *is,
iir_filter *attack, iir_filter *decay);
extern void compute_iir_symmetric2(float *x, int n, iir_state *is,
iir_filter *filter);
extern void compute_iir_symmetric3(float *x, int n, iir_state *is,
......
......@@ -88,9 +88,9 @@ static void filter_set(subband_state *ss,
/* make sure the chosen frequency doesn't require a lookahead
greater than what's available */
if(impulse_freq4(input_size*2-ss->qblocksize*3)*1.01>corner_freq &&
if(impulse_freq2(input_size*2-ss->qblocksize*3)*1.01>corner_freq &&
attackp)
corner_freq=impulse_freq4(input_size*2-ss->qblocksize*3);
corner_freq=impulse_freq2(input_size*2-ss->qblocksize*3);
alpha=corner_freq/input_rate;
filter->g=mkbessel(alpha,order,filter->c);
......@@ -129,11 +129,11 @@ static void suppress_work_helper(void *vs, suppress_settings *sset){
iir_filter *release=&sss->release;
int ahead;
if(smoothms!=smooth->ms)filter_set(ss,smoothms,smooth,1,4);
if(triggerms!=trigger->ms)filter_set(ss,triggerms,trigger,0,1);
if(releasems!=release->ms)filter_set(ss,releasems,release,0,1);
if(smoothms!=smooth->ms)filter_set(ss,smoothms,smooth,1,2);
if(triggerms!=trigger->ms)filter_set(ss,triggerms,trigger,0,2);
if(releasems!=release->ms)filter_set(ss,releasems,release,0,2);
ahead=impulse_ahead4(smooth->alpha);
ahead=impulse_ahead2(smooth->alpha);
for(i=0;i<suppress_freqs;i++){
int firstlink=0;
......@@ -171,16 +171,13 @@ static void suppress_work_helper(void *vs, suppress_settings *sset){
if(sset->linkp==0 || firstlink==1){
compute_iir_symmetric4(fast, input_size, &sss->iirS[i][j],
smooth);
//_analysis("smooth",i,fast,input_size,1,offset);
compute_iir_freefall1(fast, input_size, &sss->iirT[i][j],
trigger);
memcpy(slow,fast,sizeof(slow));
compute_iir_freefall1(slow, input_size, &sss->iirR[i][j],
release);
compute_iir_fast_attack2(fast, input_size, &sss->iirT[i][j],
smooth,trigger);
compute_iir_fast_attack2(slow, input_size, &sss->iirR[i][j],
smooth,release);
//_analysis("fast",i,fast,input_size,1,offset);
//_analysis("slow",i,slow,input_size,1,offset);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment