是否有可能让声音以更快的速度播放,例如,播放速度快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;
}
}发布于 2013-07-24 23:06:07
回放速率允许应用程序改变声音的回放速率(音高)。值1.0意味着在原来的频率上回放。值2.0意味着回放速度的两倍,值0.5意味着半速回放。请参阅文档
所以你需要改变
soundPool.play(myVoice, 20, 20, 1, 0, 1f);
至
soundPool.play(myVoice, 20, 20, 1, 0, 2f);
2的值将按您的要求将速度提高50%。
发布于 2013-07-24 23:04:24
play()的最后一个参数控制播放速率。
见医生们。
参数 soundID: load()函数返回的soundID leftVolume:左卷值(范围= 0.0至1.0) rightVolume:右卷值(范围= 0.0至1.0) 优先级:流优先级(0 =最低优先级) 循环:循环模式(0 =无循环,-1 =永久循环) 速率:播放速率(1.0 =正常播放,范围为0.5至2.0)
请注意,您只能将速度从0.5更改为2.0,这意味着速度是速度的一半到两倍。任何超过这一点的东西,您都必须想出一个自定义实现。
https://stackoverflow.com/questions/17846177
复制相似问题