Search Unity

[20% off!] 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,071
    No but that sounds simpler than what I was thinking. Give that a shot! As long as your playlist isn't on shuffle.
     
  2. username132323232

    username132323232

    Joined:
    Dec 9, 2014
    Posts:
    443
    I might try to, but actually your suggestion about looping each clip and switching to another one explicitly sounds like the right way to handle this.

    One more question. (sorry if this is too much for one day.) I have about 300 1-second clips with different words. A character in the scene should say them depending on how the game plays out. So, we don't know in advance how many times (or ever) a given clip will be played. Currently I just have all the clips in the Recourse folder, and play them in a very straight-forward way:

    AudioClip clip = Resources.Load("WordsFolder/" + word) as AudioClip;

    audio.PlayOneShot(clip);


    The clips are stored as .mp3 files, so this whole scheme is probably horrible as far as performance and memory management. Do you recommend managing those clips via Master Audio, and if so, could you point me to relevant information if something similar has been done before?
     
  3. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,071
    Easy to manage with our plugin.

    I would convert them all to .wav files (for performance), and keep them as Resource files as you have done (good thinking). You can set up files to be automatically loaded and unloaded as Resource Files (change the Audio Origin of a Variation to Resource File). There's also a "Bulk Import Mode" (I forget the exact name) dropdown on Sound Groups and the mixer so you can drag a bunch in at once (from Resources folder) without having to do them one by one. I'd put them in a single Sound Group (per character) with mode "Dialog" so only one can be played at a time and if another plays, it will auto-stop the previous one.
     
  4. hexdump

    hexdump

    Joined:
    Dec 29, 2008
    Posts:
    439
    Thanks for the answer, but this seems a dirty workaround for such an easy task, don't you think? Isn't there a way to be able to retrigger a sound whenever I like without taking into account how large it is, etc...? I don't mind spending some time configuring Master Audio instead of using default configuration but I need this functionality that is the default when no using Master Audio.

    Cheers.
     
  5. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,071
    I think you misunderstand what I meant by default configuration. This is not a workaround, it's the correct way to do it with Master Audio.

    Each time you create a Sound Group, each Variation is by default set to have a weight of 1, and can therefore be played a maximum of 1 time simultaneously. That is what the weight controls. So for each Variation you'd like to play more than 1 at a time, you'll need to go increase the Weight field for it. You only need to decide what's the maximum voice of it you'd ever want and set that. It doesn't really matter how long the clip is. In play mode, you can see visibly on the Master Audio mixer, the left of each channel (Sound Group) has a bracketed yellow number showing the number of voices playing. When it reaches the maximum (sum of Weights), it turns red to let you know. If you want, you can just err high and just put in 10 even though you might only need 6. It changes the audio memory footprint minimally.

    In this way, we not only control the how often each Variation plays compared to the others (when you have more than one clip in a Group and say "play one at random"), but also have strict control over how many voices of each sound can be played at once. You can read in the readme about why we never use AudioSource.PlayOneShot if you're curious, which is basically because you lose all control over audio triggered that way once it starts playing.

    The Retrigger Percentage I mentioned also defaults to 50%, meaning that no "busy" Variation can be played again until 50% of its clip has been played. You can decrease that to whatever percent you like, if that is useful to you. Or you could increase it to 100% meaning "never interrupt this sound".

    By the way, Limit Polyphony is only active when then sum of that Group's Variation's Weights is greater than 1. It can only limit less than the sum. If the sum is one, there's nothing to limit. So Weight is the primary way to limit polyphony, and Limit Polyphony is secondary after that. I know that sounds weird. The Weight field does say "Weight (voices)". I couldn't think of a more self-explanatory label than that. And a couple of our short videos explain it as well. But we still get this question every few weeks from different people.

    Also, if you turn on the checkbox "Log All Sounds" in Master Audio Advanced section, it will log to the Console telling you things like "No voices available for Sound Group 'blah'. Increase your Weight for one or more Variations". There's also a similar checkbox for each Sound Group if you don't want to get spammed in the Console.

    I'm not sure why you think increasing a single field for a sound is "dirty". I don't think it is. Let me know if you have any other questions.

    -Brian
     
    Last edited: Feb 3, 2015
  6. hexdump

    hexdump

    Joined:
    Dec 29, 2008
    Posts:
    439
    Amazing insight. Thanks a lot again by clirifying this :).
     
  7. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,071
    No problem. I'm here whenever you run into something else confusing :)
     
  8. username132323232

    username132323232

    Joined:
    Dec 9, 2014
    Posts:
    443
    This worked out beautifully! An added benefit is that ducking was very easy to set up since all 300 sound clips are treated as variations of just one clip. Thank you for the fantastic plugin and for your super-fast responces!
     
  9. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,071
    Perfect! Let us know if you have any other questions or suggestions. Also, please take a couple minutes to leave us a text review on the Asset Store when you are ready.

    -Brian
     
  10. Teku-Studios

    Teku-Studios

    Joined:
    Sep 29, 2012
    Posts:
    257
    Hey @jerotas, what are the release notes for the latest MasterAudio patch? The Asset Store does not include new info for today's update.
     
    Last edited: Feb 4, 2015
  11. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,071
    That's because there was no code change. I only changed out the example scene music from my song to a better sample one from a fellow Asset Store music pack creator.
     
    Teku-Studios likes this.
  12. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,071
    Apparently Resources.LoadAssetAtPath no longer works in Unity 5 beta 22 when exporting as standalone. It needs to be changed to Resources.Load (4 places in MasterAudio.cs). This works on all versions of Unity and will be in the next update.

    When beta 22 is officially released, I'll push this version out. Until then, you may want to make this fix yourself if you have early access to Unity 5 betas and are using beta 22.
     
    Last edited: Feb 5, 2015
    makeshiftwings likes this.
  13. Ross_S

    Ross_S

    Joined:
    Jul 10, 2012
    Posts:
    29
    Hi guys...
    in MasterAudio can you seek to a position in the sound file? i can't find it in the docs? ... so for example i want to start playing a streaming sound from 5.5 seconds into it. and then pause and then start playing again from 30 seconds into
     
  14. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,071
    Yes, you can do that. The API website shows all commands. I assume you only looked at the readme? There's a link to the API on page 2. I would post it here but I don't know if you're wanting to do it for music of SFX. Both are different.
     
  15. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,071
  16. Ross_S

    Ross_S

    Joined:
    Jul 10, 2012
    Posts:
    29
    Thank for answering so quick. Ok thanks yes i was only looking at the readme. So, going through the API I found the JumpToTime method.
    i'm trying to use it like this:
    PlaySoundResultpsResult = MasterAudio.PlaySound("easter_dummy");
    psResult.ActingVariation.JumpToTime(5.0f);

    ...but it doesn't work. When it gets to the JumpToTime function - VarAudio.isPlaying is false...?
    (VarAudio is the right AudioSource though it seems.)
    the audio is a long piece of dialogue setup to stream from disc. Umm, yep can't work out why this is false? JumpToTime is too soon after PlaySound ?
    thanks
     
  17. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,071
    I think it's a bug. I'll fix this tonight and report back.
     
  18. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,071
    By the way, if you're always jumping to the same time for the same sound, you can do it without code. Use the Random Start Time section in the Variation. If you set random start time min and max to the same value, it will do what you want. I will fix the bug anyway, but this may unblock you?
     
  19. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,071
    Go ahead and change the code in SoundGroupVariation.cs to this:

    Code (csharp):
    1.  
    2. public void JumpToTime(float timeToJumpTo) {
    3.    if (!_playSndParam.IsPlaying) {
    4.       return;
    5.    }
    6.  
    7.    VarAudio.time = timeToJumpTo;
    8. }
    9.  
    Now it should work. The check if VarAudio was playing is unnecessary. This fix will be in the next update.
     
    Ross_S likes this.
  20. hexdump

    hexdump

    Joined:
    Dec 29, 2008
    Posts:
    439
    Hi,

    Is there any way to select in a custom component the list of sounds that ara available to play in the Master audio instance in the scene? I mean, I want to configure the die sound of an entity in my game, instead of having to write a string with the sound name to use PlaySoundAndForget(sound_name) later, is there any way to show a dropdown list with the available sounds in AudioMaster?.

    Cheeers.
     
  21. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,071
    Sure, you add the SoundGroupAttribute to the public field in your C# class. Like this:

    Code (csharp):
    1.  
    2. [SoundGroupAttribute]
    3. public string deathSoundGroup;
    4.  
    Then you can just do: MasterAudio.PlaySound3DAndForget(deathSoundGroup);
     
  22. hexdump

    hexdump

    Joined:
    Dec 29, 2008
    Posts:
    439
    I have to try this. Thanks!
     
  23. Ross_S

    Ross_S

    Joined:
    Jul 10, 2012
    Posts:
    29
    thanks that works fine now.
     
  24. vicenterusso

    vicenterusso

    Joined:
    Jan 8, 2013
    Posts:
    130
    I have an audio clip that I want to play in a loop until X seconds, then stop it (with a fast fade out effect). Is there any automated way to do that, without using coroutines, or stuff?

    Edit: code snippet I'm using:
    Code (csharp):
    1. IEnumerator PlaySoundOverSecondsRoutine(string clipName, float seconds)
    2. {
    3.     MasterAudio.SetGroupVolume(clipName,1);
    4.     MasterAudio.PlaySound(clipName);
    5.     yield return new WaitForSeconds(seconds);
    6.     MasterAudio.FadeSoundGroupToVolume(clipName,0,0.1f);
    7. }
     
    Last edited: Feb 9, 2015
  25. Teku-Studios

    Teku-Studios

    Joined:
    Sep 29, 2012
    Posts:
    257
    float timer = 0.0f;
    float timeToWait = 5.0f;

    bool play;

    void Update()
    {
    if(timer <= timeToWait)
    {
    timer += Time.deltaTime;
    play = true;
    }
    else
    {
    play = false;
    }

    if(play)
    {
    if(!audio.isPlaying("myClip")
    {
    audio.Play("myClip");
    }
    }
    else
    {
    audio.Stop();
    }
    }



    A very quick, untested code I just made. Not quite right (better with coroutines), but effective nonetheless. And you avoid using threads, if that's what you want.

    Would that be of any help to you?
     
    Last edited: Feb 9, 2015
  26. Ross_S

    Ross_S

    Joined:
    Jul 10, 2012
    Posts:
    29
    Hi,
    is there any way to check if a Sound Group is paused? thanks
     
  27. djfrail

    djfrail

    Joined:
    Jan 16, 2014
    Posts:
    116
    I'm playing a playlist of songs with shuffle mode on. Is there a way to add a second or two of silence between songs?

    Thanks. Sorry if this was answered somewhere else.
     
  28. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,071
    No problem.
     
  29. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,071
    Looks fine to me. No, there's no way to do out of the box. And code wouldn't allow it to be precise anyway. It could stop "at the right time no closer than one frame's time".
     
  30. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,071
    There's an included script: DelayBetweenSongs, check it out! Or you can of course play any song at zero volume if it's the right length, but I doubt you want to do that.
     
  31. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,071
    Unfortunately no. Currently the Variations each are paused individually. I believe playing a new Variation in the Group after it has been paused works fine.

    If you think it shouldn't work that way, we can change it.
     
  32. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    437
    Hello, I just purchased this asset, and its very easy and comfortable to use and understand!

    While it does have a good set of Playmaker actions, I think it is missing a Playmaker Global Transitions.
    Such as..
    "Playlist Begins"
    "Playlist song changed"
    "Playlist Crossfade begins"

    Any chance this may be added?
     
  33. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,071
    Sorry, what are "Playmaker Global Transitions"? I'm not familiar with the term.
     
  34. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    437
    It is the event that can be hooked up to states to activate them.

    Test.png
    Like the box marked in red.

    I want playmaker to do something when Master Audio playlist's song has changed.
    If there is a custom Master Audio event to do just that, it would be amazing!

    "Playlist Begins"
    "Playlist song changed"
    "Playlist Crossfade begins"
     
  35. djfrail

    djfrail

    Joined:
    Jan 16, 2014
    Posts:
    116
    Great - thanks! Is there an example of how to use this DelayBetweenSongs script somewhere? Do I drag that script onto something in the editor?
     
  36. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,071
    Sorry I'm still not clear. We created a bunch of Custom Actions for Playmaker. You have put red boxes around "states" in your FSM. "Events" are what progresses an FSM from one state to the other. So I am not sure what you are asking for. The ability to trigger an event? That only works if your FSM is on a state that has that event on it by the way.
     
  37. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,071
    Just put the script onto any game object in your Scene. Enter the name of the Playlist Controller you want to delay songs and adjust the Min / Max time to wait. Then it should work.

    I believe you also need to turn off auto advance for the Playlist Controller so it doesn't automatically start the next song.
     
  38. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    437
    Yes, event triggers.
     
  39. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,071
  40. djfrail

    djfrail

    Joined:
    Jan 16, 2014
    Posts:
    116
    Works. U rock.
     
  41. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,071
    Awesome!
     
  42. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,524
    I know we can filter the group list, but my list is getting rather long now. Is it possible to have two master audio instances in the scene and have the different group list on them? I really want to be able to organize the list better than current filter option and sorting by bus option.
     
  43. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,071
    No unfortunately, and that will never happen. That would be too difficult to code even for me. However you can organize groups of audio items into Dynamic SGC's in the Scene if you like. That will not be editable at runtime but it may help.
     
    Last edited: Feb 10, 2015
  44. vicenterusso

    vicenterusso

    Joined:
    Jan 8, 2013
    Posts:
    130
    I`m having an issue with the option "Auto Advance Clips" when it`s checked. When I start the scene, the play list plays for half a second and it stops. If I leave the option unchecked, it plays normally.

    This is my MasterAudio config:


    This is my Playlist Controller
     
  45. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,071
    Not enough detail here for me to guess what's wrong. How long is your first song? What's the Master crossfade time set to?
     
  46. vicenterusso

    vicenterusso

    Joined:
    Jan 8, 2013
    Posts:
    130
    All songs are like 2, 3 min..

    More config:


    And here is a video just after I hit play. I hear the sound when its crossfading, and when it says "playing" there is no sound. https://vid.me/E6es
     
  47. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,071
    Sorry, never seen or heard of that kind of bug. If you can send me a small project that reproduces the bug, I can take a look. Maybe create a Scene with nothing except Master Audio setup and get that to me.

    What happens the majority of the time is that reconstructing the Scene in another project doesn't reproduce the same issue, and then you may figure out what's causing the problem. If not, then I can.

    -Brian
     
  48. vicenterusso

    vicenterusso

    Joined:
    Jan 8, 2013
    Posts:
    130
    I think I found a way to reproduce this bug. On an empty scene:

    1) I added Master Audio and Playlist Controller.
    2) Added a "Test" Playlist with 3 songs with FadeIn and FadeOut checked.
    3) On Master Audio I set Initial Playlist as "Test"
    4) On Advanced section of MasterAudio, I check Persist and Gapless Music Switching.
    5) On PlaylistController, I check Start on Awake, Loop Playlists and Auto Advance Clips.

    Hit play, bug happens.
     
  49. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,071
    I can try that when I'm at my computer this evening. If you haven't turned off crossfading (set to zero seconds), try that to see if it fixes the issue. Gapless really means "I don't want cross fading", but I probably never tried using gapless with a crossfade time, so that may be the issue.
     
  50. vicenterusso

    vicenterusso

    Joined:
    Jan 8, 2013
    Posts:
    130
    In that scenario, if I set Master Crossfade Time to zero the bug persist, but i hear only a *tick* of the song.

    Unchecking Gapless works. So I`l leave that unchecked because in fact, is not what I want. Anyway, I think Gapless is broken, I can`t play anything with that checked.
     
unityunity