iphone - 从 iPhone 麦克风检测节拍

标签 iphone ios objective-c

我想知道这个应用程序 RoboStrobe 怎么样?检测节拍。我正在使用“AVAudioRecorder”来听麦克风并获取声级计,但我不知道计算级别和节拍并触发我的方法的正确方法。

这是我现在所做的:

调用更新方法:

levelTimer = [NSTimer scheduledTimerWithTimeInterval: 0.05 target: self selector: @selector(levelTimerCallback:) userInfo: nil repeats: YES];

以及我的更新方法

-(void)update
{
[recorder updateMeters];


const double ALPHA = 0.05;
double peakPowerForChannel = pow(10, (0.05 * [recorder peakPowerForChannel:0]));
lowPassResults = ALPHA * peakPowerForChannel + (1.0 - ALPHA) * lowPassResults;

double scale = lowPassResults * 5;
NSLog(@"Result = %f",scale);
if (scale>4.5) {
    [[UIScreen mainScreen] setBrightness:1.0];
    NSLog(@"HEAVY Scale = %f",scale);
    [self turnTorchOn:YES];
    [self performSelector:@selector(off) withObject:Nil afterDelay:0.4];
}

else
{
    [self turnTorchOn:NO];
    [[UIScreen mainScreen] setBrightness:0.1];
}
}

最佳答案

节拍检测需要重要的音频处理(梳状滤波器、起始检测等)。您将需要为此使用一个库。可能的候选人是:

但是还有更多。 StackOverflow 上有很多相关问题。

关于iphone - 从 iPhone 麦克风检测节拍,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19194995/

相关文章:

ios - 启动错误 'Watchkit extension"- SPErrorUnknownMessage

ios - 带有 Cocoa Pods 的 Swift 框架

iphone - 未调用 UIButton 操作

iphone - iOS : SA_OAuthTwitterController callback after authorization

iphone - CAEmitterLayer 非常慢

iphone - 我应该将我的 Android 应用程序移植到 iPhone 上吗?

ios - UIActivityViewController 旋转问题

iphone - UITableView 有不同方向的不同行以及如何使可见单元格在旋转后显示相同的东西

ios - 通过应用发送 facebook 请求

iphone - 评价我的应用程序的链接无法在 iPhone 上运行?