开发者

Creating a single instance of a sound fx in MonoTouch and why is audio so bad for performance?

What I'd like to do is create a re-usable audio class which doesn't allocate/deallocate resources beyond ints initialization/destruction.

So a class such as:

class SoundInst
{
   public SoundInst(string sounddir);
   public bool IsPlaying;
   public void Play(float volume);
   public void Stop();
}

The reason I ask for such a thing is that I'm finding creating audio on the run is a prohibitively slow affair. My game runs at a solid 60fps without audio but with audio it drops to below 15fps when even one or two sounds are created and played in the same frame.

What I found is that it's not the sounds themselves which are slowing things down but rather creating them. I can run many sounds simultaneously and keep them on loop and it has no impact on performance.

Any ideas 开发者_Python百科on solving this problem of mine?


I am not sure about mono touch but if you are just using audio in a game i would look at the av foundation framework and more specifically the avaudioplayer. This is what i use for my games. It will allow you to load your music asynchronously which should help to fix your performance drop issues.

A link to the framework: http://developer.apple.com/library/ios/#documentation/AVFoundation/Reference/AVFoundationFramework/_index.html%23//apple_ref/doc/uid/TP40008072

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜