控制声音Xcode的速度

控制声音Xcode的速度

本文介绍了控制声音Xcode的速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有可能减慢xcode中的声音.我的意思是,我将在xcode的支持文件中添加一些.mp3文件,并创建可加快或减慢其速度的应用.例如带有滑块.可能吗?如果是的话,有人可以帮助我一些想法吗?谢谢

I'm wondering whether it's possible to slow down a sound in xcode. I mean I'll add some .mp3 file in my supporting files in xcode and I'll create app which will be able to speed it up or slow down. For example with slider. Is it even possible? If yes, could anyone help me with some idea? Thanks

推荐答案

AVAudioPlayer具有rate属性,该属性应能够帮助您实现目标. http://developer.apple.com/library/IOS/#documentation/AVFoundation/Reference/AVAudioPlayerClassReference/Reference/Reference.html

AVAudioPlayer has a rate property which should be able to help you accomplish your goal.http://developer.apple.com/library/IOS/#documentation/AVFoundation/Reference/AVAudioPlayerClassReference/Reference/Reference.html

讨论

此属性的默认值为1.0,可提供正常的播放速率. 可用范围从0.5的半速播放到2.0 进行双速播放.

This property’s default value of 1.0 provides normal playback rate. The available range is from 0.5 for half-speed playback through 2.0 for double-speed playback.

要设置音频播放器的播放速率,必须首先启用速率 调整,如enableRate属性说明中所述.

To set an audio player’s playback rate, you must first enable rate adjustment as described in the enableRate property description.

我还在AVAudioPlayer的价格上找到了一个不错的帖子: AVAudioPlayer费率

I also found a good SO post on the AVAudioPlayer's rate:AVAudioPlayer rate

似乎就像您提到的那样,您可以将滑块的值设置为0.5到2.0,并在更改值时使用来修改音频播放器的速率

Seems like as you'd mentioned you could set a slider with values from 0.5 to 2.0 and on valuechanged modify the audio players rate by using

- (IBAction)changeValue:(UISlider *)sender
{
    //made up assumed ivar names
    if ([_audioPlayer respondsToSelector:@selector(setEnableRate:)])
        _audioPlayer.enableRate = YES;
    if ([_audioPlayer respondsToSelector:@selector(setRate:)])
        _audioPlayer.rate = [NSNumber numberWithFloat:slideValue];
}

这篇关于控制声音Xcode的速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 08:51