0

我需要从视频中提取音频并通过使用 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;

};

4

2 回答 2

2

也许这可以帮助遇到同样问题的人: 我已经使用 SuperpoweredAdvancedAudioPlayer 类的 setPitchShiftCents 方法实现了它。此方法在播放音频时进行音高转换。

于 2017-11-21T19:34:49.663 回答
0

您可以使用PlayerExample项目并在 audioProcessing 回调的开头添加两行:

player->setTempo(1.0, true); // Needed for the pitch shifting to work
player->setPitchShift(-12); // Pitch shift one octave down
于 2019-08-16T15:35:10.850 回答