After you all figured out, I decided to go with SoundPool to change Pitch. A playback speed of 2.0 causes the sound to play at a frequency twice that of its original, and a playback speed of 0.5 makes it play half the original frequency. The playback speed range is from 0.5 to 2.0. But he worked with frequencies lower and higher than 0.5 and 2.0.
I submit my working code,
but as its just for demo purpose, here you need to manually change the "playback speed" every time you install the application, for example: "sp.play (explosion, 1,1,0,0,1,5f)", here " 1.5f "is the playback speed. You can easily create an EditView or something similar to set the value of the playback speed at runtime.
In this application, you just need to click on the application screen to play music with the set playback speed.
import java.io.IOException; import android.app.Activity; import android.content.res.AssetFileDescriptor; import android.media.AudioManager; import android.media.SoundPool; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class SoundPoolActivity extends Activity implements OnClickListener { SoundPool sp; int explosion = 0; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); View v = new View(this); v.setOnClickListener(this); setContentView(v); sp = new SoundPool(1,AudioManager.STREAM_MUSIC,0);
source share