5

Accelerate フレームワークを使用して高速フーリエ変換 (FFT) を実行しており、それで使用する 1024 の長さのバッファーを作成する方法を見つけようとしています。 FFTを実行したい信号。

誰かが私を助けたり、これを行うためのヒントを教えてくれますか?

4

1 に答える 1

11

Apple のvDSP Programming Guideには、FFT の設定方法の例がいくつか掲載されています。また、 vDSP Examplesサンプル アプリケーションもチェックしてください。Mac の場合、このコードは iOS にも直接変換する必要があります。

最近、次のコードを使用して、64 整数入力波形の単純な FFT を実行する必要がありました。

static FFTSetupD fft_weights;
static DSPDoubleSplitComplex input;
static double *magnitudes;

+ (void)initialize
{
    /* Setup weights (twiddle factors) */
    fft_weights = vDSP_create_fftsetupD(6, kFFTRadix2);

    /* Allocate memory to store split-complex input and output data */
    input.realp = (double *)malloc(64 * sizeof(double));
    input.imagp = (double *)malloc(64 * sizeof(double));
    magnitudes = (double *)malloc(64 * sizeof(double));
}

- (CGFloat)performAcceleratedFastFourierTransformAndReturnMaximumAmplitudeForArray:(NSUInteger *)waveformArray;
{   
    for (NSUInteger currentInputSampleIndex = 0; currentInputSampleIndex < 64; currentInputSampleIndex++)
    {
        input.realp[currentInputSampleIndex] = (double)waveformArray[currentInputSampleIndex];
        input.imagp[currentInputSampleIndex] = 0.0f;
    }

    /* 1D in-place complex FFT */
    vDSP_fft_zipD(fft_weights, &input, 1, 6, FFT_FORWARD);  

    input.realp[0] = 0.0;
    input.imagp[0] = 0.0;

    // Get magnitudes
    vDSP_zvmagsD(&input, 1, magnitudes, 1, 64);

    // Extract the maximum value and its index
    double fftMax = 0.0;
    vDSP_maxmgvD(magnitudes, 1, &fftMax, 64);

    return sqrt(fftMax);
}

ご覧のとおり、この FFT では実際の値のみを使用して入力バッファーを設定し、FFT を実行してから振幅を読み取りました。

于 2011-01-26T16:57:47.420 に答える