• 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
1
Question by Rush3fan · Feb 24, 2012 at 11:59 AM · soundnot workingeffectsfxplaying

How many sounds can play all at once?

I have been having the worst trouble with the sound in my game.

I have the start of a race where everyone is reving up their engines. (thats 5 3D sfx)

Then the 321 go! sequence (another 2 2D sfx)

There is the background music playing (1 2D sfx)

There are different ambient city environment sounds looping (3 3D sfx)

There are the regular sfx for the car (5 3D sfx)

Ok, so that's a lot of sound effects, but the priority option goes to 256 layers.. I don't see why 1/4th of my sounds don't play. Occasionally, I can hear t$$anonymous$$s crackling sound on one of the car's sound effects. What is going on? Could it be my sound card, or am I breaking some rules? I first imagined that I could have 256 sounds playing all at once, but where have I gone wrong?

Comment
Add comment · Show 3
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 Rush3fan · Feb 24, 2012 at 03:21 PM 0
Share
avatar image Kleptomaniac · Feb 24, 2012 at 11:59 PM 0
Share
avatar image Rush3fan · Feb 25, 2012 at 11:33 AM 0
Share

3 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Rush3fan · Feb 26, 2012 at 11:53 AM

Hey.. I figured it out.

It's a bug in Unity - or with my soundcard.

I forgot to mention one little detail, and that was that I had an audio reverb zone set up in one area of my scene. I deleted it, and everyt$$anonymous$$ng works now..

Yay.. and Boo that I can't use audio reverb zones!

Comment
Add comment · 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 Bunny83 · Feb 26, 2012 at 01:27 PM 0
Share
avatar image Rush3fan · Feb 26, 2012 at 06:52 PM 0
Share
avatar image Rush3fan · Feb 26, 2012 at 06:58 PM 1
Share
avatar image s-m-k · Sep 26, 2014 at 04:00 PM 0
Share
avatar image
2

Answer by hawken · Apr 03, 2018 at 03:30 AM

I've found that if you try to play more than 20 sounds at the same time through an audiosource / audiosources unity will stop playing audio entirely.

One technique that is simple is to count how many sounds you are playing and what their duration is, when they stop playing (using clip.length) uncount the sound. If the amount of sounds playing is more than 20 deny any new sounds from playing until less than 20 sounds are playing.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 /*
     really simple audio manager, to stop unity audio from crackling or becoming inaudible
 
     hawken king 2016
 
  */
 
 public class AudioPlayer : MonoBehaviour {
 
     public static AudioPlayer instance;
     public AudioSource audioSource;
     int playing;
     void Start() 
     {
         instance = t$$anonymous$$s;
     }
     public void PlayAudio(string clip)
     {
         if (playing > 20) return;
         StartCoroutine(Playclip(clip));
     }
     IEnumerator Playclip(string clip)
     {
         playing++;
         AudioClip a = Resources.Load("Audio/"+clip) as AudioClip;
         audioSource.PlayOneShot(a);
         yield return new WaitForSeconds(a.length);
         playing--;
     }
 }
Comment
Add comment · 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
1

Answer by Bunny83 · Feb 25, 2012 at 12:45 AM

T$$anonymous$$s depends on your hardware. See the AudioSource.priority documentation:

Unity is virtualizing AudioSources, when there's more AudioSources playing than available hardware channels. The AudioSources with lowest priority (and audibility) is virtualized first. Priority is an integer between 0 and 256. 0=$$anonymous$$ghest priority, 256=lowest priority

Comment
Add comment · 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 Rush3fan · Feb 25, 2012 at 11:16 AM 0
Share
avatar image Rush3fan · Feb 25, 2012 at 11:42 AM 0
Share
avatar image Bunny83 · Feb 25, 2012 at 02:57 PM 0
Share
avatar image Rush3fan · Feb 25, 2012 at 03:13 PM 0
Share

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

8 People are following this question.

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

Related Questions

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

Audio Not Always Playing 3 Answers

2d collision doesn't detect properly in game 0 Answers

Some AudioClips not playing in build 1 Answer

Best way to play audio sound effects 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