我需要从视频中提取音频并通过使用 seekbar(类似这样的东西)改变音高来实时改变音高。性能需要接近实时。现在至少我需要转换音频(某人.aac音频文件)。我找到了一个 Superpowered 库,但示例没有实现音高转换,并且文档不包含有关它的信息。有人做过吗?或者也许可以帮助我使用另一个库?
我找到了这个例子,现在我正在尝试这样做:
bool NDKAudioPlayer::process(short *output, unsigned int numberOfSamples) {
double masterBpm = player->currentBpm;
bool silence = !player->process(stereoBuffer, false, numberOfSamples, volume, masterBpm);
if (!silence){
handler = new LiveTimeStretchingHandler();
setupLiveTimeStretching(handler, currentSamplerate);
liveTimeStretchingProcess(stereoBuffer, numberOfSamples, 0, handler);
delete handler;
}
// The stereoBuffer is ready now, let's put the finished audio into the requested buffers.
if (!silence) SuperpoweredFloatToShortInt(stereoBuffer, output, numberOfSamples);
return !silence;
}
这是我的 NDKAudioPlayer 类:
class NDKAudioPlayer {
public:
NDKAudioPlayer(unsigned int samplerate, unsigned int buffersize, const char *path, int audioFileOffset, int audioFileLength);
~NDKAudioPlayer();
bool process(short *pInt, unsigned int numberOfSamples);
void onPlayPause(bool play);
void onCentsChanged(int cents);
private:
SuperpoweredAndroidAudioIO *audioSystem;
SuperpoweredAdvancedAudioPlayer *player;
LiveTimeStretchingHandler *handler;
float *stereoBuffer;
float volume;
int currentSamplerate = 0;
};