FDS 계산에 vDSP를 사용하는 것은 매우 쉽습니다. 나는 당신이 입력에 대한 실제 가치가 있다고 가정하고 있습니다. VDSP에서 사용하는 FFT 알고리즘이 내부적으로 사용하는 팩형 복합 배열로 실제 가치가있는 배열을 변환해야한다는 것을 명심해야합니다.
당신은 설명서에 좋은 개요를 볼 수 있습니다
const int n = 1024;
const int log2n = 10; // 2^10 = 1024
DSPSplitComplex a;
a.realp = new float[n/2];
a.imagp = new float[n/2];
// prepare the fft algo (you want to reuse the setup across fft calculations)
FFTSetup setup = vDSP_create_fftsetup(log2n, kFFTRadix2);
// copy the input to the packed complex array that the fft algo uses
vDSP_ctoz((DSPComplex *) input, 2, &a, 1, n/2);
// calculate the fft
vDSP_fft_zrip(setup, &a, 1, log2n, FFT_FORWARD);
// do something with the complex spectrum
for (size_t i = 0; i < n/2; ++i) {
a.realp[i];
a.imagp[i];
}
한 트릭 a.realp[0]
은 DC 오프셋 점이다 :
여기 https://developer.apple.com/library/content/documentation/Performance/Conceptual/vDSP_Programming_Guide/UsingFourierTransforms/UsingFourierTransforms.html
실제 가치 FFT를 계산하는 작은 예입니다 a.imagp[0]
은 나이 퀴 스트 주파수에서 실수 값입니다.