• 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 Xatoku · Jul 17, 2011 at 07:07 AM · audiosoundsourceplaying

Audio Not Always Playing

The way my audio is set up is that I have all of the sources as child empty gameobjects under the main object, and they are referenced to in script via something like this;

var HitSound1 : AudioSource;

HitSound1.audio.Play();

The problem I'm having, however, is that sometimes audio just won't play. Note that I have a lot of AudioSources going at the same time which may be a part of the problem, but everything is equal in priority so I don't understand why some aren't being heard. There's a mix of a few 3D ones and a whole ton of 2D ones if it matters, anyone got any clues?

Comment

People who like this

0 Show 0
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

3 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by aldonaletto · Jul 17, 2011 at 05:16 PM

I've just tested 32 3D sounds playing at the same time, and no one failed (in a PC Intel Core Duo 1.8 GHz). Unless you're developing for mobile devices, the max sounds limit isn't your current problem. I can suggest two possibilities:
1- Some sounds are not being Play'ed at all due to errors in the code. You can check this by adding the line I've suggested before - it would help to know if each sound is being played when it should:

  ...
  HitSound1.audio.Play();
  print(HitSound1.audio.clip.name);
  ...

2- Some of the audio sources are far enough from the listener to be heard. That's my favourite hypothesis, since our audition "prefers" to listen the louder sounds, and just ignore the weaker ones when there are several sounds playing at the same time. Another thing: if a continuos 3D sound is playing somewhere and you rotate the Listener slowly, you can notice that there are some "null directions" at which the sound becomes almost inaudible (it looks lika a kind of "phase cancelation"). Maybe the sounds you think are not playing are actually inaudible due to distance or direction.

Comment
Xatoku
ROOKIE

People who like this

2 Show 0 · Share
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

Answer by testure · Jul 17, 2011 at 07:08 AM

How many sounds are we talking about here? I believe there is a cap on the number of sounds an AudioListener can process.

Comment
aldonaletto
thekoop

People who like this

2 Show 4 · Share
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 Xatoku · Jul 17, 2011 at 07:18 AM 0
Share

Well since each AudioSource is responsible for only 1 clip, I'd say about 20 are referenced, but only about 5-10 will be heard simultaneously due to the game's control scheme.

avatar image aldonaletto · Jul 17, 2011 at 07:35 AM 0
Share

There's a limit, for sure! Each Audio Source requires a lot of calculation while playing, and all sounds currently playing are mixed at the Audio Listener. But I suspect the limit is well above 10 sounds. Add a print to the play code to know if it's working:

    ...
    HitSound1.audio.Play();
    print(HitSound1.audio.clip.name); 
avatar image Xatoku · Jul 17, 2011 at 07:46 AM 0
Share

What about having more than one listener? Would that help any?

avatar image testure · Jul 17, 2011 at 03:57 PM 0
Share

You can only have one listener per scene.

avatar image

Answer by TheEmeralDreamer · Sep 22, 2011 at 06:40 PM

Use Audio.PlayOneShot(yourclipname) This will allow you to play more than one clip at once if you do this for instance:

var clip1:AudioClip; var clip2:AudioClip;

function PlayDualAudio(firstClip:AudioClip,secondClip:AudiClip,volume:float)
{
Audio.PlayOneShot(firstClip,volume);
Audio.PlayOneShot(secondClip,volume);
}

Then simply call play audio and give it the arguments.

Comment

People who like this

0 Show 0 · Share
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

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.

Update about the future of Unity Answers

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta later in June. Please note, we are aiming to set Unity Answers to read-only mode on the 31st of May in order to prepare for the final data migration.

For more information, please read our full announcement.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to stop an Audio Clip without an Audio Source? 1 Answer

Can't get my sound to work.. 1 Answer

Best way to play audio sound effects 1 Answer

3D Sound Max Distance Not Working. 0 Answers

Sound getting deeper 2 Answers


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