예제 #1
0
void AccelerateFFT<double>::setAudioFrameSize (int frameSize)
{
    fftSize = frameSize;
    fftSizeOver2 = fftSize / 2;
    log2n = log2f (fftSize);
    
    if (configured)
    {
        free (doubleComplexSplit.realp);
        free (doubleComplexSplit.imagp);
        vDSP_destroy_fftsetupD (fftSetupDouble);
    }
    
    doubleComplexSplit.realp = (double*)malloc (fftSize * sizeof (double));
    doubleComplexSplit.imagp = (double*)malloc (fftSize * sizeof (double));
    
    fftSetupDouble = vDSP_create_fftsetupD (log2n, FFT_RADIX2);
    
    if (fftSetupDouble == nullptr)
    {
        // couldn't set up FFT
        assert (false);
    }
    
    configured = true;
}
예제 #2
0
void xtract_init_vdsp_data(xtract_vdsp_data *vdsp_data, unsigned int N)
{
    vdsp_data->setup = vDSP_create_fftsetupD(log2f(N), FFT_RADIX2);
    vdsp_data->fft.realp = (double *) malloc((N >> 1) * sizeof(double));
    vdsp_data->fft.imagp = (double *) malloc((N >> 1) * sizeof(double));
    vdsp_data->log2N = log2f(N);
    vdsp_data->initialised = true;
}
예제 #3
0
void processing_init(Processing* p, double fd, double fMin, size_t sampleCount, size_t pointCount) {
    p->fd = fd;
    p->fMin = fMin;
    
    p->targetFrequency = 440;
    p->filter = false;
    
    p->peakFrequency = 440;
    p->peakPhase = 0;
    
    p->signalLength = ceil2((double)sampleCount);
    p->step = 1;
    
    p->subcounter = 0;
    p->subLength = 32;
    p->subSignalReal = malloc(p->subLength * sizeof(*p->subSignalReal));
    p->subSignalImag = malloc(p->subLength * sizeof(*p->subSignalImag));
    p->subSpectrumReal = malloc(p->subLength * sizeof(*p->subSpectrumReal));
    p->subSpectrumImag = malloc(p->subLength * sizeof(*p->subSpectrumImag));
    p->subSpectrum = malloc(p->subLength * sizeof(*p->subSpectrum));
    
    p->pointCount = pointCount;
    p->points = malloc(p->pointCount * sizeof(*p->points));
    
    p->signal = malloc(p->signalLength * sizeof(*p->signal));
    
    p->previewLength = PREVIEW_LENGTH;
    p->preview = malloc(p->previewLength * sizeof(*p->preview));

    memset(p->signal, 0, p->signalLength * sizeof(*p->signal));

    p->real = malloc(p->signalLength * sizeof(*p->real));
    p->imag = malloc(p->signalLength * sizeof(*p->imag));
    
    p->spectrum = malloc(p->signalLength * sizeof(*p->spectrum));
    
    p->fs = vDSP_create_fftsetupD(log2(p->signalLength), kFFTRadix2);
    p->sfs = vDSP_create_fftsetupD(log2(p->subLength), kFFTRadix2);
}
예제 #4
0
void 
FFTLib_op::Initialize(int N, bool optimize)
{
        Exp = (int) log2(N);
	if (Init)
	{
		delete[] A.realp;
		delete[] A.imagp;
		vDSP_destroy_fftsetupD(SetupReal);
	}
		
	A.realp = new double[ N/2];
	A.imagp = new double[ N/2];
	SetupReal = vDSP_create_fftsetupD(Exp, 0);
	Init = true;
}
예제 #5
0
파일: main.cpp 프로젝트: SvenDeSmet/ESTL
void computeReferenceD(clFFT_SplitComplexDouble *out, clFFT_Dim3 n, 
					  unsigned int batchSize, clFFT_Dimension dim, clFFT_Direction dir)
{
	FFTSetupD plan_vdsp;
	DSPDoubleSplitComplex out_vdsp;
	FFTDirection dir_vdsp = dir == clFFT_Forward ? FFT_FORWARD : FFT_INVERSE;
	
	unsigned int i, j, k;
	unsigned int stride;
	unsigned int log2Nx = (int) log2(n.x);
	unsigned int log2Ny = (int) log2(n.y);
	unsigned int log2Nz = (int) log2(n.z);
	unsigned int log2N;
	
	log2N = log2Nx;
	log2N = log2N > log2Ny ? log2N : log2Ny;
	log2N = log2N > log2Nz ? log2N : log2Nz;
	
	plan_vdsp = vDSP_create_fftsetupD(log2N, 2);
	
	switch(dim)
	{
		case clFFT_1D:
			
			for(i = 0; i < batchSize; i++)
			{
				stride = i * n.x;
				out_vdsp.realp  = out->real  + stride;
				out_vdsp.imagp  = out->imag  + stride;
				
			    vDSP_fft_zipD(plan_vdsp, &out_vdsp, 1, log2Nx, dir_vdsp);
			}
			break;
			
		case clFFT_2D:
			
			for(i = 0; i < batchSize; i++)
			{
				for(j = 0; j < n.y; j++)
				{
					stride = j * n.x + i * n.x * n.y;
					out_vdsp.realp = out->real + stride;
					out_vdsp.imagp = out->imag + stride;
					
					vDSP_fft_zipD(plan_vdsp, &out_vdsp, 1, log2Nx, dir_vdsp);
				}
			}
			for(i = 0; i < batchSize; i++)
			{
				for(j = 0; j < n.x; j++)
				{
					stride = j + i * n.x  * n.y;
					out_vdsp.realp = out->real + stride;
					out_vdsp.imagp = out->imag + stride;
					
					vDSP_fft_zipD(plan_vdsp, &out_vdsp, n.x, log2Ny, dir_vdsp);
				}
			}
			break;
			
		case clFFT_3D:
			
			for(i = 0; i < batchSize; i++)
			{
				for(j = 0; j < n.z; j++)
				{
					for(k = 0; k < n.y; k++)
					{
						stride = k * n.x + j * n.x * n.y + i * n.x * n.y * n.z;
						out_vdsp.realp = out->real + stride;
						out_vdsp.imagp = out->imag + stride;
						
						vDSP_fft_zipD(plan_vdsp, &out_vdsp, 1, log2Nx, dir_vdsp);
					}
				}
			}
			for(i = 0; i < batchSize; i++)
			{
				for(j = 0; j < n.z; j++)
				{
					for(k = 0; k < n.x; k++)
					{
						stride = k + j * n.x * n.y + i * n.x * n.y * n.z;
						out_vdsp.realp = out->real + stride;
						out_vdsp.imagp = out->imag + stride;
						
						vDSP_fft_zipD(plan_vdsp, &out_vdsp, n.x, log2Ny, dir_vdsp);
					}
				}
			}
			for(i = 0; i < batchSize; i++)
			{
				for(j = 0; j < n.y; j++)
				{
					for(k = 0; k < n.x; k++)
					{
						stride = k + j * n.x + i * n.x * n.y * n.z;
						out_vdsp.realp = out->real + stride;
						out_vdsp.imagp = out->imag + stride;
						
						vDSP_fft_zipD(plan_vdsp, &out_vdsp, n.x*n.y, log2Nz, dir_vdsp);
					}
				}
			}
			break;
	}
	
	vDSP_destroy_fftsetupD(plan_vdsp);
}