[PD-cvs] pd/src d_fft.c,1.1.1.1.16.3,1.1.1.1.16.4

Tim Blechmann timblech at users.sourceforge.net
Tue Jun 15 12:07:37 CEST 2004


Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29110

Modified Files:
      Tag: devel_0_37
	d_fft.c 
Log Message:
moved fftw initialization

Index: d_fft.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/d_fft.c,v
retrieving revision 1.1.1.1.16.3
retrieving revision 1.1.1.1.16.4
diff -C2 -d -r1.1.1.1.16.3 -r1.1.1.1.16.4
*** d_fft.c	8 Apr 2004 16:53:08 -0000	1.1.1.1.16.3
--- d_fft.c	15 Jun 2004 10:07:33 -0000	1.1.1.1.16.4
***************
*** 284,300 ****
      inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
      x->x_f = 0;
-     
-     //get ready for the default blocksize
-     x->bins=64;
-     x->inreal = fftwf_malloc(sizeof(t_sample) * x->bins);
-     x->inimag = fftwf_malloc(sizeof(t_sample) * x->bins);
-     x->outreal = fftwf_malloc(sizeof(t_sample) * x->bins);
-     x->outimag = fftwf_malloc(sizeof(t_sample) * x->bins);
-     x->dim.n=64;
-     x->dim.is=1;
-     x->dim.os=1;
-     x->plan = fftwf_plan_guru_split_dft(1, &(x->dim), 0, NULL, x->inreal, 
- 					x->inimag, x->outreal, x->outimag,
- 					FFTW_ESTIMATE);
      return (x);
  }
--- 284,287 ----
***************
*** 307,323 ****
      inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
      x->x_f = 0;
- 
-     //get ready for the default blocksize
-     x->bins=64;
-     x->inreal = fftwf_malloc(sizeof(t_sample) * x->bins);
-     x->inimag = fftwf_malloc(sizeof(t_sample) * x->bins);
-     x->outreal = fftwf_malloc(sizeof(t_sample) * x->bins);
-     x->outimag = fftwf_malloc(sizeof(t_sample) * x->bins);
-     x->dim.n=64;
-     x->dim.is=1;
-     x->dim.os=1;
-     x->plan = fftwf_plan_guru_split_dft(1, &(x->dim), 0, NULL, x->inimag, 
- 					x->inreal, x->outimag, x->outreal,
- 					FFTW_ESTIMATE);
      return (x);
  }
--- 294,297 ----
***************
*** 350,376 ****
      t_int n =(t_int) w[6];
      
-     if (n != x->bins)
-     {
- 	x->bins=n;
- 	x->dim.n=n;
- 
- 	//re-allocate fft buffers
- 	fftwf_free(x->inreal);
- 	fftwf_free(x->inimag);
- 	fftwf_free(x->outreal);
- 	fftwf_free(x->outimag);
- 	x->inreal = fftwf_malloc(sizeof(t_sample) * x->bins);
- 	x->inimag = fftwf_malloc(sizeof(t_sample) * x->bins);
- 	x->outreal = fftwf_malloc(sizeof(t_sample) * x->bins);
- 	x->outimag = fftwf_malloc(sizeof(t_sample) * x->bins);
- 
- 	//set plan, this might take a few seconds
- 	//but you don't have to do that on the fly...
- 	fftwf_destroy_plan(x->plan);
- 	x->plan = fftwf_plan_guru_split_dft(1, &(x->dim), 0, NULL, x->inreal, 
- 					x->inimag, x->outreal, x->outimag,
- 					FFTW_ESTIMATE);
-     }
- 
      //prepare, execute and output results
      memcpy(x->inreal,in1,(sizeof(t_sample) * x->bins));
--- 324,327 ----
***************
*** 391,417 ****
      t_sample * out2 =(t_sample *) w[5];
      t_int n =(t_int) w[6];
-     
-     if (n != x->bins)
-     {
- 	x->bins=n;
- 	x->dim.n=n;
- 
- 	//re-allocate fft buffers
- 	fftwf_free(x->inreal);
- 	fftwf_free(x->inimag);
- 	fftwf_free(x->outreal);
- 	fftwf_free(x->outimag);
- 	x->inreal = fftwf_malloc(sizeof(t_sample) * x->bins);
- 	x->inimag = fftwf_malloc(sizeof(t_sample) * x->bins);
- 	x->outreal = fftwf_malloc(sizeof(t_sample) * x->bins);
- 	x->outimag = fftwf_malloc(sizeof(t_sample) * x->bins);
- 
- 	//set plan, this might take a few seconds
- 	//but you don't have to do that on the fly...
- 	fftwf_destroy_plan(x->plan);
- 	x->plan = fftwf_plan_guru_split_dft(1, &(x->dim), 0, NULL, x->inimag, 
- 					x->inreal, x->outimag, x->outreal,
- 					FFTW_ESTIMATE);
-     }
  
      //prepare, execute and output results
--- 342,345 ----
***************
*** 432,435 ****
--- 360,376 ----
      float *out1 = sp[2]->s_vec;
      float *out2 = sp[3]->s_vec;
+ 
+     //prepare the fft
+     x->bins=n;
+     x->inreal = fftwf_malloc(sizeof(t_sample) * x->bins);
+     x->inimag = fftwf_malloc(sizeof(t_sample) * x->bins);
+     x->outreal = fftwf_malloc(sizeof(t_sample) * x->bins);
+     x->outimag = fftwf_malloc(sizeof(t_sample) * x->bins);
+     x->dim.n=n;
+     x->dim.is=1;
+     x->dim.os=1;
+     x->plan = fftwf_plan_guru_split_dft(1, &(x->dim), 0, NULL, x->inimag, 
+ 					x->inreal, x->outimag, x->outreal,
+ 					FFTW_MEASURE);
      dsp_add(f, 6, x, in1, in2, out1, out2, n);
  }
***************
*** 489,504 ****
      outlet_new(&x->x_obj, gensym("signal"));
      x->x_f = 0;
- 
-     //get ready for the default blocksize
-     x->bins=64;
-     x->infft = fftwf_malloc(sizeof(t_sample) * x->bins);
-     x->outreal = fftwf_malloc(sizeof(t_sample) * ((x->bins)/2+1));
-     x->outimag = fftwf_malloc(sizeof(t_sample) * ((x->bins)/2+1));
-     x->dim.n=64;
-     x->dim.is=1;
-     x->dim.os=1;
-     x->plan = fftwf_plan_guru_split_dft_r2c(1, &(x->dim), 0, NULL, x->infft, 
- 					    x->outreal, x->outimag,
- 					    FFTW_ESTIMATE);
      return (x);
  }
--- 430,433 ----
***************
*** 531,555 ****
      t_int n =(t_int) w[5];
      
-     if (n != x->bins)
-     {
- 	x->bins=n;
- 	x->dim.n=n;
- 	
- 	//re-allocate fft buffers
- 	fftwf_free(x->infft);
- 	fftwf_free(x->outreal);
- 	fftwf_free(x->outimag);
- 	x->infft = fftwf_malloc(sizeof(t_sample) * x->bins);
- 	x->outreal = fftwf_malloc(sizeof(t_sample) * ((x->bins)/2+1));
- 	x->outimag = fftwf_malloc(sizeof(t_sample) * ((x->bins)/2+1));
- 	
-        	//set plan, this might take a few seconds
- 	//but you don't have to do that on the fly...
- 	fftwf_destroy_plan(x->plan);
- 	x->plan = fftwf_plan_guru_split_dft_r2c(1, &(x->dim), 0, NULL,
- 						x->infft, x->outreal,
- 						x->outimag, FFTW_ESTIMATE);
-     }
- 
      //prepare, execute and output results
      memcpy(x->infft,in1,n*sizeof(t_sample));
--- 460,463 ----
***************
*** 575,580 ****
      }
      else    
  	dsp_add(sigrfftw_perform,5,x,in1,out1,out2,n);
!     
      dsp_add_zero(out1 + n2, n2);
      dsp_add_zero(out2 + n2, n2);
--- 483,501 ----
      }
      else    
+     {
+ 	// prepare the fft
+ 	x->bins=n;
+ 	x->infft = fftwf_malloc(sizeof(t_sample) * x->bins);
+ 	x->outreal = fftwf_malloc(sizeof(t_sample) * ((x->bins)/2+1));
+ 	x->outimag = fftwf_malloc(sizeof(t_sample) * ((x->bins)/2+1));
+ 	x->dim.n=n;
+ 	x->dim.is=1;
+ 	x->dim.os=1;
+ 	x->plan = fftwf_plan_guru_split_dft_r2c(1, &(x->dim), 0, NULL, x->infft, 
+ 						x->outreal, x->outimag,
+ 						FFTW_MEASURE);
  	dsp_add(sigrfftw_perform,5,x,in1,out1,out2,n);
!     }
! 
      dsp_add_zero(out1 + n2, n2);
      dsp_add_zero(out2 + n2, n2);
***************
*** 617,633 ****
      outlet_new(&x->x_obj, gensym("signal"));
      x->x_f = 0;
- 
-     //get ready for the default blocksize
-     x->bins=64;
-     x->inreal = fftwf_malloc(sizeof(t_sample) * (x->bins)/2+1);
-     x->inimag = fftwf_malloc(sizeof(t_sample) * (x->bins)/2+1);
-     x->outfft = fftwf_malloc(sizeof(t_sample) * x->bins);
-     
-     x->dim.n=64;
-     x->dim.is=1;
-     x->dim.os=1;
-     x->plan = fftwf_plan_guru_split_dft_c2r(1, &(x->dim), 0, NULL, x->inreal, 
- 					    x->inimag, x->outfft,
- 					    FFTW_ESTIMATE);
      return (x);
  }
--- 538,541 ----
***************
*** 650,674 ****
      t_int n =(t_int) w[5];
      
-     if (n != x->bins)
-     {
- 	x->bins=n;
- 	x->dim.n=n;
- 
- 	//re-allocate fft buffers
- 	fftwf_free(x->inreal);
- 	fftwf_free(x->inimag);
- 	fftwf_free(x->outfft);
- 	x->inreal = fftwf_malloc(sizeof(t_sample) * (x->bins)/2+1);
- 	x->inimag = fftwf_malloc(sizeof(t_sample) * (x->bins)/2+1);
- 	x->outfft = fftwf_malloc(sizeof(t_sample) * x->bins);
- 
- 	//set plan, this might take a few seconds
- 	//but you don't have to do that on the fly...
- 	fftwf_destroy_plan(x->plan);
- 	x->plan = fftwf_plan_guru_split_dft_c2r(1, &(x->dim), 0, NULL,
- 						x->inreal, x->inimag, 
- 						x->outfft, FFTW_ESTIMATE);
-     }
- 
      //prepare, execute and output results
      memcpy(x->inreal,in1,(n/2+1)*sizeof(t_sample));
--- 558,561 ----
***************
*** 695,699 ****
--- 582,599 ----
  
      else    
+     {
+ 	//prepare the fft
+ 	x->bins=n;
+ 	x->inreal = fftwf_malloc(sizeof(t_sample) * (x->bins)/2+1);
+ 	x->inimag = fftwf_malloc(sizeof(t_sample) * (x->bins)/2+1);
+ 	x->outfft = fftwf_malloc(sizeof(t_sample) * x->bins);
+ 	x->dim.n=n;
+ 	x->dim.is=1;
+ 	x->dim.os=1;
+ 	x->plan = fftwf_plan_guru_split_dft_c2r(1, &(x->dim), 0, NULL, x->inreal, 
+ 						x->inimag, x->outfft,
+ 						FFTW_MEASURE);
  	dsp_add(sigrifftw_perform,5,x,in1,in2,out1,n);
+     }
  }
  





More information about the Pd-cvs mailing list