Astra Child

SoundyService

Estimated reading: 3 minutes 0 views

The SoundyService class is a singleton audio manager system designed to handle sound and music playback in Unity projects. It provides a centralized and organized approach to managing audio assets, making it easy for developers to play, stop, pause, mute, and manage audio players efficiently.

The class utilizes audio player pools for both sounds and music, which allows for the reuse of audio players, reducing memory overhead and improving performance. Each audio player is responsible for playing a specific sound or music, and the pool manages the creation, reuse, and removal of these players as needed.

The SoundyService class makes use of Unity’s Audio Mixer Groups to enable different control over sound and music playback. This allows developers to specify custom audio mixer groups for individual sounds and music or use default ones defined in sound and music libraries.

Important APIs inside the SoundyService class:

  1. Sound:
    • PlaySound: Plays a sound from a given library and with a given name. It returns the audio player responsible for playing the sound.
    • StopSound: Stops all instances of a specific sound object that are currently playing.
    • StopSoundLibrary: Stops all sounds from a given sound library.
    • StopAllSounds: Stops all sounds currently playing, including looping sounds.
    • PauseSound: Pauses all instances of a specific sound object that are currently playing.
    • PauseSoundLibrary: Pauses all sounds from a given sound library.
    • PauseAllSounds: Pauses all sounds currently playing, including looping sounds.
    • MuteSound: Mutes all instances of a specific sound object that are currently playing.
    • MuteSoundLibrary: Mutes all sounds from a given sound library.
    • MuteAllSounds: Mutes all sounds currently playing, including looping sounds.
    • UnMuteSound: Unmutes all instances of a specific sound object that are currently playing.
    • UnMuteSoundLibrary: Unmutes all sounds from a given sound library.
    • UnMuteAllSounds: Unmutes all sounds currently playing, including looping sounds.
  2. Music:
    • PlayMusic: Plays a music track from a given library and with a given name. It returns the audio player responsible for playing the music.
    • StopMusic: Stops all instances of a specific music track that are currently playing.
    • StopMusicLibrary: Stops all music tracks from a given music library.
    • StopAllMusic: Stops all music currently playing, including looping music.
    • PauseMusic: Pauses all instances of a specific music track that are currently playing.
    • PauseMusicLibrary: Pauses all music tracks from a given music library.
    • PauseAllMusic: Pauses all music currently playing, including looping music.
    • MuteMusic: Mutes all instances of a specific music track that are currently playing.
    • MuteMusicLibrary: Mutes all music tracks from a given music library.
    • MuteAllMusic: Mutes all music currently playing, including looping music.
    • UnMuteMusic: Unmutes all instances of a specific music track that are currently playing.
    • UnMuteMusicLibrary: Unmutes all music tracks from a given music library.
    • UnMuteAllMusic: Unmutes all music currently playing, including looping music.
  3. All Audio Methods:
    • StopAll: Stops all sounds and music currently playing, including looping sounds and music.
    • MuteAll: Mutes all sounds and music currently playing, including looping sounds and music.
    • UnMuteAll: Unmutes all sounds and music currently playing, including looping sounds and music.
    • PauseAll: Pauses all sounds and music currently playing, including looping sounds and music.
    • UnPauseAll: Unpauses all sounds and music currently playing, including looping sounds and music.

Developers can utilize these APIs to easily manage audio in their Unity projects, ensuring a seamless and immersive audio experience for users.

For more detailed information on the SoundyService class and its APIs, you can visit the official documentation at https://api.doozyui.com.

Share this Doc
CONTENTS
Scroll to Top