是否可以使Soundpool以更快的速度播放声音,例如播放速度快50%?

private void loadSound(int position, int group_position) {
    switch (position) {
        case 0:
            myVoice = soundPool.load(PhraseActivity.wr.get(), sound[group_position][0], 2);
            soundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() {
                @Override
                public void onLoadComplete(SoundPool soundPool, int sampleId,
                    int status) {
                    soundPool.play(myVoice, 20, 20, 1, 0, 1f);
                }
            });
        break;
        case 1:
            myVoice = soundPool.load(PhraseActivity.wr.get(), sound[group_position][1], 2);
            soundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() {
                @Override
                public void onLoadComplete(SoundPool soundPool, int sampleId,
                    int status) {
                    soundPool.play(myVoice, 20, 20, 1, 0, 1f);
                }
            });
        break;
    }
}

最佳答案

播放速率允许应用程序更改声音的播放速率(音高)。值1.0表示以原始频率播放。值为2.0表示播放速度快一倍,值为0.5表示播放速度为一半。
Doc

所以你需要改变
soundPool.play(myVoice, 20, 20, 1, 0, 1f);

soundPool.play(myVoice, 20, 20, 1, 0, 2f);

2的值将使速度提高到所需的50%

关于android - 使用SoundPool加速声音,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17846177/

10-10 17:22