我想在iOS应用程序中实现节拍检测。我找到了一个相当简单的框架叫做SoundTouch,并尝试按照iOS SoundTouch framework BPM Detection example的说明实施。
不幸的是,我的所有努力似乎都没有奏效,目前陷入了僵局状态,因此我发布了这篇文章到Stackoverflow上。
我采取了以下步骤:
- Create single-view-based project
- Imported the
- Renamed mainViewController.m to ViewController.mm to make it compatible with c++
- Instructed the UIViewController class of the ViewController to conform to the AVFoundationPlayerDelegate protocols.
- Copy/Pasted the solution @MrHappyAsthma posted to his question
Refactored
player =[[AVAudioPlayer alloc] initWithData:data error:NULL];
to
AVAudioPlayer *player =[[AVAudioPlayer alloc] initWithData:data error:NULL];
现在编译器报错了:
soundtouch::SAMPLETYPE sampleBuffer[len]; (use of undeclared variable soundtouch)
soundtouch::BPMDetect BPM(player.numberOfChannels, [[player.settings valueForKey:@"AVSampleRateKey"] longValue]); (use of undeclared variable soundtouch)
BPM.inputSamples(sampleBuffer, len/player.numberOfChannels); (use of undeclared variable BPM)
NSLog(@"Beats Per Minute = %f", BPM.getBpm()); (use of undeclared variable BPM)
我认为我的C ++知识不如应该,并且需要声明/初始化对象soundtouch和BPM。
谢谢大家!