diff --git a/CHANGELOG b/CHANGELOG index e97f7a9..b33d82b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,13 @@ +1.2.4 (Oct 27, 2005) The "oops, inverse fixed point real fft was borked" release. + Fixed scaling bug for inverse fixed point real fft -- also fixed test code that should've been failing. + Thanks to Jean-Marc Valin for bug report. + + Use sys/types.h for more portable types than short,int,long => int16_t,int32_t,int64_t + If your system does not have these, you may need to define them -- but at least it breaks in a + loud and easily fixable way -- unlike silently using the wrong size type. + + Hopefully tools/psdpng.c is fixed -- thanks to Steve Kellog for pointing out the weirdness. + 1.2.3 (June 25, 2005) The "you want to use WHAT as a sample" release. Added ability to use 32 bit fixed point samples -- requires a 64 bit intermediate result, a la 'long long' diff --git a/tools/psdpng.c b/tools/psdpng.c index 5b1f066..d11a54f 100644 --- a/tools/psdpng.c +++ b/tools/psdpng.c @@ -22,35 +22,35 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND #include "kiss_fft.h" #include "kiss_fftr.h" -size_t nfft=1024; -size_t nfreqs=0; -int repeat=0; -int window=0; -int colors=256; +int nfft=1024; FILE * fin=NULL; FILE * fout=NULL; int navg=20; -float * valbuf=NULL; -int remove_dc=1; - -size_t nrows=0; +int remove_dc=0; +int nrows=0; float * vals=NULL; +int stereo=0; static void config(int argc,char** argv) { while (1) { - int c = getopt (argc, argv, "n:rs"); + int c = getopt (argc, argv, "n:r:as"); if (c == -1) break; switch (c) { - case 'n': - nfft=(size_t)atoi(optarg); + case 'n': nfft=(int)atoi(optarg);break; + case 'r': navg=(int)atoi(optarg);break; + case 'a': remove_dc=1;break; + case 's': stereo=1;break; case '?': fprintf (stderr, "usage options:\n" - "\t-n d: fft dimension(s) default = 1024\n" - "stereo 16 bit machine format real input is assumed\n" + "\t-n d: fft dimension(s) [1024]\n" + "\t-r d: number of rows to average [20]\n" + "\t-a : remove average from each fft buffer\n" + "\t-s : input is stereo, channels will be combined before fft\n" + "16 bit machine format real input is assumed\n" ); default: fprintf (stderr, "bad %c\n", c); @@ -91,6 +91,7 @@ void val2rgb(float x,rgb_t *p) p->g = (int)(255*sin(x*pi)); p->r = (int)(255*abs(sin(x*pi*3/2))); p->b = (int)(255*abs(sin(x*pi*5/2))); + //fprintf(stderr,"%.2f : %d,%d,%d\n",x,(int)p->r,(int)p->g,(int)p->b); } static @@ -105,7 +106,12 @@ void cpx2pixels(rgb_t * res,const float * fbuf,size_t n) if (fbuf[i] < minval) minval = fbuf[i]; } + fprintf(stderr,"min ==%f,max=%f\n",minval,maxval); valrange = maxval-minval; + if (valrange == 0) { + fprintf(stderr,"min == max == %f\n",minval); + exit (1); + } for (i = 0; i < n; ++i) val2rgb( (fbuf[i] - minval)/valrange , res+i ); @@ -118,53 +124,57 @@ void transform_signal(void) kiss_fftr_cfg cfg=NULL; kiss_fft_scalar *tbuf; kiss_fft_cpx *fbuf; - kiss_fft_cpx *avgbuf; - size_t i; - size_t n; + float *mag2buf; + int i; + int n; int avgctr=0; - nfreqs=nfft/2+1; + int nfreqs=nfft/2+1; CHECKNULL( cfg=kiss_fftr_alloc(nfft,0,0,0) ); CHECKNULL( inbuf=(short*)malloc(sizeof(short)*2*nfft ) ); CHECKNULL( tbuf=(kiss_fft_scalar*)malloc(sizeof(kiss_fft_scalar)*nfft ) ); CHECKNULL( fbuf=(kiss_fft_cpx*)malloc(sizeof(kiss_fft_cpx)*nfreqs ) ); - CHECKNULL( avgbuf=(kiss_fft_cpx*)malloc(sizeof(kiss_fft_cpx)*nfreqs ) ); + CHECKNULL( mag2buf=(float*)malloc(sizeof(float)*nfreqs ) ); - while (1){ - n = fread(inbuf,sizeof(short)*2,nfft,fin); - if (n != nfft ) - break; + memset(mag2buf,0,sizeof(mag2buf)*nfreqs); - /* pack the shorts */ - for (i=0;i