• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by davekalina · Mar 10, 2015 at 03:32 PM · audiosourceaudioclipmusicmp3

How do I setup music for optimal playback on iOS?

Whenever we start playing a new 'stream from disc' audio clip, our game "$$anonymous$$tches" 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 t$$anonymous$$ngs set properly, but since t$$anonymous$$s has been going on for as long as I can remember, I feel I must be missing somet$$anonymous$$ng.

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 w$$anonymous$$ch 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 $$anonymous$$tches.

W$$anonymous$$le it's not exactly a fatal error, our game is fast-paced and performance $$anonymous$$tches like t$$anonymous$$s are very noticeable, even on $$anonymous$$gher end devices. Would obviously like to know what we're doing wrong!

Comment

People who like this

0 Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image wkaj · Mar 12, 2015 at 06:01 PM 0
Share

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

avatar image davekalina · Mar 12, 2015 at 06:04 PM 0
Share

Hello wkaj,

  • Music 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 minutes typically.

  • Unity 4.6.3 -- we were on Unity 4.5 for ages and 4.6 has made no difference.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

22 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

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

How to stop music from restarting when reloading scene it began? 0 Answers

How to play a playlist of mp3s randomly? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges