0

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.

Christian
  • 25,249
  • 40
  • 134
  • 225
  • Hey Christian what about simply changing the sample rate of the output stream? – realvictorprm Jan 08 '17 at 20:28
  • I'm sorry that's a problem which requires more investigation – realvictorprm Jan 08 '17 at 20:59
  • [`SoundPool.setRate()`](https://developer.android.com/reference/android/media/SoundPool.html#setRate%28int,%20float%29) is no of help? – ozbek Jan 16 '17 at 06:02
  • @ozbek : The documentation says "The playback rate allows the application to vary the playback rate (pitch) of the sound." I think that means it doesn't do pitch correction. – Christian Jan 16 '17 at 08:32
  • You think or you tried and it did not work for your case? :) – ozbek Jan 16 '17 at 08:35
  • @ozbek : Basically if the function does what the documentation says it does, it won't create the result I'm looking for. Do you have reason to believe that the documentation is wrong? – Christian Jan 16 '17 at 08:42
  • @Christian No, I don't. How is VLC's implementation? It has the functionality you are looking for, but is their implementation acceptable for your case (both technically and legally, it's on GPL)? – ozbek Jan 16 '17 at 08:47
  • @ozbek : GPL unfortunately doesn't work for me. – Christian Jan 16 '17 at 11:05
  • Tarsos is a good audio processing library https://github.com/ederwander/TarsosDSP – Jon Goodwin Jan 17 '17 at 00:23

1 Answers1

1

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.

nabulator
  • 276
  • 3
  • 18