简体   繁体   中英

Android - Change audio pitch

I have some audio files in my raw folder and I want to change their pitch using, for example, a seekbar. I can do this with soundpool, but I can only play short sounds (up to 5 secs). How can I change the pitch of long sounds?

SoundPool soundPool;
int soundID;
soundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0);
soundID = soundPool.load(context, R.raw.no, 1);
//play(int soundID, float leftVolume, float rightVolume, int priority, int loop, float rate)
float pitch=0.8f;
//{0.5f,0.6f,0.7f,0.8f,0.9f,1.0f,1.1f,1.2f,1.3f,1.4f,1.5f,1.6f,1.7f,1.8f,1.9f,2.0f}
soundPool.play(soundID, volume, volume, 1, 0, data.get(item));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM