Hi all,
I use some sounds like machine gun and monster hurt sounds in my scene and I am afraid if I don’t manage correctly created sounds may invade RAM too much and/or make CPU busy (because of garbage collection and like that)
How can I handle audio clips in a good way?
Forexample I tried Master Audio package which is very sofisticated one but still it seems it doesn’t prevent performance issues.
What can I do, is there any well known pooling process for audioclips or just using audiosource.playoneshot() may solve all of my problems?
You can have a single machine gun sfx object and a single monster sfx object with Audiosources. Then when you need them just relocate them and use playoneshot().
In addition you can change the audio distance volume profile to reduce the range and limit the sources as well as lowering the priority of the audiosources (this can ensure player audio has priority and is always played).
You could also use distance from player to adjust priority.
Hi. Do you actually have examples of where audio has been an issue for performance? My wip game uses master audio as well. I have about 300 sound effects, background music and a small number of effects e.g. reverb and audio performance is not an issue. I am developing for pc platform so perhaps on mobile this would be different.
Profile. If it isn’t a problem you’re just making additional work for yourself for no benefit and if you do this often enough you will never finish anything.
General rule of thumb is to stream any large files from disk (such as music) and other small sound files like gunshots etc. directly from RAM. This will make a big difference in memory use because large files don’t have to be entirely put into memory but rather read in small chunks from your harddrive.