Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 this 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

Ok, the crackling was due to a little bad scripting, but I still have the problem of sounds not playing when they should.

avatar image Kleptomaniac · Feb 24, 2012 at 11:59 PM 0
Share

Could we see the code you're using? It would help lots to answer your question.

avatar image Rush3fan · Feb 25, 2012 at 11:33 AM 0
Share

The code is enormous in it's complexity. I would have to share the entire source for you to see what's going on..

But here's the basic code that plays the sound in Update()

if(!BumpSound.isPlaying) { BumpSound.Play(); }

That's super simple and is never supposed to fail.

The problem came when I added the ambient background sounds. They are just plain 3D sound objects that are set to loop and play at start.. nothing complicated about that.

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 everything 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

Well, i guess it depends on how the reverb does work behind the scenes. I guess it can't be applied to many sources at the same time.

Good you figured it out ;)

avatar image Rush3fan · Feb 26, 2012 at 06:52 PM 0
Share

I'm still working on it.. the doppler effect is another problem. I can drive past a sound source, and will only hear the behind-sound.. and no, it's not because my cars are traveling the speed of sound.. something else weird is going on here.. I might have to test this on more computers, and if the problem persists, I will have to remove the doppler effects all together.

I should also see what happens in a quad speaker scenario.

avatar image Rush3fan · Feb 26, 2012 at 06:58 PM 1
Share

Oh.. never$$anonymous$$d.. I left it on quad.. that's what happened.. so scratch the doppler issue.

avatar image s-m-k · Sep 26, 2014 at 04:00 PM 0
Share

Is it by any chance related to this: Inconsistent AudioSource.volume behavior ?

Because it sounds very similar.

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 = this;
     }
     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

This 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=highest 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

Hmm.. there must be a standard number of channels.. I will have to look into this. I really hate my onboard soundcard right now. You can literally 'hear' the graphics card churning out frequencies into my headphones, and then it produces this static noise while my computer is going into hibernation or sleep. It makes me jump out of my chair every time I hear it.. it's so annoying. Anyway.. I'm going to check out the tech specs and see if I can find anything on that. Wish me luck.

avatar image Rush3fan · Feb 25, 2012 at 11:42 AM 0
Share

"when there's more AudioSources playing than available hardware channels" I don't get that part.. Normally when I am looking at buying a sound card, "channels" is always referred to what type of surround sound it uses. :/

avatar image Bunny83 · Feb 25, 2012 at 02:57 PM 0
Share

I know that's confusing because they always use "channel". The number of "hardware channels" tell you how many audio sources your soundcard can mix together at once. We hadn't issues in our game so far.

I don't know much about how F$$anonymous$$OD handles multiple sources. Some audio libraries have additional software mixers so they combine multiple sources into one hardware channel, but i'm not sure if Unity / F$$anonymous$$OD supports this. It would of course produce additional load on your CPU.

avatar image Rush3fan · Feb 25, 2012 at 03:13 PM 0
Share

Hmm.. this is just confusing.. They licence Fmod for like $9,000.. :/ Sounds like a super expensive workaround to me..

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.

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

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

Some AudioClips not playing in build 1 Answer

Audio Not Always Playing 3 Answers

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