我仍然在寻找计算BPM的工作代码,你们中的任何人都解决了这个问题吗?感谢任何帮助。
这是我的代码,它返回0值或错误值(与在线BPM值相比)
-(void) calcBPM {
NSString *path = [[NSBundle mainBundle] pathForResource:@"song_test" ofType:@"mp3"];
NSData *data = [NSData dataWithContentsOfFile:path];
AVAudioPlayer *player =[[AVAudioPlayer alloc] initWithData:data error:NULL];
NSUInteger len = [player.data length];
soundtouch::SAMPLETYPE sampleBuffer[len];
[player.data getBytes:sampleBuffer length:len];
soundtouch::BPMDetect BPM(player.numberOfChannels, [[player.settings valueForKey:@"AVSampleRateKey"] longValue]);
BPM.inputSamples(sampleBuffer, len/player.numberOfChannels);
NSLog(@"Beats Per Minute = %f", BPM.getBpm());
}