1

I'm trying to use the currentPlaybackRate property on MPMusicPlayerController to adjust the tempo of a music track as it plays. The property works as expected when the rate is less than 0.90 or greater than 1.13, but for the range just above and below 1, there seems to be no change in tempo. Here's what I'm trying:

UIAppDelegate.musicPlayer = [MPMusicPlayerController iPodMusicPlayer]; 

... load music player with track from library

[UIAppDelegate.musicPlayer play];

- (void)speedUp{

        UIAppDelegate.musicPlayer.currentPlaybackRate =  UIAppDelegate.musicPlayer.currentPlaybackRate + 0.03125;           
}

- (void)speedDown
{

        UIAppDelegate.musicPlayer.currentPlaybackRate = UIAppDelegate.musicPlayer.currentPlaybackRate - 0.03125;

}

I can monitor the value currentPlaybackRate and see that it's being correctly set, but there seems to be no different in playback tempo until the 0.9 or 1.13 threshold has been reached. Does anyone have any guidance or experience on the matter?

Dave Norfleet
  • 409
  • 3
  • 14

2 Answers2

2

I'm no expert, but I suspect that this phenomenon may be merely an artefact of the algorithm used to change the playback speed without raising or lowering the pitch. It's a tricky business, and here it must be done in real time without much distortion, so probably an integral multiple of the tempo is needed. You might want to read the wikipedia article on time stretching, http://en.wikipedia.org/wiki/Audio_timescale-pitch_modification

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • matt, thanks for the insight, but I know that setting the rate on an AVAudioPlayer has the desired effect with even a small percentage change. So I hoped I was missing a step - AVAudioPlayer requires an enablerate flag to be set - that someone could point out. I'll keep searching and update this if I find anything else. – Dave Norfleet Apr 26 '13 at 16:48
  • But the fact that the rate does change audibly for larger values, and that you can see it change for smaller values, suggests that you have hit some internal limitation and have done all you can do. – matt Apr 26 '13 at 17:34
0

Actually I've found out the problem: the sentence myMusicPlayer.currentPlaybackRate = 1.2 must be placed after the sentence .play(). If you put the rate setting before the .play(), it would not work.

sunyi
  • 3
  • 2