Is there a way to play an .ogg file in Android at an increased speed?

1.3k views Asked by At

I have sound files that I want to play at 1x speed, 2x speed and 3x speed. It should be pitch corrected. There are many solutions for changing the file offline and simple having three files. However that means that my app takes more disc space.

Is there a straightforward way for online speed increase, so that I only have to include one version of the file in my App?

My App is closed source, so I can't use a GLP library.

1

There are 1 answers

1
nabulator On

The feature you are probably looking for is Audio Time Stretching. Simply changing the sample rate is not an option as it will induce pitch variation (similar to the effect produced by analogue records or cassettes)

If you want true time stretching, try using a real-time Digital Signal Processing Library. If you're willing to add an additional library to your project, TarsosDSP is a native Java framework works on Android on default.

https://github.com/JorenSix/TarsosDSP

There is even Audio Time Stretching example code included in their repository which even comes with a swing interface.

EDIT: TarsosDSP is GPL'd. Audio timestretching is a big deal in the audio industry so many of the algorithms used are either proprietary or GPL'd.

If you are willing to learn some DSP, I would recommend checking out https://github.com/philburk/jsyn It is under the Apache license and supports Android.