【发布时间】:2013-07-20 02:08:30
【问题描述】:
我搜索了整个网络,但找不到有关如何使用SoundTouch library 进行节拍检测的教程。
(注意:在此之前我没有 C++ 经验。我知道 C、Objective-C 和 Java。所以我可能会搞砸一些,但它可以编译。)
我将framework 添加到我的项目中并设法编译以下内容:
NSString *path = [[NSBundle mainBundle] pathForResource:@"song" ofType:@"wav"];
NSData *data = [NSData dataWithContentsOfFile:path];
player =[[AVAudioPlayer alloc] initWithData:data error:NULL];
player.volume = 1.0;
player.delegate = self;
[player prepareToPlay];
[player play];
NSUInteger len = [player.data length]; // Get the length of the data
soundtouch::SAMPLETYPE sampleBuffer[len]; // Create buffer array
[player.data getBytes:sampleBuffer length:len]; // Copy the bytes into the buffer
soundtouch::BPMDetect *BPM = new soundtouch::BPMDetect(player.numberOfChannels, [[player.settings valueForKey:@"AVSampleRateKey"] longValue]); // This is working (tested)
BPM->inputSamples(sampleBuffer, len); // Send the samples to the BPM class
NSLog(@"Beats Per Minute = %f", BPM->getBpm()); // Print out the BPM - currently returns 0.00 for errors per documentation
inputSamples(*samples, numSamples) 歌曲字节信息让我感到困惑。
如何从歌曲文件中获取这些信息?
我尝试使用memcpy(),但它似乎不起作用。
有人有什么想法吗?
【问题讨论】:
标签: ios audio objective-c++ soundtouch