Change the tempo of the tempo / playback of Android

I am creating an Android application that requires a change in real-time playback speed / speed. I searched all over the Internet and saw many solutions, including Tutorials for OpenSL ES for Android. How to change the tempo of sound and individuality of tone using ffmpeg?

Since I'm relatively new to development and android, some of them are just from my level.

Many of these examples talk about Soundpool, but this api does not work with large files.

After looking at the API and classes, I found the setPlaybackRate (int sampleRateInHz) method under the AudioTrack class. http://developer.android.com/reference/android/media/AudioTrack.html#setPlaybackRate(int)

However, in all of these examples, none of them mention this. Am I missing something and can I use it?

Any help is much appreciated

+4
source share
2 answers

setPlaybackRate() can really be used, but probably not what you are looking for.

Suppose you have an audio stream at 44100. You can use this function to set the playback speed to 22050 Hz, which means that the samples will be sent to the audio output at half speed, and this will really slow down the music. The disadvantage is that the frequency of the sound will also drop to half, due to the same fact that the samples are fed at half speed.

API Android . , Java, .

- ++ JNI, , , , ffmpeg.

+2

API 23, MediaPlayer , .

MediaPlayer

public void setPlaybackParams (PlaybackParams params) API 23

PlaybackParams. params    : . IllegalStateException, . IllegalArgumentException, .

:

MediaPlayer mp = ...; //Whatever
float speed = 0.75f;     
mp.setPlaybackParams(mp.getPlaybackParams().setSpeed(speed));
+2

Source: https://habr.com/ru/post/1530324/


All Articles