Question

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?

Was it helpful?

Solution

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top