改变录音的音高和频率

我一直在尝试使用以下代码调整录音音频的音高:

http://developer.android.com/guide/topics/media/audio-capture.html

我的猜测是这个调整应该用MediaRecorder来完成。

http://developer.android.com/reference/android/media/MediaRecorder.html

但是,我不确定哪种方法可以改变音高?

通过SO查看,我发现在android中改变声音文件的频率,但我对如何将SoundPool与我正在关注的音频捕获指南中的元素进行集成感到困惑。 根据我使用的开发人员指南,是否有更简单的解决方案?

 mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); mSoundPool = new SoundPool(size, AudioManager.STREAM_MUSIC, 0); mSoundPoolMap = new HashMap(); mSoundPoolMap.put(index, mSoundPool.load(context, R.raw.sound, 1)); mSoundPool.play(id, streamVolume, streamVolume, 1, loop, 1f); 

频率是1f部分。 如果将其更改为.5f和2.0f之间的值,应该减慢或加速样本,这会改变音高。

以下是我的某个应用中的一些代码:

  private SoundPool soundpool; private HashMap soundsMap; protected void onCreate(Bundle savedInstanceState) { soundpool = new SoundPool(4, AudioManager.STREAM_MUSIC, 100); soundsMap = new HashMap(); soundsMap.put(cowbell1, soundpool.load(this, R.raw.cowbell, 1)); soundsMap.put(cowbell2, soundpool.load(this, R.raw.cowbell1, 1)); soundsMap.put(cowbell3, soundpool.load(this, R.raw.windhh3, 1)); } public void playSound(int sound, float fSpeed) { AudioManager mgr = (AudioManager)getSystemService(Context.AUDIO_SERVICE); float streamVolumeCurrent = mgr.getStreamVolume(AudioManager.STREAM_MUSIC); float streamVolumeMax = mgr.getStreamMaxVolume(AudioManager.STREAM_MUSIC); float volume = streamVolumeCurrent / streamVolumeMax; soundpool.play(soundsMap.get(sound), volume, volume, 1, 0, fSpeed); } 

要拨打声音我用这个:

  playSound(cowbell1, 1.0f); or playSound(cowbell2, 1.0f); 

可以通过更改1.0f值来更改速率。

如果您仍然无法发布代码,我会看一下。