Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Master Audio - AAA Sound Solution. #1 audio plugin on Asset Store!

Discussion in 'Assets and Asset Store' started by dark_tonic, Jan 28, 2013.

  1. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    No problem, that's why I'm here!
     
  2. sevensails

    sevensails

    Joined:
    Aug 22, 2013
    Posts:
    483
    I'm having some lags on the first play of some sfx on Android/iOS. I'm using uncompressed sounds and pre-loaded. What is the correct way of avoiding these lags?
     
  3. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I have "warming code" already, so unfortunately it's just an Android problem (although we have never heard of iOS problems). Nothing we can do to fix it that I'm aware of besides writing native code (which we don't have the knowledge for). Although I'll say that for our Android game and 2 iOS games we encountered none of what you're describing.

    Make sure you're also not using streaming, "load in background" or "preload audio data" = false.

    It's also possible that it could be a bug in that particular Unity version. I say that because I had another bug report that turned out to be exactly that earlier today. If you have the patience and have nothing else to try, I'd try a couple Unity versions back and see if it's any different.
     
    Last edited: Jun 18, 2016
  4. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    Hi, I'm using DynamicSoundGroupCreator to load sounds in Editor for each scene and there's a variable to access them.
    Code (CSharp):
    1.   [SerializeField]
    2.         [SoundGroupAttribute]
    3.         string sound;
    But this header can't get sound group names from DSGC, it works good if I type in those long name though. Is that by design?
     
  5. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    That's how it works currently. Yes, it will work if you type or copy/paste.

    I will add a roadmap item to make it grab Sound Groups from DGSC as well.
     
    zhuchun likes this.
  6. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    I am not sure if this has been fixed since 3.5 (the version I am using) but

    UnpauseSoundGroup isn't working. I can pause the bus by MasterAudio.PauseBus but MasterAudio.UnpauseBus does not resume playing paused bus.

    When I check the Master Audio Inspector, the sound group that I let play in loop for the bus that I want to pause seems to have paused properly because it is now marked as red and it says "playing 0%" But calling UnpauseBus doesn't do anything.
     
  7. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Probably has been fixed since. I recall something like that. We require that any users reporting bugs first try the latest version before we spend time looking into any issues. Please try that and let me know if it's still broken or not.

    That's a fairly old version you're using.
     
  8. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Master Audio V 4.0.4 will be live in 20 minutes. Changelog:

    • Added MasterAudio.RouteGroupToBus method to reassign Sound Group to a different bus at runtime.
    • Fixed compile error for Playmaker actions that were broken in 4.0.3 update.
    • Added gear icon next to Linked Groups so you can edit them if desired.
    • Jukebox time remaining for song now accounts for pitch other than 1 and shows actual real time remaining.
    • Now the Delete icon for Sound Groups is available at runtime.
    • API renaming for more consistency. MasterAudio.CreateNewSoundGroup is now CreateSoundGroup, RemoveSoundGroup is now DeleteSoundGroup, DeleteBus is now DeleteBusByIndex.
    • More API renaming for more consistency. MasterAudio.ResumeAllPlaylists is now UnpauseAllPlaylists.
    • Bug fixed: Deleting a bus will reassign all Groups on that bus to "no bus" and recalculate all Groups that were assigned to it (spatial blend / volumes).
    • Bug fixed: "type in" now allows type in for all Event Sounds dropdowns (sorting previously added made it not work in some places).
    • Bug fixed: "Start" Playlist functions would not work when you enter a new Scene with a persistent and same clone of the Playlist Controller (which gets destroyed automatically).
    • Bug fixed: Unpausing a stopped Playlist Controller was clicking "play", so it started songs over.
    • Bug fixed: When using gapless transitions was not auto-advancing songs when you had multiple Synced Playlist Controllers.
    • Bug fixed: When adding 2nd Playlist layer (Cynced) not even playing, layer 1 repeats 2nd song.
    • Bug fixed: Updated Behavior Designer compile errors from changes.
    • Updated Node Canvas compile errors from changes.
    • Added "Route To Bus" to Event Sounds, under Group Control type.
    • Added optional System.Action completedAction to all PlaySoundXAndWaitUntilFinished methods, to execute code when completed.
    • Added a boolean return value for the MasterAudio.PlaySoundXAndForget methods, so you at least know if the sound was played or scheduled (both return true, false otherwise).
    • Now not logging the warning about next gapless song rescheduled if you are paused.
    • Added new code to make layered gapless music always accurate on next song transition.
    • Added "Initialized Custom Event" to each Playlist Controller, which fires if you select one in the Inspector after the Controller is done initializing and is ready.
    • Added buttons in the top section of Master Audio game object to pause/unpause/stop the mixer and all Playlists at once. Only visible at runtime.
    • Custom Events in Dynamic SGC's now show up in the dropdown in the Inspector created by MasterCustomEvent Attribute decorated fields.
    • Sound Groups in Dynamic SGC's now show up in the dropdown in the Inspector created by SoundGroup Attribute decorated fields.
     
  9. Bioxx

    Bioxx

    Joined:
    Mar 7, 2014
    Posts:
    6
    Hi, I'm currently trying to get some simple sound effects setup in my scene as I learn the ropes of Master Audio and I'm having a failure in understanding what I am sure is a very simple concept. I have a SoundGroup set up with a single cannon fire sound(I'll add more variations later unless this is a requirement for my issue). My unit in game has 2 cannons which alternate firing. I had assumed that calling MasterAudio.PlaySound3DAtTransform would be all that I'd need to do, but I'm only ever seeing a single voice on my bus at a time.

    I would have thought that each call to PlaySound3DAtTransform would be its own voice, but that is not the case? How can I get the same sound to fire multiple times over top of each other?
     
  10. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    You have kept the default Voices (Weight) value of 1 for your Variation. You will need to increase it to whatever you require. That field is used for dual purpose.

    1) To control the weight of different variations (which is played more often).
    2) To control the maximum number of that sound effect (Variation) that can be played at once.

    A couple of the video tutorials we have touch on this, and the online documentation does explain as well. The 2nd Quick Start in the online help called "how to create your first Sound Effect with Variations" has more detail.

    Don't feel bad, this question gets asked about twice a month even though it's now documented in numerous places :)
     
  11. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    I have tried the latest MA version from Asset Store, (4.0.4) but the unpause bus issue still remains.

    Here is more information about the process.

    I call :

    MasterAudio.PauseBus("SFX");

    And then make Time.timeScale = 0;

    Then when I want to unpause, I call

    MasterAudio.UnpauseBus("SFX");

    Then set : Time.timeScale = 1;
     
  12. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    That's actually a different case. I'll fix that in the next version.
     
  13. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Hmm, I just tried this and couldn't reproduce the issue as you showed. Works fine for me. Can you send me an example package to reproduce what you're seeing?
     
  14. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Humm.. I am not sure if I can make a small project with such case..

    One more information , which is probably doesn't matter is that the sound I have been playing before the pause bus is loopable one. But this will probably have the same issue with sound with long length as well.

    I remember that when I used MA for the first time , it used to work. And then after some update it stopped working. I am not sure from what version. probably since 3.5 maybe?

    I have placed Debug.log on PauseBus function and UnpauseBus function and only 1 of them triggers so there are no other MA calls in between.
     
  15. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I had only modified MA_Player.cs and made one sound looping to test it in Standalone Scene (example).

    I didn't see any code there that cares about time scale. Not sure what is going on with your project (something weird). Have you tried it in a new blank project?
     
  16. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Ok, I have done some more debugging myself, and I think the source of the problem is that the source.time for the audio source that has been paused becomes 0. Therefore failing all the checks for the unpause function logic.

    This is probably bug in pause function instead of unpause function.

    Or this could be a Unity bug.. I am using 5.3.5p3

    I will log more stuff on the pause function to see why paused audiosource's time property is becoming 0.
     
  17. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Ok. Of course there's always the .001% chance that a looping clip could have EXACTLY looped back to sample #1 and be at zero. But that's not going to happen more than once.

    Try it on an older version of Unity if you have it.

    There really should be a normal way to tell if the audio clip is paused instead of that way I'm deciding.
     
  18. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Ok, so, I have tracked it down to :

    MaybeUnloadClip();

    Audiosource's time is good before calling this function on SoundGroupVariation : Pause

    if I comment it out from the Pause function, unpause works properly.

    Looking at the MaybeUnloadClip,

    audLocation == Clip so the first bit of check isn't happening. So it is AudioUtil.UnloadNonPreloadedAudioData(VarAudio.clip);

    I will look into that now.
     
  19. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Ok, this sounds like it will always unload (and therefore stop) any Audio clips set to "preload audio data" = false. Mine did not.
    This should probably respect the same toggle that controls whether paused Resource files are unloaded, right?
     
  20. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Ok.. so for clip.UnloadAudioData(); will cause the problem.. if clip is !clip.preloadAudioData.

    And which causes the AudioSource's time property with that AudioClip to become 0.

    Which makes some sense , as the clip has been unloaded of its memory. But then again, this could be bug right?

    Can you try the default example scene with the audio clip with preloadAudioData set to false?
     
  21. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    I think the problem is when clip.UnloadAudioData() is called, the AudioSource's time becomes 0. I am not sure if this is the right behavior on Unity. If this is the correct behavior on Unity ( which means it is not Unity bug ) then we need to track the time property for the AudioSource ourselves when we call pause and then use that to check the unpause condition instead? (Since we can't rely on AudioSource's time property anymore)
     
    Last edited: Jul 2, 2016
  22. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Negative. What should happen is that we should not unload the clip when paused. Well, it should check the same setting we have for Resource files to see if it should unload. I'll make it affect both.

    I'm talking about this in Advanced Settings.

    upload_2016-7-2_9-11-6.png

    Anything that's unloaded will not be unpausable, that is correct behavior.
     
  23. Tiny-Tree

    Tiny-Tree

    Joined:
    Dec 26, 2012
    Posts:
    1,314
    is there a way to reduce the sound hashing when doing fade in on a soundgroup?
     
  24. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    sound hashing? I don't know what that is. I somehow doubt it though.
     
  25. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    This has been fixed for the next version. If you would like the fix, email me at support@darktonic.com
     
  26. Tiny-Tree

    Tiny-Tree

    Joined:
    Dec 26, 2012
    Posts:
    1,314
    im using custom fading option on group: fade in time (sec) = 3, fade out time (sec) =1;
    i set a bus max voice to 1 and stop oldest = true; that way when i play new group on my bus it fade out the last one and fade it the new one.

    the problem is there is some noise when the new one fade in it sound like very harsh "clicks" every second until the fade in is finished so i hear 3 or 4 clicks. the original sound file dont have these
     
  27. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I have no idea what would cause that or how to fix it. I haven't encountered that before. Are you saying those artifacts don't happen unless you're fading stuff?

    You would need to send me a sample project that shows this, and I can take a look.
     
  28. Tiny-Tree

    Tiny-Tree

    Joined:
    Dec 26, 2012
    Posts:
    1,314
    yes exactly, it happen when i do fading only with MA
     
  29. Tiny-Tree

    Tiny-Tree

    Joined:
    Dec 26, 2012
    Posts:
    1,314
    I found the problem comming from my script that change bus levels depending on day/night/interior position

    i used setbusvolume and that seems to make some noise while lerping in update.

    so i replaced it using FadeBusToVolume now all the transitions are very smooth again.


    Code (CSharp):
    1. using UnityEngine;
    2. using DarkTonic.MasterAudio;
    3. using System.Collections;
    4. using System.Collections.Generic;
    5.  
    6. public class AmbientSoundManager : MonoBehaviour
    7. {
    8.     #region Field
    9.     private static AmbientSoundManager instance;
    10.     public static AmbientSoundManager Instance {
    11.         get {
    12.             return instance;
    13.         }
    14.     }
    15.        
    16.     [SerializeField] int m_frameToSkip = 10;
    17.     private int currentFrame = 0;
    18.     [SerializeField]  float fadeTime = 1;
    19.     public enum soundState
    20.     {
    21.         outside,inside
    22.     }
    23.  
    24.     public soundState state;
    25.     public enum timeState
    26.     {
    27.         isday,isnight
    28.     }
    29.     public timeState currentTimeState;
    30.  
    31.     private float dayVolume, nightVolume;
    32.     private float lerpTime = 0.5f;
    33.     private float cachedInteriorVolume,cachedOutDayVolume,cachedOutNightVolume;
    34.     private List<string> m_playingInteriorSounds = new List<string>();
    35.     #endregion
    36.     #region Monobehaviour
    37.     void Update()
    38.     {
    39.         if (currentFrame < m_frameToSkip)
    40.         {
    41.             currentFrame++;
    42.             return;
    43.         }
    44.         ComputeEnvironmentLevels ();
    45.     }
    46.  
    47.     void Awake()
    48.     {
    49.         instance = this;
    50.     }
    51.     #endregion
    52.     #region Publics
    53.     public void EnterInside(string soundName)
    54.      {
    55.         m_playingInteriorSounds.Add (soundName);
    56.  
    57.         MasterAudio.PlaySound (soundName);
    58.         if (state == soundState.inside)
    59.             return;
    60.  
    61.  
    62.         state = soundState.inside;
    63.         if (TOD_Sky.Instance)
    64.         {
    65.             MasterAudio.FadeBusToVolume("EnvironmentDay",0,fadeTime);
    66.             MasterAudio.FadeBusToVolume("EnvironmentNight",0,fadeTime);
    67.             MasterAudio.FadeBusToVolume("Interior",1,fadeTime);
    68.         }
    69.     }
    70.  
    71.     public void EnterOutside()
    72.     {
    73.         if (state == soundState.outside)
    74.             return;
    75.        
    76.         for (int i = 0; i < m_playingInteriorSounds.Count; i++)
    77.         {
    78.             MasterAudio.FadeOutAllOfSound (m_playingInteriorSounds[i], fadeTime);
    79.         }
    80.  
    81.         if (state == soundState.outside)
    82.             return;
    83.        
    84.         state = soundState.outside;
    85.         float dayVolume = 1;
    86.         float NightVolume = 0;
    87.         if (TOD_Sky.Instance) {
    88.             if (!TOD_Sky.Instance.IsDay)
    89.             {
    90.  
    91.                 dayVolume = 0;
    92.                 NightVolume = 1;
    93.  
    94.                     //lerp to night
    95.                 MasterAudio.FadeBusToVolume("EnvironmentDay",dayVolume,fadeTime);
    96.                 MasterAudio.FadeBusToVolume("EnvironmentNight",NightVolume,fadeTime);
    97.                 currentTimeState = timeState.isnight;
    98.            
    99.             }
    100.             else
    101.             {
    102.                
    103.                 //lerp to day
    104.                 MasterAudio.FadeBusToVolume("EnvironmentDay",dayVolume,fadeTime);
    105.                 MasterAudio.FadeBusToVolume("EnvironmentNight",NightVolume,fadeTime);
    106.                 currentTimeState = timeState.isday;
    107.  
    108.             }
    109.         }
    110.  
    111.         //smoothly fade off and stop interior sounds
    112.         MasterAudio.FadeBusToVolume ("Interior", 0, fadeTime);
    113.         Invoke ("StopInteriorGroups",fadeTime);
    114.     }
    115.     #endregion
    116.     void StopInteriorGroups()
    117.     {
    118.         MasterAudio.StopBus ("Interior");
    119.     }
    120.  
    121.     protected void Init()
    122.     {
    123.         CreateAudioBusses ();
    124.         PersistentAudioSettings.SetBusVolume ("EnvironmentNight", 0f);
    125.         PersistentAudioSettings.SetBusVolume ("EnvironmentNight",0f);
    126.     }
    127.  
    128.     protected void ComputeEnvironmentLevels()
    129.     {
    130.         if (state == soundState.outside)
    131.         {
    132.             //We are outside
    133.        
    134.             float dayVolume = 1;
    135.             float NightVolume = 0;
    136.             if (TOD_Sky.Instance) {
    137.                 if (!TOD_Sky.Instance.IsDay)
    138.                 {
    139.                    
    140.                     dayVolume = 0;
    141.                     NightVolume = 1;
    142.                     if (currentTimeState == timeState.isday)
    143.                     {
    144.                         //lerp to night
    145.                         MasterAudio.FadeBusToVolume("EnvironmentDay",dayVolume,fadeTime);
    146.                         MasterAudio.FadeBusToVolume("EnvironmentNight",NightVolume,fadeTime);
    147.                         currentTimeState = timeState.isnight;
    148.                     }
    149.                 }
    150.                 else
    151.                 {
    152.                     if (currentTimeState == timeState.isnight)
    153.                     {
    154.                         //lerp to day
    155.                         MasterAudio.FadeBusToVolume("EnvironmentDay",dayVolume,fadeTime);
    156.                         MasterAudio.FadeBusToVolume("EnvironmentNight",NightVolume,fadeTime);
    157.                         currentTimeState = timeState.isday;
    158.                     }
    159.                 }
    160.             }
    161.                
    162.         }
    163.  
    164.     }
    165.  
    166.     void CreateAudioBusses()
    167.     {
    168.         PersistentAudioSettings.MakeBusKey ("EnvironmentDay");
    169.         PersistentAudioSettings.MakeBusKey ("EnvironmentNight");
    170.         PersistentAudioSettings.MakeBusKey ("Interior");
    171.     }
    172. }
    173.  
     
  30. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Not sure why I need to see the code if you say it was your problem, but ok.
     
    Last edited: Jul 11, 2016
  31. Green-Sauce-Games

    Green-Sauce-Games

    Joined:
    Mar 27, 2014
    Posts:
    71
    Is it possible to use an Animation Event to play a Master Audio Sound Group without using any additional code? How?
     
  32. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Show me a screenshot of what you mean. If you mean Mechanim, yes we have MechanimStateSounds script you can after clicking on the state in Mechanim to play a sound when the state is entered and/or exited. Otherwise, if you're talking "legacy animation", then no, you'll need to write code.
     
    Last edited: Jul 14, 2016
  33. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    Hi, I want to mute sounds and playlists(layered music) for specific character. Docs says BUS can do this job but I have no idea about how to assign it for playlists. Where should I start with? Thanks.
     
  34. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Please show me where the docs say that so I can fix it if it's wrong. Playlists don't use buses at all. Did you find the API command to mute a Playlist? Take a look at the API website and let me know if you can't find the method for it.
     
  35. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    I check the docs carefully, it turns out that I misunderstood the bus :p
    Now I use Unity Audio Mixer to control playlists and buses, so all audio in the MA can be control in an unified way. Thank you.
     
  36. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    No problem.
     
  37. Dreamcube017

    Dreamcube017

    Joined:
    Dec 20, 2009
    Posts:
    253
    Hi Jerotas. Firstly, thanks so much for being so responsive and helpful to everyone and keeping your asset updated. This is awesome.

    I have two questions.

    Recently I wsitched from using another audio tool but stopped because the API was a bit lackluster.
    So onto my questions.

    1. The other tool had a thing called Intro-loop-outro which was VERY useful for creating sounds that had a start and stop case. So think of some kind of motor or machine. A sound would play at the start and another sound would loop over until the event was stopped. What would be the easiest way to do this in MasterAudio? I see there is something like that for Playlists, but that is mentioning music and I need this to happen for sound effects. Can this be done in a single event?

    2. I set up a sound group to continuously play a variation of sounds mapped to a cube. What I noticed when moving the camera is that when moving from the left to the right side of the cube, the last audioclip played stays where the camera last was. So if the cube is on the left, but then quickly moves to the right, the sound stays on the left. Is there a way to fix this?

    Thanks. I am using the latest version of MA and Unity 5.3.5.
     
  38. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    #1 you can do but it requires a little coding. I can post a code sample if you'd like to see it. Would all 3 Variations be in a single sound group? I have on the roadmap to add a way to do it without code.

    #2 it sounds like you've told the sound to play *AT* caller location, which is basically fire and forget. You should instead do *Follow* caller location. Are you using EventSounds script for this or wrote some code? Let's see the code or EventSounds Inspector please.
     
  39. Dreamcube017

    Dreamcube017

    Joined:
    Dec 20, 2009
    Posts:
    253
    1) Ah ok. I'm mainly a sound designer, so not too skilled with code. Would there be anyway to wrap it in a simple script? If not, then you can just post how to do it in code and I will get it figured out. I also use PlayMaker for a lot of things. Would it be possible in PlayMaker?

    2) Currently not at home but you do bring up a great point. I was indeed using an Event Sounds on the cube object. I will try the follow caller option.

    Thanks!
    Oh, I actually used MA in a dynamic music demo for something I posted in the asset store a while ago. You can find it in my signature.
     
  40. Shadeless

    Shadeless

    Joined:
    Jul 22, 2013
    Posts:
    136
    @jerotas

    Hey I just wanted to say that I'm also interested in the intro-loop-outro case that Dreamcube017 asked for. And when it comes to the Variations I'd think it's better if they were separate so you can even have variations for the intro, loop and outro sounds.
    And I also wondered about a simpler case where you want to play a looping sound but then interrupt it when you need to. I was just wondering how you recommend to do it.

    On another note, Is it a better idea to have a Dynamic Sound Group than to have the sounds on the Master Audio object? Since I'm using Follow Audio Listener, the Master Audio transform moves every frame and it also moves the sounds after I play them, since they are still parented to it.

    Cheers
     
    Last edited: Jul 29, 2016
  41. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Could Playmaker do it? Sure, but I'd rather not spend time on that and make the non-Playmaker version work with no code.

    Here's a couple ways to do it with small code:

    Assuming you've set up the loop clip to actually loop, here's how you'd code the intro/loop/outro sequence.
    Code (csharp):
    1.  
    2. var introResult = MasterAudio.PlaySound ("Arrow");
    3. if (introResult.ActingVariation != null) {
    4.       introResult.ActingVariation.SoundFinished += delegate {
    5.           var loopResult = MasterAudio.PlaySound("Blast");
    6.           if (loopResult.ActingVariation != null) {
    7.              loopResult.ActingVariation.SoundFinished += delegate {
    8.                 MasterAudio.PlaySound("Scream"); // outro
    9.              };
    10.           }
    11.       };
    12. }
    13.  
    Here's another way. Less readable to me:

    Code (csharp):
    1.  
    2. StartCoroutine (MasterAudio.PlaySoundAndWaitUntilFinished ("Arrow", 1f, 1f, 0f, null,
    3.   delegate {
    4.         StartCoroutine(MasterAudio.PlaySoundAndWaitUntilFinished("Blast", 1f, 1f, 0f, null,
    5.             delegate {
    6.                MasterAudio.PlaySoundAndForget("Scream");
    7.             }));
    8.         }));
    9.  
     
  42. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Stop a looping sound has many options:
    Code (csharp):
    1.  
    2. var result = MasterAudio.PlaySound ("Arrow");
    3. // later
    4. if (result.ActingVariation != null) {
    5.      result.ActingVariation.Stop();
    6. }
    7.  
    8.  
    There's also API like StopAllOfSound, StopSoundGroupOfTransform, etc without needing a reference to the ActingVariation. These are fire-able from EventSounds script without any coding as well.

    Dynamic SGC moves all its audio into the Master Audio game object when it becomes enabled, and at that point it doesn't matter *where* the DSGC is. The default option is "Follow Audio Listener" in Advanced Settings, and that's just so that previewing sounds from the MA game object will always be audible. You can turn that off if you like. When you tell MA to "follow transform" when playing a SFX, it will track and follow the position of whatever caller told it to play. It shouldn't matter where the MA game object is. I'm not really sure what the problem you're having is and the motivation for asking this question?

    The question of whether to use DGSC or not has nothing to do with position and more to do with:
    1) Do you want per-scene audio when using a persistent MA game object?
    2) Do you want "audio skins"?
    3) Do you want other unloadable SFX?
     
  43. Shadeless

    Shadeless

    Joined:
    Jul 22, 2013
    Posts:
    136
    Hey I didn't know that Dynamic SGC reparented the sounds to the Master Audio object. I just saw it in the video and wasn't sure about it. So I thought that by using it I could solve the issue.

    So it seems to me that the right behavior even if Follow Audio Listener is on, would be that the sounds that you play shouldn't be moved when the Master Audio game object moves once you've played them until they are done.

    And I just noticed they moved today, and I was surprised they did.

    Edit: Also I was wondering what was the reason that the PlaySoundResult was a class and not a struct? If there is a legitimate reason for it, are there any considerations to maybe somehow cache them or maybe make PlaySoundXXX versions of the functions which take a PlaySoundResult that we have to provide, so we can reuse them.

    Cheers
     
    Last edited: Jul 29, 2016
  44. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    It's a class and not a struct mainly so I can return a null instance when aborting super early from a bunch of our functions.

    I will see if I can make all the currently playing Variations fix their position when the MA game object moves. Added to roadmap.
     
    Shadeless likes this.
  45. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    Hey,

    In C#, What do i input for Optional Parameters if i don't want to use them?
    MasterAudio.PlaySoundAndForget(cat,1f,1f,0f,"hop");
    I'm not interested in setting the parameters in bold, but compiler gives me invalid overload error unless i specify something.
    Default(float) gave a buggy result, volume was set to 0, and soundgroup was stuck on "Playing 0%"
     
  46. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Default(float) IS zero, by the way. As it is zero with any numeric type. I don't know why it would be stuck on Playing 0%?

    You can use the "named parameters" c# feature to skip optional parameters.
    Code (csharp):
    1.  
    2. var cat = "Arrow";
    3.  
    4. MasterAudio.PlaySoundAndForget(sType: cat, variationName: "hop");
    5.  
     
    luniac likes this.
  47. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Master Audio V 4.0.5 will be live in 20 minutes. Changelog:

    • Fixed bug: Audio Clips with Preload Audio Data = false would unload when pausing. Now it uses the same checkbox in Advanced Settings "Keep Paused Resources" to decide whether to unload or not.
    • Now "File on Internet" Audio Clips show up with a name instead of blank on the Audio Source.
    • Fixed illegal seek position for PlaylistControllers under uncommon scenario.
    • Added "Collapse All Events" button in EventSounds Inspector.
    • Added "Fire!" button in Event Sounds Inspector at runtime for Custom Events, Mechanim State Changed and all other events so you can test the audio configured in the event without making it actually happen.
    • Removed MasterAudio.PlaySound3DAndForget method. It was the same as PlaySoundAndForget and the documentation was wrong.
    • Fixed bug: "Follow Audio Listener" would move already playing Variations that didn't follow their caller when the MA game object moved. Removed option for "Follow Audio Listener" and now play audio for previewing directly on the AudioListener game object.
     
    Shadeless likes this.
  48. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Master Audio is back on sale for 1/3 off for a limited time! That's $30 instead of $45. Happy summer!
     
  49. Dreamcube017

    Dreamcube017

    Joined:
    Dec 20, 2009
    Posts:
    253
    Hello again! I found a lot of ways to do start loop stop with the event sounds.
    Thanks again!

    So now I am trying to use a Play Sound action in PlayMaker, but I want to play it from a different position.

    I have sound occlusion turned on and I have the object specified, but every time I play the game, it defaults back to the object the action is set on and the game object I have told it to play from is set back to none. The object itself is just an object with nothing on it. Do I need an event sounds complainant on it? here is a screenshot of the action.

    Thanks in advance.
     
  50. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    No, you don't need EventSounds. That's an alternative to using Playmaker, not something you would use in conjunction.

    Sorry, but you are talking about the persisting of a field in a Playmaker script, yes that I wrote, but that persistence code is in the core of Playmaker and I can't fix it or even see the code (compiled into a DLL). If you are making changes at runtime, I would expect them to be lost when you hit stop. But if you are losing changes you made at edit time, you will need to inform the Playmaker authors of this bug.

    -Brian