问题描述
我知道OpenAL是快速库,但是它不支持任何压缩的音频格式,而且使用起来也不那么容易...
I know that OpenAL is fast library but it doesn't support any compressed audio format and it's not so easy to use...
AVAudioPlayer的运行速度并不快,但它支持多种文件格式以及mp3等压缩格式.
AVAudioPlayer is not so fast, but supports wide range file formats, as well as compressed formats like mp3.
还有一个可以播放声音的SKAction类,以及SystemSoundID ...
Also there is an SKAction class which can play a sound, as well as SystemSoundID...
我有几个问题:
-
什么是首选的播放方式/播放器/技术:
What would be a preferred way/player/technique to play :
- 声音效果(一次多个)?
- 声音效果,有时会在短时间延迟后重复出现
- 循环播放的背景音乐
此外,将未压缩的音频用于声音效果是否明智?我想这样可以,因为这些文件的大小反而还小?
Also, is it smart move to use uncompressed audio for sound effects? I suppose this is ok, because those files have small size anyway?
推荐答案
我个人使用的是 ObjectAL .很好,因为它利用了OpenAL和AVAudioPlayer,但使您摆脱了很多复杂的部分.我的游戏包含背景音乐,大量声音同时播放以及可循环播放的声音,这些声音会根据精灵的速度而增加音量,音调等. ObjectAL可以完成所有这些工作.
I'm personally using ObjectAL. It's good because it utilizes OpenAL and AVAudioPlayer but abstracts a lot of the complicated parts away from you. My game has background music, tons of sounds playing simultaneously, and loopable sounds that increase in volume, pitch etc based on a sprites speed. ObjectAL can do all of that.
ObjectAL可以使用OALSimpleAudio类来播放简单的声音和音乐循环.或者,您可以更深入地研究它并做更复杂的事情.
ObjectAL can be used for playing simple sounds and music loops using it's OALSimpleAudio class. Or you can get deeper into it and do more complex things.
我专门为我的游戏围绕ObjectAL创建了一个简单的包装,因此它进一步从我身上抽象了.
I've created a simple wrapper around ObjectAL specifically for my game so it's further abstracted away from me.
从我阅读的内容来看,未压缩的音频效果更好.您只需要确保预先加载声音即可,这样您的游戏就不会在每次播放声音时尝试拉文件.
From what I've read, uncompressed audio is better. You just need to make sure you preload the sounds so that your game isnt trying to pull the file each time it's playing a sound.
这篇关于OpenAL与AVAudioPlayer与其他播放声音的技术的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!