[xiph-commits] r7885 - trunk/postfish
xiphmont at motherfish-iii.xiph.org
xiphmont at motherfish-iii.xiph.org
Mon Sep 27 21:45:25 PDT 2004
Author: xiphmont
Date: 2004-09-27 21:45:24 -0700 (Mon, 27 Sep 2004)
New Revision: 7885
Modified:
trunk/postfish/singlecomp.c
trunk/postfish/subband.c
trunk/postfish/version.h
Log:
Convert single-band compander to new shared window infrastructure
Fix bug where if any channel goes inactive, all channel filters got reset (causing a click)
Modified: trunk/postfish/singlecomp.c
===================================================================
--- trunk/postfish/singlecomp.c 2004-09-27 06:30:08 UTC (rev 7884)
+++ trunk/postfish/singlecomp.c 2004-09-28 04:45:24 UTC (rev 7885)
@@ -23,6 +23,7 @@
#include "postfish.h"
#include "feedback.h"
+#include "window.h"
#include "bessel.h"
#include "singlecomp.h"
@@ -166,11 +167,7 @@
singlecomp_load_helper(&master_state,outch);
singlecomp_load_helper(&channel_state,input_ch);
- window=malloc(input_size/2*sizeof(*window));
- for(i=0;i<input_size/2;i++){
- window[i]=sin( (i+.5)/input_size*M_PIl);
- window[i]*=window[i];
- }
+ window=window_get(1,input_size/2);
singlecomp_channel_set=calloc(input_ch,sizeof(*singlecomp_channel_set));
master_set_bundle=malloc(outch*sizeof(*master_set_bundle));
@@ -210,6 +207,15 @@
memset(scs->b_iir,0,scs->ch*sizeof(*scs->b_iir));
}
+static void reset_onech_filter(singlecomp_state *scs,int i){
+ memset(scs->o_peak+i,0,sizeof(*scs->o_peak));
+ memset(scs->u_peak+i,0,sizeof(*scs->u_peak));
+ memset(scs->b_peak+i,0,sizeof(*scs->b_peak));
+ memset(scs->o_iir+i,0,sizeof(*scs->o_iir));
+ memset(scs->u_iir+i,0,sizeof(*scs->u_iir));
+ memset(scs->b_iir+i,0,sizeof(*scs->b_iir));
+}
+
/* called only in playback thread */
int singlecomp_reset(void ){
/* reset cached pipe state */
@@ -473,8 +479,8 @@
if(!active0 && !activeC){
- if(activeP) reset_filter(scs); /* just became inactive; reset all filters */
-
+ if(activeP) reset_onech_filter(scs,i); /* just became inactive; reset all filters for this channel */
+
/* feedback */
if(scset[i]->panel_visible){
int k;
Modified: trunk/postfish/subband.c
===================================================================
--- trunk/postfish/subband.c 2004-09-27 06:30:08 UTC (rev 7884)
+++ trunk/postfish/subband.c 2004-09-28 04:45:24 UTC (rev 7885)
@@ -23,6 +23,7 @@
#include "postfish.h"
#include <fftw3.h>
+#include "window.h"
#include "subband.h"
#include "lpc.h"
@@ -77,11 +78,7 @@
for(i=0;i<ch;i++)
f->out.data[i]=malloc(input_size*sizeof(**f->out.data));
- /* fill in time window */
- f->window=malloc(f->qblocksize*2*sizeof(*f->window));
- /* we need a smooth-edged, symmetric window */
- for(i=0;i<f->qblocksize*2;i++)f->window[i]=sin(M_PIl*i/(f->qblocksize*2));
- for(i=0;i<f->qblocksize*2;i++)f->window[i]*=f->window[i]*.25/f->qblocksize;
+ f->window=window_get(1,f->qblocksize);
f->fftwf_forward_out = fftwf_malloc(sizeof(*f->fftwf_forward_out) *
(f->qblocksize*4+2));
@@ -235,7 +232,9 @@
for(i=0;i<ch;i++){
- int content_p= f->lap_activeC[i]= (visible[i]||active[i]) && !mute_channel_muted(mutemask,i);
+ int content_p=
+ f->lap_activeC[i]=
+ (visible[i]||active[i]) && !mute_channel_muted(mutemask,i);
int content_p0= f->lap_active0[i];
int content_p1= f->lap_active1[i];
@@ -294,8 +293,20 @@
break;
}
+
/* window; assume the edges are already zeroed */
- for(k=0;k<f->qblocksize*2;k++)workoff[k]*=f->window[k];
+ {
+ float scale=.25/f->qblocksize;
+ float *workoff2=workoff+f->qblocksize*2;
+ /* odd-symmetry window */
+ workoff[0]*=f->window[0]*scale;
+ for(k=1;k<f->qblocksize;k++){
+ float w=f->window[k]*scale;
+ workoff[k]*=w;
+ *(--workoff2)*=w;
+ }
+ workoff[k]*=f->window[k]*scale;
+ }
fftwf_execute(f->fftwf_forward);
@@ -331,7 +342,9 @@
}
}
-static void unsubband_work(subband_state *f,time_linkage *in, time_linkage *out){
+static void unsubband_work(subband_state *f,time_linkage *in,
+ time_linkage *out){
+
int i,j,k,ch=f->out.channels;
f->lap_samples+=in->samples;
@@ -406,22 +419,19 @@
/* transitioning to active effect, but the lap was already
previously active; window the transition */
float *lo=o+f->qblocksize;
- float scale=f->qblocksize*4;
memset(o,0,sizeof(*o)*f->qblocksize);
for(j=0;j<f->qblocksize;j++)
- lo[j]*=f->window[j]*scale;
+ lo[j]*=f->window[j];
}else if (!active_p0 && content_p0){
/* transitioning from active effect, but the lap will continue
to be active; window the transition */
float *lo=o+input_size-f->qblocksize*2;
- float *lw=f->window+f->qblocksize;
- float scale=f->qblocksize*4;
memset(o+input_size-f->qblocksize,0,sizeof(*o)*f->qblocksize);
for(j=0;j<f->qblocksize;j++)
- lo[j]*=lw[j]*scale;
-
+ lo[j]*=f->window[f->qblocksize-j];
+
} /* else any transitions we need are already windowed as
above by the lap handling code in subband_work */
@@ -430,28 +440,24 @@
/* beginning transition */
float *lo=o+f->qblocksize;
float *lc=f->cache1[i]+f->qblocksize;
- float *lw=f->window+f->qblocksize;
- float scale=f->qblocksize*4;
memcpy(o,f->cache1[i],sizeof(*o)*f->qblocksize);
for(j=0;j<f->qblocksize;j++)
- lo[j]+=lc[j]*lw[j]*scale;
+ lo[j]+=lc[j]*f->window[f->qblocksize-j];
}else if (!active_p0 && !muted_p0){
/* end transition */
float *lo=o+input_size-f->qblocksize*2;
float *lc=f->cache1[i]+input_size-f->qblocksize*2;
- float scale=f->qblocksize*4;
memcpy(o+input_size-f->qblocksize,
f->cache1[i]+input_size-f->qblocksize,
sizeof(*o)*f->qblocksize);
for(j=0;j<f->qblocksize;j++)
- lo[j]+=lc[j]*f->window[j]*scale;
+ lo[j]+=lc[j]*f->window[j];
}
}
-
}
/* out is done for this channel */
Modified: trunk/postfish/version.h
===================================================================
--- trunk/postfish/version.h 2004-09-27 06:30:08 UTC (rev 7884)
+++ trunk/postfish/version.h 2004-09-28 04:45:24 UTC (rev 7885)
@@ -1,2 +1,2 @@
#define VERSION "$Id$ "
-/* DO NOT EDIT: Automated versioning hack [Mon Sep 27 02:46:29 EDT 2004] */
+/* DO NOT EDIT: Automated versioning hack [Tue Sep 28 01:01:38 EDT 2004] */
More information about the commits
mailing list