嗨,伙计们,我正试图在播放时改变声音的音高。
我正在使用Audio Track。
public void start() {
if (isPlaying()) {
return;
}
mKeepPlaying = true;
mAudioTrack.flush();
if(mAudioTrack != null)
{
mAudioTrack.setPlaybackRate(44100);
mAudioTrack.play();
// Setting thread feeding the audio samples to the audio hardware.
// (Assumes mChannels = 1 or 2).
mPlayThread = new Thread()
{
public void run() {
int position = mPlaybackStart * mChannels;
mSamples.position(position);
int limit = mNumSamples * mChannels;
while (mSamples.position() < limit && mKeepPlaying)
{
int numSamplesLeft = limit - mSamples.position();
if (numSamplesLeft >= mBuffer.length)
{
mSamples.get(mBuffer);
} else
{
for (int i = numSamplesLeft; i < mBuffer.length; i++)
{
mBuffer[i] = 0;
}
mSamples.get(mBuffer, 0, numSamplesLeft);
}
// TODO(nfaralli): use the write method that takes a ByteBuffer as argument.
mAudioTrack.write(mBuffer, 0, mBuffer.length);
}
}
};
mPlayThread.start();
}
}
因此,如果我将setPlayBackRate()更改为88200,则音高会增加,但声音的速度会增加。如何以与44100相同的速度播放?
我在Google Play上看到的应用,音乐变速器正是我想要的。我希望能够在没有音频改变速度的情况下改变Pitch Octaves +1.00或-1.00