mirror of
https://github.com/mborgerding/kissfft.git
synced 2025-05-27 21:20:27 -04:00
piddly little changes to fastfir stuff
This commit is contained in:
parent
ebd0d360e0
commit
624f8edfd3
@ -89,9 +89,9 @@ def utilfastfilter(sig,h,nfft,usereal):
|
|||||||
open( 'sig.dat','w').write( compfft.dopack(sig,'f',not usereal) )
|
open( 'sig.dat','w').write( compfft.dopack(sig,'f',not usereal) )
|
||||||
open( 'h.dat','w').write( compfft.dopack(h,'f',not usereal) )
|
open( 'h.dat','w').write( compfft.dopack(h,'f',not usereal) )
|
||||||
if usereal:
|
if usereal:
|
||||||
util = './ffr_float'
|
util = './fastconvr'
|
||||||
else:
|
else:
|
||||||
util = './ff_float'
|
util = './fastconv'
|
||||||
cmd = 'time %s -n %d -i sig.dat -h h.dat -o out.dat' % (util, nfft)
|
cmd = 'time %s -n %d -i sig.dat -h h.dat -o out.dat' % (util, nfft)
|
||||||
print cmd
|
print cmd
|
||||||
ec = os.system(cmd)
|
ec = os.system(cmd)
|
||||||
|
@ -320,6 +320,7 @@ void direct_file_filter(
|
|||||||
free (circbuf);
|
free (circbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void do_file_filter(
|
void do_file_filter(
|
||||||
FILE * fin,
|
FILE * fin,
|
||||||
FILE * fout,
|
FILE * fout,
|
||||||
@ -327,6 +328,7 @@ void do_file_filter(
|
|||||||
size_t n_imp_resp,
|
size_t n_imp_resp,
|
||||||
size_t nfft )
|
size_t nfft )
|
||||||
{
|
{
|
||||||
|
int fdin,fdout;
|
||||||
size_t n_samps_buf;
|
size_t n_samps_buf;
|
||||||
|
|
||||||
void * cfg;
|
void * cfg;
|
||||||
@ -334,10 +336,15 @@ void do_file_filter(
|
|||||||
size_t nread,nwrite;
|
size_t nread,nwrite;
|
||||||
size_t idx_inbuf;
|
size_t idx_inbuf;
|
||||||
|
|
||||||
|
fdout = fileno(fout);
|
||||||
|
|
||||||
cfg=kiss_fastfir_alloc(imp_resp,n_imp_resp,&nfft,0,0);
|
cfg=kiss_fastfir_alloc(imp_resp,n_imp_resp,&nfft,0,0);
|
||||||
|
|
||||||
/* use length to minimize buffer shift*/
|
/* use length to minimize buffer shift*/
|
||||||
n_samps_buf = nfft + 5*(nfft-n_imp_resp+1);
|
n_samps_buf = 8*4096/sizeof(kffsamp_t);
|
||||||
|
n_samps_buf = nfft + 4*(nfft-n_imp_resp+1);
|
||||||
|
|
||||||
|
fprintf(stderr,"bufsize=%d\n",sizeof(kffsamp_t)*n_samps_buf );
|
||||||
|
|
||||||
/*allocate space and initialize pointers */
|
/*allocate space and initialize pointers */
|
||||||
inbuf = (kffsamp_t*)malloc(sizeof(kffsamp_t)*n_samps_buf);
|
inbuf = (kffsamp_t*)malloc(sizeof(kffsamp_t)*n_samps_buf);
|
||||||
@ -346,14 +353,14 @@ void do_file_filter(
|
|||||||
idx_inbuf=0;
|
idx_inbuf=0;
|
||||||
do{
|
do{
|
||||||
/* start reading at inbuf[idx_inbuf] */
|
/* start reading at inbuf[idx_inbuf] */
|
||||||
nread = fread( inbuf + idx_inbuf, sizeof(kffsamp_t), n_samps_buf - idx_inbuf , fin );
|
nread = fread( inbuf + idx_inbuf, sizeof(kffsamp_t), n_samps_buf - idx_inbuf,fin );
|
||||||
|
|
||||||
/* If nread==0, then this is a flush.
|
/* If nread==0, then this is a flush.
|
||||||
The total number of samples in input is idx_inbuf + nread . */
|
The total number of samples in input is idx_inbuf + nread . */
|
||||||
nwrite = kiss_fastfir(cfg, inbuf, outbuf,nread,&idx_inbuf);
|
nwrite = kiss_fastfir(cfg, inbuf, outbuf,nread,&idx_inbuf) * sizeof(kffsamp_t);
|
||||||
/* kiss_fastfir moved any unused samples to the front of inbuf and updated idx_inbuf */
|
/* kiss_fastfir moved any unused samples to the front of inbuf and updated idx_inbuf */
|
||||||
|
|
||||||
if ( fwrite( outbuf, sizeof(outbuf[0]), nwrite, fout) != nwrite ) {
|
if ( write(fdout, outbuf, nwrite) != nwrite ) {
|
||||||
perror("short write");
|
perror("short write");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user