什么是对快速按钮presses X $ C $ç快速播放声音的最好方法? [英] what is the best way to play sound quickly upon fast button presses xcode?
问题描述
喜
我有一个共鸣板
它只是其中约8个按钮的屏幕。
每个按键都会有自己的声音,将在按钮preSS播放
有一对夫妇的方式,我可以播放声音,如使用SystemSound或AVAudioPlayer
系统声音至今似乎有最快的响应时间,avaudioplayer是相当缓慢的,它不能跟上,如果用户上的按钮水龙头真快,我创建了这是相当混乱的每个声音的音频播放器。
这是怎么打的IM的声音的那一刻
.h文件
hi i have a soundboard its just a screen with about 8 buttons. each individual button will have its own sound which will be played upon button press There are a couple of ways i could play the sound, such as using SystemSound or AVAudioPlayer system 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 im playing the sounds at the moment the .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文件和右框架工程和综合所有的变量后,写code的作用
这是什么的个人行为。
then the .m file, after importing the .h file and the right frame works and synthesizing all the variables, write the code for the action and this is whats 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?
推荐答案
22/03/2014 - 更新:摆脱了我过于兴奋后(这是很久以前写的)的和更新,以塑造一个更合适的答案。
我必须实现精细控制音频以便选择使用的OpenAL。
WOW是总结起来的一种方式。当我上台后,它自己使用的OpenAL这需要一些额外的专家组的工作,让所有需要的方法来实现,并设置了一切;我发现自己,几乎没有明显的延迟可言。我是绝对高兴的优异成绩。
I had to achieve fine control over audio so opted to use OpenAL. WOW is one way to sum it up. As soon as I took it upon myself to use OpenAL which required a bit of extra leg work, getting all the required methods implemented and setting everything up; I found myself with practically no noticeable latency at all. I was absolutely pleased with the excellent results.
我是能够同时实现精确控制,无延迟的。我记得在欢乐的时候跳,当我有它的工作。
I was able to achieve both fine control and no latency at all. I remember jumping in joy at the time when I had it working.
下面是我用有助于缓解实施的OpenAL的第一次的努力的资源:
Here are the resources I used that helped ease the endeavor of implementing OpenAL for the first time:
- OpenAL on the iPhone
- It was because of
this linkthis 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.
这篇关于什么是对快速按钮presses X $ C $ç快速播放声音的最好方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!