audio pitch change in android - android

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.

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.

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

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

Related

Microphone input RMS measurement on Android device

I want to measure the RMS value of the input audio signal over periods of 100-200 ms on an Android device without recording the audio to a file. This is not to measure the noise level, I only need the RMS value of the ADC. Please suggest an appropriate approach. Should I look into the AudioRecord class, the Oboe library or something completely different? I am an amateur with very basic Android/Kotlin knowledge. Thank you!)
I tried to find examples of Kotlin code regarding recording audio from a microphone to a byte array, but I did not succeed.

Audio tone change when changing speed in IJKPlayer

I am working with ijkplayer video player library to play videos in my android app.But when i try to increase the audio speed (e.g 1.5+) it change my audio tone.I looked into the source code of ijkplayer but couldn't figure out the issue. When setting playback rate it calculates pitch and sample rate which seems working to me.I enabled soundtouch for playing audio.Can anyone help me figure out how i can fix this issue. If you need more information please leave a comment.
I'm not familiar with the specific software you are using, but a fundamental aspect of sound is that if you change the rate of the playback, this will change the pitch of the sound. Sound is measured in pulses per unit time, for example, in Hertz, which is waves per second, where 440 Hz is the A note used to tune an orchestra. If you change the rate of playback to speed it up 50%, the resulting sound will vibrate at 660 Hz, which is the E above that A.
If you want to change the playback rate without altering the pitch, this will require additional digital signal processing. The algorithm is a bit too complex for me to explain here. It involves breaking the original signal up into 'granules' and rejoining them. The process is specialized enough that it is something more commonly dealt with at another forum, dedicated to Signal Processing.

Android AudioTrack latency with playback

I am trying to play raw sound data using AudioTrack class in Android, I am using the write method, but I noticed that there is a latency between the write method returns and the actual sound is played, to make it simple let us use AudioRecord class as the following psedu code:
//init AudioTrack
//init AudioRecord
while(true){
byte [] buffer = new byte[1000];
int read = audioRecord(buffer,0,1000);
audioTrack.write(buffer,0,read);
}
I expect to get latency that is read / sample rate seconds but the actual sound is played after and extra of about 0.5 seconds, I really need the audio to be played with minimum latency, so does anyone has an explanation of what is going on and is there any available solution or should I accept this as it is a hardware issue?
I'm assuming your goal is to come up with some interactive audio solution (that is, where sound is played in response to some user action), because in this scenario low latency really matters.
On Android, to achieve the lowest latency you need to use Open SL ES API which is available to native (C++) code via NDK. The only Java side mechanism that can achieve low latency is SoundPool class, but it has limitations in what kind of sounds you can play.
For more information, see the page on high-performance audio, and also check out this SO answer: Low-latency audio playback on Android

change voice modulation in android

I need the change the voice modulation of an audio file, tried whole day with SoundPool but it only changes the playing speed of audio. I want to change the modulation. Need your suggestion, Thanks in advance.
See the accepted answer for Python Audio Frame Pitch Change for a brief explanation of what you need to do. For Java libraries that lets you do FFT / inverse FFT, see e.g. FFTW (I haven't used it myself, so I can't provide any help with that part).

How to implement bass effect in android?

I want to develop a bass effect for media player.Can any body help me regarding this..
First step is to isolate the low-frequency components. You will need an FFT to do this... there's one linked to this older S/O question.
After you've got the frequency representation of your audio data, alter the magnitudes of the low-frequency components as you see it, run the inverse transform to convert it back to audio samples, and pass it to the audio hardware for playback.

Categories

Resources