- Home /
How do I setup music for optimal playback on iOS?
Whenever we start playing a new 'stream from disc' audio clip, our game "hitches" for about half a second right as playback of the new track begins. It is a noticeable performance penalty -- and having developed for iOS natively in the past -- one that is completely unnecessary.
I beieve I have things set properly, but since this has been going on for as long as I can remember, I feel I must be missing something.
The music is imported into Unity as VBR mp3s.
The resulting AudioClips are set as follows:
Load type: Stream from disc
Hardware decoding: yes
3D sound: no
Our music player class references a bunch of GameObjects which contain AudioSources that point at the individual song AudioClips. The Music Player calls Stop() on the previous song and waits a second and then calls Start() on the new song, and it's in that frame -- where we call Start() on the new song -- that the game hitches.
While it's not exactly a fatal error, our game is fast-paced and performance hitches like this are very noticeable, even on higher end devices. Would obviously like to know what we're doing wrong!
Hi,
Are you loading the music via WWW or asset bundles, or is it just part of the normal scene asset load?
Are you playing the music more than once at a time?
How long is the music file? Is it a long song?
What version of Unity are you working with?
Cheers
Hello wkaj,
$$anonymous$$usic is in the scene, in a prefab which is instantiated once and never unloaded throughout the course of the game.
No, we finish a song by fading its volume to 0, stopping the AudioSource, waiting a second, and then starting a new song. It is the call to AudioSource.Play() that causes the 0.3-0.5 second spike according to the profiler.
Songs vary from 3-6 $$anonymous$$utes typically.
Unity 4.6.3 -- we were on Unity 4.5 for ages and 4.6 has made no difference.
Your answer
Follow this Question
Related Questions
C sharp cant play Audio 2 Answers
Save Audio Clips List to the disk? 0 Answers
Loop GetSpectrumData() through a song 2 Answers
Unity Unable to Reassign Audio Clip 1 Answer
Is it possible to read music from ps4 storage through an AudioSource? 0 Answers