Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug previous clip on audiosource while playing new clip on different source

Discussion in 'Audio & Video' started by rgarand64, Nov 29, 2023.

  1. rgarand64

    rgarand64

    Joined:
    Feb 17, 2022
    Posts:
    14
    _RESOLVED SEE DOWN HERE_
    Hi All,
    Have set up audio manager with 4 different audiosources (master, voice, sfx, music), I have music while playing and, at end of level voice source play "level completed" clip. But when I start Level menu smooth music, I hear the end of the voice audiosource, tried to send a stop, throw an empty clip, put a debug watch on audiosource, etc...First, I don t get it that voice ends in the music audiosource (thought they were two different objects), and two, how to reset the music audiosource or empty its buffer. Audio manager is static class.
    (I know I could put a wait X sec for clip to end, but I'm sure there is a better way)
    TIA, Robert, almost there :)
    audio manager setup pic in attachment
    2021.3, VS2019, no audio additional package, oculus, XR, URP
    Code (CSharp):
    1.  
    2.         //voice audio source just played "level completed"clip
    3.         AudioManager_C.Audio_Instance.Start_Stop_Voice(false);
    4.         //false = stop, true = play
    5.         // its where I hear end of previous clip from other source
    6.         AudioManager_C.Audio_Instance.PlayMusic(audiomanager.music_menu);
    audio setup.jpg
     
    Last edited: Dec 6, 2023
  2. SeventhString

    SeventhString

    Unity Technologies

    Joined:
    Jan 12, 2023
    Posts:
    373
    Could you share the implementation of your AudioManager? It seems like the issue would occur in there.
     
  3. rgarand64

    rgarand64

    Joined:
    Feb 17, 2022
    Posts:
    14
    Hi Seventh string,
    Resolved yesterday, When I loaded volume settings at beginning of level, I trigger the slider onchangevalue, who would make the loop to set volume. I patched the script, now the snake don't bite its tail :)
    Should I remove the thread ? since it wasn't a real bug ...
     
  4. SeventhString

    SeventhString

    Unity Technologies

    Joined:
    Jan 12, 2023
    Posts:
    373
    I would leave it there, since it might help a future someone :)
    You could certainly flag it as "Resolved" though!
     
    rgarand64 likes this.