Iphone 从aurio touch2示例代码中获取频率值
如何获取苹果提供的auriotouch 2示例代码的频率值。有人能帮我吗。我还想得到计算频率的时间。提前谢谢。我已经尝试了很多,但是如何从中获得频率值呢Iphone 从aurio touch2示例代码中获取频率值,iphone,ios,cocoa-touch,audio,Iphone,Ios,Cocoa Touch,Audio,如何获取苹果提供的auriotouch 2示例代码的频率值。有人能帮我吗。我还想得到计算频率的时间。提前谢谢。我已经尝试了很多,但是如何从中获得频率值呢 [_audioRecorder stop]; NSLog(@"error :%@", [self OSStatusToStr:[self open:[self path]]]); UInt32 N = 4096; UInt32 log2n = 32 - CountLeadingZeroes(N - 1); UInt32 n
[_audioRecorder stop];
NSLog(@"error :%@", [self OSStatusToStr:[self open:[self path]]]);
UInt32 N = 4096;
UInt32 log2n = 32 - CountLeadingZeroes(N - 1);
UInt32 n = 1 << log2n;
UInt32 stride = 1;
UInt32 nOver2 = n / 2;
DSPSplitComplex A;
FFTSetup setupReal ;
// printf("1D real FFT of length log2 ( %d ) = %d\n\n", n, log2n);
/* Allocate memory for the input operands and check its availability,
* use the vector version to get 16-byte alignment. */
A.realp = (float *) malloc(nOver2 * sizeof(float));
A.imagp = (float *) malloc(nOver2 * sizeof(float));
float * originalReal = (float *) malloc(n * sizeof(float));
float * obtainedReal = (float *) malloc(n * sizeof(float));
if (originalReal == NULL || A.realp == NULL || A.imagp == NULL) {
printf("\nmalloc failed to allocate memory for the real FFT"
"section of the sample.\n");
exit(0);
}
/* Generate an input signal in the real domain. */
for (int i = 0; i < n; i++){
originalReal[i] = (float) (i + 1);
}
/* Look at the real signal as an interleaved complex vector by
* casting it. Then call the transformation function vDSP_ctoz to
* get a split complex vector, which for a real signal, divides into
* an even-odd configuration. */
vDSP_ctoz((COMPLEX *) originalReal, 2, &A, 1, nOver2);
/* Set up the required memory for the FFT routines and check its
* availability. */
setupReal = vDSP_create_fftsetup(log2n, FFT_RADIX2);
if (setupReal == NULL) {
printf("\nFFT_Setup failed to allocate enough memory for"
"the real FFT.\n");
exit(0);
}
/* Carry out a Forward and Inverse FFT transform. */
vDSP_fft_zrip(setupReal, &A, stride, log2n, FFT_FORWARD);
vDSP_fft_zrip(setupReal, &A, stride, log2n, FFT_INVERSE);
/* Verify correctness of the results, but first scale it by 2n. */
Float32 scale = (float) 1.0 / (2 * n);
vDSP_vsmul(A.realp, 1, &scale, A.realp, 1, nOver2);
vDSP_vsmul(A.imagp, 1, &scale, A.imagp, 1, nOver2);
/* The output signal is now in a split real form. Use the function
* vDSP_ztoc to get a split real vector. */
vDSP_ztoc(&A, 1, (COMPLEX *) obtainedReal, 2, nOver2);
[[u录音机停止];
NSLog(@“error:%@,[self-OSStatusToStr:[self-open:[self-path]]);
UInt32 N=4096;
UInt32 log2n=32-计数前导零(N-1);
UInt32 n=1此类问题-例如FFT箱的中心频率-定期在此处提出。请去看看,然后修改一些问题,包括一些代码。嗨。你弄明白了吗?谢谢。我没有找到解决这个问题的办法。