Search Unity

Audio Busses

Discussion in 'Scripting' started by RyanPaterson, Sep 17, 2014.

  1. RyanPaterson

    RyanPaterson

    Joined:
    Dec 14, 2013
    Posts:
    77
    Hi,

    I'm making a game with interactive audio and procedural elements for my major project (audio engineering student), and I thought of the idea of (simple) audio busses to make things a bit more organised, and add the feature into my options menu of being able to lower sounds as you please, music, sfx, ambience etc..

    I worked out a nice way to do it by tagging sounds via enumerators and having a script organise them and send them to the correct audio source, and it all worked.

    Then I realised audio sources work with clips, and can't do more than one at a time. (Without having to create more audio sources)

    Has anyone got any information they could give me to point me in the right direction? Or suggestions?

    Thanks
     
  2. Krysalgir

    Krysalgir

    Joined:
    Aug 30, 2010
    Posts:
    95
    Maybe use several channels (audio sources) per kind of sound, and synchronize their settings?
    When playing a sound of a specific kind, assign it to the first free audiosource of its kind.
     
  3. RyanPaterson

    RyanPaterson

    Joined:
    Dec 14, 2013
    Posts:
    77
    That's a good idea.
    However I'll have to create new audiosources and sync them whenever there's no free channel available.

    It's a bit messier than I would have hoped to see this go.. but then I guess it would look good in the writeup.
    Cheers for the idea I appreciate it!
     
  4. Krysalgir

    Krysalgir

    Joined:
    Aug 30, 2010
    Posts:
    95
    You're welcome ;)

    You can imagine a SoundManager that has a list of SoundItems (a simple class containing the actual file, their kind - enum?, the name/enum), and several instances of AudioSourcesManager, each one containing n audiosources and for a unique kind of sound.
    When I do something similar I have a public SoundItems[] to set them up inthe editor, and at start/awake I build a Dictionary<string, SoundItem> by parsing the array and add the pair soundItem.name/soundItem, it's then easier to get the actual sound corresponding to your key.

    When you ask your SoundManager to play "soundA", it will fetch its kind of sound, fetch the AudiosourcesManager corresponding, ask the ASM to play the sound, and the ASMwill fetch the first available audiosource ;)
    The ASM can determine the availability on its Update() by checking whether all its audiosources are playing or not a sound.
     
  5. RyanPaterson

    RyanPaterson

    Joined:
    Dec 14, 2013
    Posts:
    77
    Yeah it does seem like a pretty solid way to manage it. Let's hope the new unity audio system has bus capability!
    Cheers again
     
  6. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,038
    The 5.0 system is all buses and stuff, just like the pictures show. But do you have time to wait for it? Beta is soon, but public release might be a long way away.
     
  7. RyanPaterson

    RyanPaterson

    Joined:
    Dec 14, 2013
    Posts:
    77
    Thanks for the post, unfortunately I don't have the time, by the time it comes out I would have to rewrite a load of my written assignment. I am very excited for the next audio system though, it looks amazing.
     
  8. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,038
    Yeah, it's basically some of the niceness of a DAW. Until then you're a bit stuck doing your own system :/