ウェブ全体を検索しましたが、 SoundTouch ライブラリをビート検出 に使用する方法に関するチュートリアルが見つかりません。
(注: これまで C++ の経験はありません。C、Objective-C、および Java は知っています。したがって、これを台無しにすることもできましたが、コンパイルは可能です。)
フレームワークをプロジェクトに追加し、次のものをコンパイルすることができました。
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()
ましたが、うまくいかないようです。
誰にも考えはありますか?