MPMusicPlayerController speed adjustment

Hi

Is there a way to adjust the playback speed of an MPMusicPlayerController song?

I searched everywhere but found nothing useful. If there is no way to do this, where can I find an example that does this with other components? Some say OpenAL, but I can't find any clear way to use the iPod library with this and change the speed of the song ...

The main thing I need:

  • User selects song from iPod library via MPMusicPlayerController
  • You have two buttons: Slow down and accelerate

If the user clicks "Slow Down", the speed of the song slows down, if you say 5% or something like that. Accelerate, on the contrary.

I really hope someone helps me with this!

Thanks in advance!

+4
source share
3 answers

You can use AVAudioPlayer and AVPlayer for the above purpose.
They have a speed property that can set the speed of a song.

 [AVPlayer setRate:1.25]; // 25% faster 

However, AVPlayer cannot change the speed by 5%, but 25%, and AVAudioPlayer - on iOS 5 and higher.
If you want to go for another alternative, then Dirac is the best option. Try DIRAC 3 LE , which is free.

Use the Link to get an idea of ​​how to use Dirac. For more information let me know.

@girish_vr

+1
source

No, you cannot do this using only MPMusicPlayerController.

If you do not mind that the step up and down is proportional to changes in speed, you can use Resampler OpenAL after converting your sound file to source files or PCM buffers.

If you do not want the pitch to change, then what you are looking for is a DSP stretch / change / pitch correction method. OpenAL cannot do this, but there are commercial DSP libraries (possibly DIRAC) that can do this on iOS. You can also try writing your own phase vocoder, but this is a non-trivial digital signal processing code.

-1
source

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


All Articles