问题描述
我有一个音板它只是一个带有大约 8 个按钮的屏幕.每个单独的按钮都有自己的声音,在按钮按下时播放有几种方法可以播放声音,例如使用 SystemSound 或 AVAudioPlayer到目前为止,系统声音似乎具有最快的响应时间,avaudioplayer 很慢,如果用户真的快速点击按钮,它就跟不上,我为每个声音都创建了一个音频播放器,这很混乱.这就是我现在播放声音的方式.h 文件
I have a soundboardit's just a screen with about 8 buttons.each individual button will have its own sound which will be played upon button pressThere are a couple of ways I could play the sound, such as using SystemSound or AVAudioPlayersystem sound so far seems have the quickest response times, avaudioplayer is quite slow, it cant keep up if the user taps on the buttons really fast, I created an audio player for each sound which was quite messy.this is how I'm playing the sounds at the momentthe .h file
@interface MainScreenViewController : UIViewController <AVAudioPlayerDelegate, UITabBarControllerDelegate> {
AVAudioPlayer *player;
CFURLRef keNURL;
SystemSoundID keNObject;
//KE LOUD
CFURLRef keLURL;
SystemSoundID keLObject;
//GE NORMAL
CFURLRef geNURL;
SystemSoundID geNObject;
//GE LOUD
CFURLRef geLURL;
SystemSoundID geLObject;
//NA NORMAL
CFURLRef naNURL;
SystemSoundID naNObject;
//NA LOUD
CFURLRef naLURL;
SystemSoundID naLObject;
//RA
CFURLRef raURL;
SystemSoundID raObject;
//DAGGA CLICK
CFURLRef daCURL;
SystemSoundID daCObject;
//TILLI CLICK
CFURLRef tiCURL;
SystemSoundID tiCObject;
}
@property (nonatomic, retain) AVAudioPlayer *player;
@property (readwrite) CFURLRef keNURL;
@property (readonly) SystemSoundID keNObject;
@property (readwrite) CFURLRef keLURL;
@property (readonly) SystemSoundID keLObject;
@property (readwrite) CFURLRef geNURL;
@property (readonly) SystemSoundID geNObject;
@property (readwrite) CFURLRef geLURL;
@property (readonly) SystemSoundID geLObject;
@property (readwrite) CFURLRef naNURL;
@property (readonly) SystemSoundID naNObject;
@property (readwrite) CFURLRef naLURL;
@property (readonly) SystemSoundID naLObject;
@property (readwrite) CFURLRef raURL;
@property (readonly) SystemSoundID raObject;
@property (readwrite) CFURLRef daCURL;
@property (readonly) SystemSoundID daCObject;
@property (readwrite) CFURLRef tiCURL;
@property (readonly) SystemSoundID tiCObject;
}
然后播放个人声音的动作
then the actions that play the individual sounds
然后是.m文件,在导入.h文件和正确的框架工作并综合所有变量后,编写动作代码这就是个人行动中的内容.
then the .m file, after importing the .h file and the right frame works and synthesizing all the variables, write the code for the actionand this is what's in the individual actions.
-(IBAction)geSound{
AudioServicesPlaySystemSound (self.geNObject);
}
我只是想知道 systemsound 是否是我创建音板的前进方向.尤其是当用户在节拍之间快速交替敲击板时..如果不是,播放响应非常好的声音的最佳方式是什么?
I just wanted to know if systemsound is the way forward for me to create a soundboard.thanks especially when the user will tap on the board really fast alternating between beats..if not what is the best way to play the sound which responds really well?
推荐答案
这个视频教程 我能够创建一个出色的声音管理器单身人士.这让我可以在几乎没有声音管理的情况下从任何我想要的课程中播放我需要的所有声音,单身人士会为我处理一切.
- OpenAL on the iPhone
- It was because of this video tutorial that I was able to create an excellent sound manager singleton. This allowed me to play all the sounds that I needed from any class that I wanted with little sound management, the singleton took care of everything for me.
如果您需要对音频进行精细控制,更重要的是,如果您需要低延迟的点播音频,我谦虚地建议每个人都使用 OpenAL,尤其是当您需要确保在该处播放声音以及何时播放的游戏时您需要并期望它,例如基于音频的应用程序.
I humbly suggest everyone to use OpenAL if you require fine control over your audio, and more importantly if you require a low-latency on-demand audio, specially for games when you need to make sure sound is played there and then when you require and expect it to, an audio based application for example.
这篇关于在快速按下 Xcode 按钮时快速播放声音的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!