1

I am developing a sound related application. I am trying to change the audio sound in to completely different like robot sound or make the audio echo. I tried with soundpool , but no any idea, anyone knows how to achieve that? i need only a basic idea to achieve this, please help. many thanks.

bitbonk
  • 48,890
  • 37
  • 186
  • 278
Chris
  • 1,311
  • 2
  • 15
  • 37
  • Have you considered native (C) processing of the data, saving it to the file (e.g. wav) and play it back? Input format of data would be helpful to determine the best implementation way. – sandrstar Oct 24 '12 at 08:04
  • Try this https://stackoverflow.com/a/30696843/14576798 – Rohit gupta May 07 '23 at 20:38

3 Answers3

5

Pitch and echo are 2 different things.

Pitch:

You can alter the pitch by modifing the playback rate. You can do it in 2 ways, with audioTrack and setPlayBackRate or with SoundPool and setRate. Depends on your needs, AudioTrack allow a larger range of pitch (from 1hz to x2) on large files and SoundPool for sound effects and picth can vary between x0.5 and x2.

Echo/reverb:

You can archive this with AudioEffect since API lvl 9 by attaching it to an AudioTrack or MediaPlayer instance.

Damien Praca
  • 3,126
  • 21
  • 14
1

For a robot effect you want to set a constant pitch for the audio. I.e. do a FFT, move everything into a single frequency bin, and then do an inverse FFT to get back into the time domain.

For an echo effect you could keep a separate buffer which is as long as your desired echo delay. And for every sample do something like the following (pseudo-code):

output = mix(currentSample, echoBuffer[echoPos]*echoVolume)
echoBuffer[echoPos] = mix(currentSample, echoBuffer[echoPos]*echofeedback)
echoPos += 1
Michael
  • 57,169
  • 9
  • 80
  • 125
0

Im working on a similar project and i can say that you need to look into DSP (digital signal processing), PCM 16 format and preferably fourier transforms.

It is possible to loopback audio with the AudioRecord class (running a thread constantly filling the buffer on a AudioTrack)

But the delay might be too big for what you are trying to accomplish.

Best of luck in your endevours!

Some really good pointers: Android AudioRecord class - process live mic audio quickly, set up callback function

Community
  • 1
  • 1
EJTH
  • 2,178
  • 1
  • 20
  • 25