- Home /
Numerous simultaneous audio clips getting cut off
My iOS game creates numerous pooled AudioSource objects on demand during play when a target appears or is hit. They generally last only a short time, less than 3 seconds each. On the Mac, they all play fine, but on the device, many are not heard or played briefly then stop midway through leaving a poor game experience. Sometimes a sound is never heard that should be played - that is played on the Mac. These are all mp3-encoded and all have carefully assigned priorities. I also have checked hardware decoding on all items. With the exception of large size, long-playing music tracks from disc, they are all compressed in memory.
I'm not quite sure how to proceed to solve this. The documentation states that if the hardware decoder is in use, then FMOD software will be used, so I don't think contention for HW decoder could be the issue. I don't think priorities are the issue, but they could be. Does anyone know if there is a limit the number of simultaneous sounds that can be playing at once through an AudioListener? I'm also wondering if (lamely) that I should use PlayOneShot sound from a persistent AudioSource instead of creating a pooled AudioSource object on demand, then recycling it, as I'm doing. Writing because I'm just out of ideas right now. Thanks.
I'm guessing that the mobile device does not support certain encodings that your computer might have. I would maybe try exporting them as .wav files. Other than that I have had issues with 3d sound being checked for mobile games, try unchecking that box under each of your audio files inside unity.
Could it be the maximum amount of audio channels allowed by the device being reached?
@all & @gregzo, thanks. I don't think it's 3D sound, I tried unchecking from most of my clips and had the same problem. I think it's the number of mp3's as @gregzo and @fafade point out. I think what I should have learned when starting out with Unity was to create a test app on iOS to gauge the number of simultaneous mp3's, wavs, etc that can be played without clipping. I plan to try and use the WAV version of these clips, but because I have 100's, they will take up too much memory and extend scene loading times. I'll try loading from "disc" (flash) on many to mitigate that but disc loading may have its own limitations. I'll try to report back if anyone's interested.
Answer by jackpile · May 22, 2012 at 01:02 AM
By the way, I also looked into FMOD tech notes on iOS playback. I was noticing some very poor performance and stuttering when playing streaming WAV or AIFF files from flash. What I found was that FMOD states the native mix rate is 24KHz, so I tried resampling all of my native sounds to this rate and now plays absolutely beautifully. All very smooth, fast and high quality -- all from "disc" (flash). So I really don't need any clips in RAM. It seems to stream multiple sources from disc simultaneously just fine. Thought I'd share that. So I only have one MP3 track being streamed from disc during my levels as well. Sometimes I use a background track in addition to music in MP3 and that seems to be streamed and decoded fine without stuttering either.
Answer by gregzo · Apr 30, 2012 at 06:34 AM
I'm pretty sure you cannot play even 2 simultaneous mp3's on iOS. Use mp3 for longer cues (background, non-interactive music), and wav's set to load in memory for sounds you need to spawn quickly.
I think when you load a sound for mobile, it is always be converted to mp3 on import. http://unity3d.com/support/documentation/$$anonymous$$anual/Audio%20Files.html
The same page also states "Native: Use Native (WAV, AIFF) audio for short sound effects. The audio data will be larger but sounds won't need to be decoded at runtime. " Plus my experience with audio in Unity (coding sequencer-like apps) just tells me you may not play to mp3's at once on iOS...
Answer by Jaysta · Jul 29, 2013 at 01:01 AM
EDIT* I think Unity has fixed this problem now. I do not see any info about mp3's being clipped on compressed in memory.
Your answer
Follow this Question
Related Questions
Mac built-in microphone stopped sending data to Unity. 0 Answers
Passing Audio to an Android service? 0 Answers
3d Sound not working? 1 Answer
Audio volume problem? 2 Answers