This may be helpful. After everything was done, I decided to go with SoundPool to change Pitch. The playback speed 2.0 leads to the fact that the sound is reproduced at a frequency of two times compared with the original, and the playback speed of 0.5 leads to the fact that it reproduces half of its 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