Search code examples
javaandroidaudiocore-audioaudio-streaming

How to change frequency of audio using java


How to change the frequency of audio sound clip using java. and what kind of api's can I use?


Solution

  • Has an answer here Changing Pitch and Frequency of Recorded Audio

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

    The frequency is the 1f part. If you change it to a value between .5f and 2.0f that should slow down or speed up the sample, which changes the pitch.

    Taken from: Changing Pitch and Frequency of Recorded Audio