iPhone音频分析 [英] iPhone audio analysis

查看:166
本文介绍了iPhone音频分析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究开发一款iPhone应用程序,它可能会对从标准手机麦克风接收的音频进行简单分析。具体来说,我对麦克风图片的高点和低点感兴趣,而且介于两者之间的所有内容都与我无关。

有没有一个应用程序已经这样做(只是这样我可以看到它的能力)?我应该在哪里开始使用这些代码?

感谢您的帮助。

I'm looking into developing an iPhone app that will potentially involve a "simple" analysis of audio it is receiving from the standard phone mic. Specifically, I am interested in the highs and lows the mic pics up, and really everything in between is irrelevant to me.

Is there an app that does this already (just so I can see what its capable of)? And where should I look to get started on such code?

Thanks for your help.

推荐答案

查看音频队列框架。这就是我用来获得高水位的原因:

Look in the Audio Queue framework. This is what I use to get a high water mark:

AudioQueueRef audioQueue; // Imagine this is correctly set up
UInt32 dataSize = sizeof(AudioQueueLevelMeterState) * recordFormat.mChannelsPerFrame;
AudioQueueLevelMeterState *levels = (AudioQueueLevelMeterState*)malloc(dataSize);

float channelAvg = 0;

OSStatus rc = AudioQueueGetProperty(audioQueue, kAudioQueueProperty_CurrentLevelMeter, levels, &dataSize);
if (rc) {
    NSLog(@"AudioQueueGetProperty(CurrentLevelMeter) returned %@", rc);
} else {    
    for (int i = 0; i < recordFormat.mChannelsPerFrame; i++) {
        channelAvg += levels[i].mPeakPower;
    }
}
free(levels);

// This works because one channel always has an mAveragePower of 0.
return channelAvg;

您可以在dB Free Scale(使用kAudioQueueProperty_CurrentLevelMeterDB)中获得峰值功率,或者只是作为浮点数获得interval [0.0,1.0](使用kAudioQueueProperty_CurrentLevelMeter)。

You can get peak power in either dB Free Scale (with kAudioQueueProperty_CurrentLevelMeterDB) or simply as a float in the interval [0.0, 1.0] (with kAudioQueueProperty_CurrentLevelMeter).

这篇关于iPhone音频分析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆