17 #ifndef R8B_CDSPREALFFT_INCLUDED 18 #define R8B_CDSPREALFFT_INCLUDED 22 #if !R8B_IPP && !R8B_PFFFT 24 #endif // !R8B_IPP && !R8B_PFFFT 61 return( InvMulConst );
95 float*
const op = (
float*) p;
98 for( i = 0; i < Len; i++ )
100 op[ i ] = (float) p[ i ];
103 #endif // R8B_FLOATFFT 107 ippsFFTFwd_RToPerm_64f( p, p, SPtr, WorkBuffer );
111 pffft_transform_ordered( setup, op, op, work, PFFFT_FORWARD );
115 ooura_fft :: rdft( Len, 1, p, wi.
getPtr(), wd.
getPtr() );
131 ippsFFTInv_PermToR_64f( p, p, SPtr, WorkBuffer );
135 pffft_transform_ordered( setup, (
float*) p, (
float*) p, work,
140 ooura_fft :: rdft( Len, -1, p, wi.
getPtr(), wd.
getPtr() );
146 const float*
const ip = (
const float*) p;
149 for( i = Len - 1; i >= 0; i-- )
154 #endif // R8B_FLOATFFT 170 double*
const aop )
const 174 const float*
const ip1 = (
const float*) aip1;
175 const float*
const ip2 = (
const float*) aip2;
176 float*
const op = (
float*) aop;
178 #else // R8B_FLOATFFT 180 const double*
const ip1 = aip1;
181 const double*
const ip2 = aip2;
182 double*
const op = aop;
184 #endif // R8B_FLOATFFT 188 ippsMulPerm_64f( (Ipp64f*) ip1, (Ipp64f*) ip2, (Ipp64f*) op, Len );
192 op[ 0 ] = ip1[ 0 ] * ip2[ 0 ];
193 op[ 1 ] = ip1[ 1 ] * ip2[ 1 ];
199 op[ i ] = ip1[ i ] * ip2[ i ] - ip1[ i + 1 ] * ip2[ i + 1 ];
200 op[ i + 1 ] = ip1[ i ] * ip2[ i + 1 ] + ip1[ i + 1 ] * ip2[ i ];
220 const float*
const ip = (
const float*) aip;
221 float*
const op = (
float*) aop;
224 #else // R8B_FLOATFFT 226 const double*
const ip = aip;
227 double*
const op = aop;
230 #endif // R8B_FLOATFFT 234 ippsMulPerm_64f( (Ipp64f*) op, (Ipp64f*) ip, (Ipp64f*) op, Len );
245 t = op[ i ] * ip[ i ] - op[ i + 1 ] * ip[ i + 1 ];
246 op[ i + 1 ] = op[ i ] * ip[ i + 1 ] + op[ i + 1 ] * ip[ i ];
270 const float*
const ip = (
const float*) aip;
271 float*
const op = (
float*) aop;
273 #else // R8B_FLOATFFT 275 const double*
const ip = aip;
276 double*
const op = aop;
278 #endif // R8B_FLOATFFT 282 ippsMul_64f_I( (
const Ipp64f*) ip, (Ipp64f*) op, Len );
288 for( i = 0; i < Len; i++ )
307 float*
const p = (
float*) ap;
309 #else // R8B_FLOATFFT 311 double*
const p = ap;
313 #endif // R8B_FLOATFFT 335 IppsFFTSpec_R_64f* SPtr;
374 CObjKeeper& operator = (
CDSPRealFFT*
const aObject )
403 : LenBits( aLenBits )
404 , Len( 1 << aLenBits )
406 , InvMulConst( 1.0 / Len )
408 , InvMulConst( 1.0 / Len )
410 , InvMulConst( 2.0 / Len )
419 ippsFFTGetSize_R_64f( LenBits, IPP_FFT_NODIV_BY_ANY,
420 ippAlgHintFast, &SpecSize, &SpecBufferSize, &BufferSize );
423 SpecBuffer.
alloc( SpecSize );
424 WorkBuffer.
alloc( BufferSize );
426 ippsFFTInit_R_64f( &SPtr, LenBits, IPP_FFT_NODIV_BY_ANY,
427 ippAlgHintFast, SpecBuffer, InitBuffer );
431 setup = pffft_new_setup( Len, PFFFT_REAL );
436 wi.
alloc( (
int) ceil( 2.0 + sqrt( (
double) ( Len >> 1 ))));
438 wd.
alloc( Len >> 1 );
446 pffft_destroy_setup( setup );
480 Object = acquire( LenBits );
514 if( Object -> LenBits == LenBits )
522 Object = acquire( LenBits );
543 static CDSPRealFFT :: CObjKeeper FFTObjects[];
556 R8BASSERT( LenBits > 0 && LenBits <= 30 );
560 if( FFTObjects[ LenBits ] == NULL )
566 FFTObjects[ LenBits ] = ffto -> Next;
581 ffto -> Next = FFTObjects[ ffto -> LenBits ];
582 FFTObjects[ ffto -> LenBits ] = ffto;
610 const int LenMult = 2,
const bool DoFinalMul =
true,
611 double*
const DCGroupDelay = NULL )
617 const int Len = 1 << LenBits;
618 const int Len2 = Len >> 1;
624 memcpy( &ip[ 0 ], Kernel, KernelLen *
sizeof(
double ));
625 memset( &ip[ KernelLen ], 0, ( Len - KernelLen ) *
sizeof(
double ));
634 float*
const aip = (
float*) &ip[ 0 ];
635 float*
const aip2 = (
float*) &ip2[ 0 ];
636 const float nzbias = 1e-35;
637 #else // R8B_FLOATFFT 638 double*
const aip = &ip[ 0 ];
639 double*
const aip2 = &ip2[ 0 ];
640 const double nzbias = 1e-300;
641 #endif // R8B_FLOATFFT 643 aip2[ 0 ] = aip[ 0 ];
644 aip[ 0 ] = log( fabs( aip[ 0 ]) + nzbias );
645 aip2[ Len2 ] = aip[ 1 ];
646 aip[ 1 ] = log( fabs( aip[ 1 ]) + nzbias );
648 for( i = 1; i < Len2; i++ )
650 aip2[ i ] = sqrt( aip[ i * 2 ] * aip[ i * 2 ] +
651 aip[ i * 2 + 1 ] * aip[ i * 2 + 1 ]);
653 aip[ i * 2 ] = log( aip2[ i ] + nzbias );
654 aip[ i * 2 + 1 ] = 0.0;
662 const double m2 = -m1;
666 for( i = 1; i < Len2; i++ )
673 for( i = Len2 + 1; i < Len; i++ )
684 aip[ 0 ] = aip2[ 0 ];
685 aip[ 1 ] = aip2[ Len2 ];
687 for( i = 1; i < Len2; i++ )
689 aip[ i * 2 + 0 ] = cos( aip[ i * 2 + 1 ]) * aip2[ i ];
690 aip[ i * 2 + 1 ] = sin( aip[ i * 2 + 1 ]) * aip2[ i ];
697 for( i = 0; i < KernelLen; i++ )
699 Kernel[ i ] = ip[ i ] * m1;
704 memcpy( &Kernel[ 0 ], &ip[ 0 ], KernelLen *
sizeof(
double ));
707 if( DCGroupDelay != NULL )
712 tmp, tmp, *DCGroupDelay );
718 #endif // VOX_CDSPREALFFT_INCLUDED void init(const int LenBits)
Function acquires FFT object with the specified block length.
Definition: CDSPRealFFT.h:510
int getBitOccupancy(const int v)
Definition: r8bbase.h:775
double getInvMulConst() const
Definition: CDSPRealFFT.h:59
void convertToZ(double *const ap) const
Function converts the specified forward-transformed block into "zero-phase" form suitable for use wit...
Definition: CDSPRealFFT.h:303
#define R8BASSERT(e)
Assertion macro used to check for certain run-time conditions.
Definition: r8bconf.h:72
Real-valued FFT transform class.
Definition: CDSPRealFFT.h:47
Wrapper class for Takuya OOURA's FFT functions.
void forward(double *const p) const
Function performs in-place forward FFT.
Definition: CDSPRealFFT.h:91
void calcFIRFilterResponseAndGroupDelay(const double *const flt, const int fltlen, const double th, double &re, double &im, double &gd)
Function calculates frequency response and group delay of the specified FIR filter at the specified c...
Definition: r8bbase.h:882
#define R8BNOCTOR(ClassName)
A special macro that defines empty copy-constructor and copy operator with the "private:" prefix...
Definition: r8bbase.h:144
void multiplyBlocksZ(const double *const aip, double *const aop) const
Function multiplies two complex-valued data blocks in-place, considering that the "ip" block contains...
Definition: CDSPRealFFT.h:266
Multi-threaded synchronization object class.
Definition: r8bbase.h:526
The "base" inclusion file with basic classes and functions.
int getLenBits() const
Definition: CDSPRealFFT.h:69
void inverse(double *const p) const
Function performs in-place inverse FFT.
Definition: CDSPRealFFT.h:127
A "keeper" class for real-valued FFT transform objects.
Definition: CDSPRealFFT.h:461
int getLen() const
Definition: CDSPRealFFT.h:79
#define R8BSYNC(SyncObject)
The synchronization macro.
Definition: r8bbase.h:664
void multiplyBlocks(const double *const aip1, const double *const aip2, double *const aop) const
Function multiplies two complex-valued data blocks and places result in a new data block...
Definition: CDSPRealFFT.h:169
void reset()
Function releases a previously acquired FFT object.
Definition: CDSPRealFFT.h:529
Templated memory buffer class for element buffers of fixed capacity.
Definition: r8bbase.h:278
T * getPtr() const
Definition: r8bbase.h:378
#define R8B_BASECLASS
Macro defines the name of the class from which all classes that are designed to be created on heap ar...
Definition: r8bconf.h:99
void calcMinPhaseTransform(double *const Kernel, const int KernelLen, const int LenMult=2, const bool DoFinalMul=true, double *const DCGroupDelay=NULL)
Function calculates the minimum-phase transform of the filter kernel, using a discrete Hilbert transf...
Definition: CDSPRealFFT.h:609
The "r8brain-free-src" library namespace.
Definition: CDSPBlockConvolver.h:21
void alloc(const int Capacity)
Function allocates memory so that the specified number of elements of type T can be stored in *this b...
Definition: r8bbase.h:318
void multiplyBlocks(const double *const aip, double *const aop) const
Function multiplies two complex-valued data blocks in-place.
Definition: CDSPRealFFT.h:216
CDSPRealFFTKeeper(const int LenBits)
Function acquires FFT object with the specified block length.
Definition: CDSPRealFFT.h:478