### Advanced Playlist Configuration with Callbacks (C#) Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/playlist Presents a comprehensive example of configuring a Playlist with various advanced settings. This includes setting volume, enabling looping, making the music follow a target transform, shuffling tracks, routing to a specific output channel, applying fade-in/out effects, and registering a callback to execute when a new track starts. ```C# Playlist ambientRadio = new Playlist(Track.ForestTheme, Track.RainTheme, Track.CityTheme) .SetVolume(0.6f) .SetLoop(true) .SetFollowTarget(carTransform) // Music follows the car .Shuffle() // Randomize track order .SetOutput(Output.Music) // Route to the Music channel .SetFadeIn(2f) // 2-second fade-in at the start of each track .SetFadeOut(2f) // 2-second fade-out at the end of each track .OnNextTrackStart(() => Debug.Log("Track changed!")) .Play(); ``` -------------------------------- ### Create and Play a Music Object (C#) Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/music Demonstrates how to instantiate and play a `Music` object using a string tag or a `Track` enum. Includes an example of chaining configuration methods like `SetVolume`, `SetLoop`, and `SetSpatialSound` before playback. ```C# new Music("MainTheme").Play(); ``` ```C# new Music(Track.MainTheme).Play(); ``` ```C# Music mainTheme = new Music("MainTheme").SetVolume(0.6f) .SetLoop(true).SetSpatialSound(false); mainTheme.Play(); ``` -------------------------------- ### Basic Sound Playback in C# Source: https://melenitass-organization.gitbook.io/sounds-good-docs/firsts-steps/quickstart This C# example demonstrates how to initialize a `Sound` object using the `MelenitasDev.SoundsGood` library and play it. It shows the use of an auto-generated `SFX` enum for sound identification. ```C# using MelenitasDev.SoundsGood; public class Player : MonoBehaviour { private Sound jump = new Sound(SFX.jump); public void Jump() { jump.Play(); } } ``` -------------------------------- ### Register Sound Playback Callback (Action) Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/sound/methods Callback fired when playback starts. ```APIDOC `Sound` OnPlay(`Action` onPlay) ``` -------------------------------- ### Customize Sound Properties with Chained Methods in C# Source: https://melenitass-organization.gitbook.io/sounds-good-docs/firsts-steps This C# example illustrates how to customize sound playback using chained `Set...` methods provided by `MelenitasDev.SoundsGood`. It shows how to adjust properties like volume, fade, looping, spatial sound, and add completion callbacks. The snippet also differentiates between persistent settings (in `Start()`) and per-play settings (in `Jump()`). ```C# using MelenitasDev.SoundsGood; public class Player : MonoBehaviour { private Sound jump = new Sound(SFX.jump); void Start() { jump.SetVolume(0.75f) .SetFadeOut(0.5f) .SetLoop(false) .SetRandomClip(true) .SetSpatialSound(true) .SetHearDistance(1, 50) .SetVolumeRolloffCurve(VolumeRolloffCurve.Linear) .OnComplete(() => Debug.Log("Sound ends")) .Play(); } public void Jump() { jump.SetRandomPitch() .SetPosition(transform.position) .Play(); } } ``` -------------------------------- ### Implement an adaptive soundtrack with DynamicMusic Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/dynamicmusic An advanced example showing how to create an adaptive soundtrack. It initializes a `DynamicMusic` instance with multiple tracks, sets base volumes, mutes specific tracks initially, and demonstrates how to dynamically change track volumes during runtime (e.g., during combat). ```C# DynamicMusic adaptiveSoundtrack = new DynamicMusic( Track.MainTheme, Track.Percussion, Track.Violins ) .SetAllVolumes(0.7f) // Base volume for all stems .SetTrackVolume(Track.Percussion, 0) // Start with percussion muted .SetLoop(true) .SetOutput(Output.Music) .OnPlay(() => Debug.Log("Soundtrack started!")) .Play(); // Later, during combat: adaptiveSoundtrack.ChangeTrackVolume(Track.Percussion, 0.7f); // Bring in percussion ``` -------------------------------- ### Advanced Sound configuration with chaining Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/sound Presents an advanced example of configuring a `Sound` object using method chaining. It covers setting volume, random pitch, 3D hear distance, output, and registering a callback function to execute upon sound completion. ```C# Sound laser = new Sound(SFX.Laser) .SetVolume(0.5f) .SetRandomPitch() .SetHearDistance(5, 30) .SetOutput(Output.SFX) .OnComplete(() => Debug.Log("Laser reloaded")) .Play(); ``` -------------------------------- ### Music OnPlay Event Listener Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/music/methods Registers a callback function to be invoked immediately when music playback starts. ```APIDOC Music OnPlay(Action onPlay) onPlay: Callback function invoked at playback start. ``` -------------------------------- ### Configure Playlist Looping and Fade-Out (C#) Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/playlist Illustrates how to create a Playlist and configure it with common options before playing. This example sets the playlist to loop indefinitely and applies a 1-second fade-out effect at the end of each track, providing smooth transitions. ```C# Playlist radio = new Playlist(Track.RockSong, Track.JazzSong) .SetLoop(true) // Repeat the sequence when it ends .SetFadeOut(1f); // 1-second fade-out at the end of each track radio.Play(); ``` -------------------------------- ### Playlist OnPlay Callback Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/playlist/methods Registers a callback action to be invoked when the playlist starts playback. ```APIDOC Playlist OnPlay(Action onPlay) ``` -------------------------------- ### Advanced Sound Customization in C# Source: https://melenitass-organization.gitbook.io/sounds-good-docs/firsts-steps/quickstart This C# snippet illustrates how to apply various playback settings to a `Sound` object using chained methods from `MelenitasDev.SoundsGood`. It covers settings like volume, fade, looping, random clips, spatial sound, hear distance, volume rolloff, and `OnComplete` callbacks. It also differentiates between settings applied once (in `Start`) and those applied per-play (in `Jump`). ```C# using MelenitasDev.SoundsGood; public class Player : MonoBehaviour { private Sound jump = new Sound(SFX.jump); void Start() { jump.SetVolume(0.75f) .SetFadeOut(0.5f) .SetLoop(false) .SetRandomClip(true) .SetSpatialSound(true) .SetHearDistance(1, 50) .SetVolumeRolloffCurve(VolumeRolloffCurve.Linear) .OnComplete(() => Debug.Log("Sound ends")) .Play(); } public void Jump() { jump.SetRandomPitch() .SetPosition(transform.position) .Play(); } } ``` -------------------------------- ### Subscribe to Music Lifecycle Events with On Prefix (C#) Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/prefixes This C# example illustrates how to use `On` prefixed methods to subscribe to various lifecycle events of a `Music` object, such as `OnPlay`, `OnPause`, `OnResume`, and `OnComplete`. These methods provide a clean way to handle events without relying on coroutines or repetitive `Invoke` calls, and they also support method chaining. ```C# var loopingMusic = new Music(Track.ForestAmbience) .SetLoop(true) .OnPlay(() => Debug.Log("Ambient started")) .OnPause(() => Debug.Log("Ambient paused")) .OnResume(() => Debug.Log("Ambient resumed")) .OnComplete(() => Debug.Log("Ambient stopped")); loopingMusic.Play(); // fires OnPlay // Later… loopingMusic.Pause(); // fires OnPause loopingMusic.Resume(); // fires OnResume loopingMusic.Stop(); // fires OnComplete ``` -------------------------------- ### Replace Sounds Good 1.0 Enumerator References with Strings Source: https://melenitass-organization.gitbook.io/sounds-good-docs/update-from-1.0-to-2 This snippet illustrates a temporary solution to compilation errors during the Sounds Good 2.0 migration. It shows how to replace old Sounds Good 1.0 enumerator references (e.g., `SFX.jump`, `Track.main`) with their corresponding string literals, enabling project compilation and access to new migration tools. ```Text SFX.jump → "jump" Track.main → "main" ``` -------------------------------- ### Generic Slider Utility Prefab Documentation Source: https://melenitass-organization.gitbook.io/sounds-good-docs/included-prefabs This prefab is a general-purpose utility slider not specifically tied to Sounds Good, but included for its versatility. It displays the current value as a percentage and exposes a 'UnityEvent onValueChange' for hooking custom logic. By default, it starts at 50% and automatically updates its label. ```APIDOC Generic Slider: Purpose: General-purpose utility slider. Display: Shows the value as %. Event: Exposes a UnityEvent onValueChange for custom logic. Default: Starts at 50 % by default. Label: Updates the label automatically. ``` -------------------------------- ### Playlist SetFadeIn Method Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/playlist/methods Defines the duration for audio to fade in, applied at the start of each track or when the playlist begins playback. ```APIDOC Playlist SetFadeIn(float fadeInTime) ``` -------------------------------- ### Playlist.PlayingTime Property Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/playlist/properties Reports the total accumulated time, in seconds, that the playlist has been actively playing. This value represents the aggregate playback duration since the playlist started. ```APIDOC Property: PlayingTime Type: float Description: Total time (in seconds) the playlist has been playing. ``` -------------------------------- ### Sound.PlayingTime Property Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/sound/properties Total time in seconds that the sound has been playing since it last started. This cumulative value tracks the active playback duration of the sound. ```APIDOC PlayingTime: float Total time in seconds that the sound has been playing since it last started. ``` -------------------------------- ### Output Volume Slider Prefab Documentation Source: https://melenitass-organization.gitbook.io/sounds-good-docs/included-prefabs The Output Volume Slider prefab provides a quick way to control the volume of a single audio channel (Output) and automatically saves its value. It loads the last stored value from PlayerPrefs on start and updates the slider and percentage label accordingly. Every slider movement immediately calls SoundsGoodManager.ChangeOutputVolume() to apply the change. ```APIDOC Output Volume Slider: targetAudioOutput: Choose which 'Output' it manipulates. Behavior: On Start: Loads the last value stored in PlayerPrefs and updates both the Slider and the percentage label. On slider movement: Calls SoundsGoodManager.ChangeOutputVolume() internally for immediate change. ``` -------------------------------- ### Create a Sound object instance in C# Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects Demonstrates how to instantiate a new Sound object, linking it to a registered SFX and setting its initial volume. ```C# var coinSound = new Sound(SFX.Coin).SetVolume(0.7f); ``` -------------------------------- ### Create and play Sound by string tag Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/sound Demonstrates how to instantiate a `Sound` object using its string tag and immediately play it. This method is straightforward for quick playback. ```C# new Sound("Jump").Play(); ``` -------------------------------- ### Store and configure Sound in a variable Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/sound Illustrates how to create a `Sound` instance, store it in a variable, and apply initial configurations like volume and looping before playing. Storing the sound allows for more control over its lifecycle. ```C# Sound jumpSound = new Sound("Jump") .SetVolume(0.8f) .SetLoop(true); jumpSound.Play(); ``` -------------------------------- ### Configure DynamicMusic properties Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/dynamicmusic Illustrates how to set properties like looping and initial volume for all layers of a `DynamicMusic` instance immediately after creation. ```C# DynamicMusic intenseTheme = new DynamicMusic(Track.Base, Track.Choirs) .SetLoop(true) // Loop all stems indefinitely .SetAllVolumes(0.5f); // Set every layer to 50% volume intenseTheme.Play(); ``` -------------------------------- ### Create and Play Basic Playlist (C#) Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/playlist Demonstrates how to create and immediately play a new Playlist instance. It shows two common ways to initialize the playlist: using string tags for tracks or directly referencing 'Track' enum identifiers. Be aware that renaming track tags in the Audio Collection window will break string-based code references. ```C# new Playlist("RockSong", "JazzSong", "ElectronicSong").Play(); ``` ```C# new Playlist(Track.RockSong, Track.JazzSong, Track.ElectronicSong).Play(); ``` -------------------------------- ### Advanced Music Object Configuration (C#) Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/music Illustrates an advanced configuration of a `Music` object, showcasing method chaining for setting volume, looping, fade-out, output channel, and attaching a callback for the `OnPause` event. ```C# Music dungeonTheme = new Music(Track.Dungeon) .SetVolume(0.4f) .SetLoop(true) // Loops the track when it ends .SetFadeOut(2.5f) // 2.5-second fade-out at the end .SetOutput(Output.Music) // Assigns it to a specific output channel .OnPause(() => Debug.Log("Dungeon theme paused")) .Play(); ``` -------------------------------- ### Initialize and Play a Sound in C# Source: https://melenitass-organization.gitbook.io/sounds-good-docs/firsts-steps This C# code snippet demonstrates how to initialize a `Sound` object using the `MelenitasDev.SoundsGood` library and play it. Sounds can be referenced by a string tag or an auto-generated `SFX` enum, simplifying audio playback in game development. ```C# using MelenitasDev.SoundsGood; public class Player : MonoBehaviour { private Sound jump = new Sound(SFX.jump); public void Jump() { jump.Play(); } } ``` -------------------------------- ### Create DynamicMusic instance with tags or enums Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/dynamicmusic Demonstrates how to instantiate a `DynamicMusic` object by grouping pre-created tracks using either string tags or `Track` enum identifiers. Shows basic playback. ```C# new DynamicMusic("BaseTrack", "Drums", "Strings").Play(); ``` ```C# new DynamicMusic(Track.BaseTrack, Track.Drums, Track.Strings).Play(); ``` -------------------------------- ### Configure Sound Properties with Set Prefix (C#) Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/prefixes This C# code demonstrates the use of `Set` prefixed methods on a `Sound` object. These methods allow for fluent chaining to configure properties like volume, random pitch, spatial sound, and fade-out before the sound is played. The `Set` methods return the instance, enabling method chaining. ```C# new Sound(SFX.Explosion) .SetVolume(0.55f) .SetRandomPitch() // variation to avoid repetition .SetSpatialSound(true) // 3D .SetFadeOut(0.8f) // fade when it ends .Play(); ``` -------------------------------- ### DynamicMusic Class API Reference Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/dynamicmusic/methods Comprehensive API documentation for the DynamicMusic class, detailing its constructors, volume controls, spatial audio settings, playback management, and event callbacks. ```APIDOC DynamicMusic Class: Description: Manages dynamic music playback with multiple tracks, volume control, spatial audio, and event handling. Constructors: DynamicMusic(): Returns: DynamicMusic Description: Creates an empty DynamicMusic instance. Tracks must be added before playback. DynamicMusic(tracks: Track[]): Returns: DynamicMusic Description: Constructs a DynamicMusic instance with the given Track array; all stems play simultaneously. DynamicMusic(tags: string[]): Returns: DynamicMusic Description: Constructs a DynamicMusic instance using the specified tags array, one tag per stem. Methods: SetAllVolumes(volume: float): Returns: DynamicMusic Description: Assigns the same initial volume (0-1) to all stems before playback. SetTrackVolume(track: Track, volume: float): Returns: DynamicMusic Description: Sets the initial volume for the specified track. SetTrackVolume(tag: string, volume: float): Returns: DynamicMusic Description: Sets the initial volume for the stem identified by its tag. SetHearDistance(minHearDistance: float, maxHearDistance: float): Returns: DynamicMusic Description: Defines the minimum and maximum hearing distances, specifying full audibility and fade-out points. SetVolumeRolloffCurve(curve: VolumeRolloffCurve): Returns: DynamicMusic Description: Chooses between Logarithmic or Linear distance-based volume attenuation. SetCustomVolumeRolloffCurve(curve: AnimationCurve): Returns: DynamicMusic Description: Applies a custom AnimationCurve for precise volume attenuation control. ChangeAllVolumes(newVolume: float, lerpTime: float): Returns: void Description: Changes the volume of all stems in real time; transitions smoothly if lerpTime > 0. ChangeTrackVolume(track: Track, newVolume: float, lerpTime: float): Returns: void Description: Changes the volume of a specific track at runtime. ChangeTrackVolume(tag: string, newVolume: float, lerpTime: float): Returns: void Description: Changes the volume of the track identified by tag at runtime. SetPitch(pitch: float): Returns: DynamicMusic Description: Adjusts the global pitch for all tracks. SetDopplerLevel(dopplerLevel: float): Returns: DynamicMusic Description: Sets the Doppler effect intensity (0-5). SetId(id: string): Returns: DynamicMusic Description: Assigns a unique identifier to this instance. SetLoop(loop: bool): Returns: DynamicMusic Description: Enables (true) or disables (false) looping. SetClips(tracks: Track[]): Returns: DynamicMusic Description: Replaces current stems with the provided Track array. SetClips(tags: string[]): Returns: DynamicMusic Description: Replaces current stems with the provided array of tags. SetPosition(position: Vector3): Returns: DynamicMusic Description: Sets the 3D world position from which audio emits. SetFollowTarget(target: Transform): Returns: DynamicMusic Description: Makes each audio source follow the specified Transform. SetSpatialSound(activate: bool): Returns: DynamicMusic Description: Toggles spatialized 3D audio (true) or global 2D audio (false). SetFadeOut(fadeOutTime: float): Returns: DynamicMusic Description: Defines a fade-out when stopping all tracks. SetOutput(output: Output): Returns: DynamicMusic Description: Routes all stems to the specified AudioMixerGroup. OnPlay(onPlay: Action): Returns: DynamicMusic Description: Callback when playback starts. OnComplete(onComplete: Action): Returns: DynamicMusic Description: Callback when playback ends or is stopped. OnLoopCycleComplete(onLoopCycleComplete: Action): Returns: DynamicMusic Description: Callback at the end of each loop cycle. OnPause(onPause: Action): Returns: DynamicMusic Description: Callback when paused. OnPauseComplete(onPauseComplete: Action): Returns: DynamicMusic Description: Callback after the pause fade-out finishes. OnResume(onResume: Action): Returns: DynamicMusic Description: Callback when playback resumes. Play(fadeInTime: float): Returns: void Description: Starts playback of all stems (optional fade-in). Pause(fadeOutTime: float): Returns: void Description: Pauses playback with optional fade-out. Resume(fadeInTime: float): Returns: void Description: Resumes playback with optional fade-in. Stop(fadeOutTime: float): Returns: void Description: Stops playback with optional fade-out. ``` -------------------------------- ### DynamicMusic.OnPlay API Reference Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/dynamicmusic/methods Callback invoked when dynamic music playback begins. ```APIDOC DynamicMusic OnPlay(Action onPlay) onPlay: Action ``` -------------------------------- ### Playlist Class API Reference Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/playlist/methods Detailed API documentation for the Playlist class, including constructors, property setters, and playback control methods. ```APIDOC Playlist Class: Constructors: Playlist(): Playlist - Creates an empty instance; you must add tracks before playing. Playlist(playlistTracks: Track[]): Playlist - Creates the playlist with the given Track array in the provided order. Playlist(playlistTags: string[]): Playlist - Creates the playlist using the specified tags in the provided order. Methods: SetVolume(volume: float): Playlist - Sets the initial volume of the playlist, normalized between 0 (mute) and 1 (full volume). SetHearDistance(minHearDistance: float, maxHearDistance: float): Playlist - Defines the distance at which the audio is fully audible and the distance at which it begins to fade. SetVolumeRolloffCurve(curve: VolumeRolloffCurve): Playlist - Selects a logarithmic or linear attenuation curve for distance-based volume drop-off. SetCustomVolumeRolloffCurve(customCurve: AnimationCurve): Playlist - Allows you to apply a custom attenuation curve of your choice. ChangeVolume(newVolume: float, lerpTime: float): void - Changes the playlist’s volume during playback; if lerpTime > 0, the change is smoothed over that duration. SetPitch(pitch: float): Playlist - Applies a fixed pitch to all tracks in the playlist. SetDopplerLevel(dopplerLevel: float): Playlist - Adjusts Doppler effect intensity (0–5). SetId(id: string): Playlist - Assigns a unique identifier to this instance for management via SoundsGoodManager without needing a direct reference. SetLoop(loop: bool): Playlist - Enables (true) or disables (false) infinite looping. SetPlaylist(playlistTracks: Track[]): Playlist - Replaces the playlist with the provided Track array. SetPlaylist(playlistTags: string[]): Playlist - Replaces the playlist with the provided tags array. AddToPlaylist(addedTrack: Track): void - Adds a Track to the end of the playlist at runtime. AddToPlaylist(addedTrackTag: string): void - Adds a tag to the end of the playlist at runtime. Shuffle(): void - Shuffles the current tracks and updates playback order. SetPosition(position: Vector3): Playlist - Sets the 3D world position from which the audio emits. SetFollowTarget(followTarget: Transform): Playlist - Makes the audio source follow the specified Transform. SetSpatialSound(activate: bool): Playlist - Toggles 3D spatial audio (true) or global 2D (false). SetFadeOut(fadeOutTime: float): Playlist - Defines the fade-out duration at the end of each track or when stopping. SetFadeIn(fadeInTime: float): Playlist - Defines the fade-in duration at the start of each track or when starting. SetOutput(output: Output): Playlist - Routes audio to a specific AudioMixerGroup. OnPlay(onPlay: Action): Playlist - Callback invoked when the playlist starts. OnComplete(onComplete: Action): Playlist - Callback invoked when the playlist ends or is manually stopped. OnLoopCycleComplete(onLoopCycleComplete: Action): Playlist - Callback invoked at the end of each loop cycle. OnNextTrackStart(onNextTrackStart: Action): Playlist - Callback invoked when the next track begins. OnPause(onPause: Action): Playlist - Callback invoked when the playlist is paused. OnPauseComplete(onPauseComplete: Action): Playlist - Callback invoked after the pause fade-out completes. OnResume(onResume: Action): Playlist - Callback invoked when the playlist resumes after a pause. Play(): void - Starts playback of the playlist. Pause(fadeOutTime: float): void - Pauses the playlist with optional fade-out. Resume(fadeInTime: float): void - Resumes the playlist with optional fade-in. Stop(fadeOutTime: float): void - Stops the playlist with optional fade-out. ``` -------------------------------- ### Music Object Methods API Reference Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/music/methods API documentation for the `Music` object, detailing its constructors and various methods for controlling audio playback, volume, spatialization, and event handling within the Sounds Good audio system. ```APIDOC Music Music() Music Music(Track track) Music Music(string tag) Music SetVolume(float volume) Music SetHearDistance(float minHearDistance, float maxHearDistance) Music SetVolumeRolloffCurve(VolumeRolloffCurve curve) Music SetCustomVolumeRolloffCurve(AnimationCurve customCurve) void ChangeVolume(float newVolume, float lerpTime) Music SetPitch(float pitch) Music SetDopplerLevel(float dopplerLevel) Music SetId(string id) Music SetLoop(bool loop) Music SetClip(string tag) Music SetClip(Track track) Music SetRandomClip(bool random) Music SetClipByIndex(int index) Music SetPosition(Vector3 position) Music SetFollowTarget(Transform followTarget) Music SetSpatialSound(bool activate) Music SetFadeOut(float fadeOutTime) Music SetOutput(Output output) Music OnPlay(Action onPlay) Music OnComplete(Action onComplete) Music OnLoopCycleComplete(Action onLoopCycleComplete) Music OnPause(Action onPause) Music OnPauseComplete(Action onPauseComplete) Music OnResume(Action onResume) void Play(float fadeInTime) void Pause(float fadeOutTime) void Resume(float fadeInTime) void Stop(float fadeOutTime) ``` -------------------------------- ### Sound Class API Reference Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/sound/methods Detailed API documentation for the `Sound` class, including constructors, properties, and methods for controlling audio playback, volume, pitch, spatialization, and callbacks. ```APIDOC Sound Class: Description: Manages audio playback properties and behavior. Constructors: Sound(): Returns: Sound Description: Empty constructor. You must assign a clip or tag before calling Play(). Sound(sfx: SFX): Returns: Sound Description: Builds the sound using the SFX enum generated in Audio Creator. Sound(tag: string): Returns: Sound Description: Builds the sound from the tag you registered in Audio Creator. Methods: SetVolume(volume: float): Returns: Sound Description: Sets the initial volume (0 = silent, 1 = max). SetHearDistance(minHearDistance: float, maxHearDistance: float): Returns: Sound Description: Defines the distance at which the sound is fully audible and the distance at which it starts fading in. SetVolumeRolloffCurve(curve: VolumeRolloffCurve): Returns: Sound Description: Selects the Logarithmic or Linear roll-off curve for distance attenuation. SetCustomVolumeRolloffCurve(customCurve: AnimationCurve): Returns: Sound Description: Lets you apply an AnimationCurve you created for custom attenuation. ChangeVolume(newVolume: float, lerpTime: float): Returns: void Description: Changes the volume while the sound is playing. If lerpTime > 0 the change is smoothed. SetPitch(pitch: float): Returns: Sound Description: Sets a fixed pitch (also affects playback speed). SetRandomPitch(): Returns: Sound Description: Automatically applies a random pitch between 0.85 and 1.15. SetRandomPitch(pitchRange: Vector2): Returns: Sound Description: Applies random pitch inside the custom range you pass. SetDopplerLevel(dopplerLevel: float): Returns: Sound Description: Defines Doppler intensity (0 – 5). SetId(id: string): Returns: Sound Description: Assigns a unique ID so you can control the sound via SoundsGoodManager without a direct reference. SetLoop(loop: bool): Returns: Sound Description: true → infinite looping, false → plays once. SetClip(tag: string): Returns: Sound Description: Assigns a clip using its tag from Audio Creator. SetClip(sfx: SFX): Returns: Sound Description: Assigns a clip using the SFX enum. SetRandomClip(random: bool): Returns: Sound Description: If enabled, a random clip is chosen each time you call Play(). SetClipByIndex(index: int): Returns: Sound Description: Plays a specific clip by its index inside the tag’s clip array. SetPlayProbability(probability: float): Returns: Sound Description: Sets the chance (0 – 1) that the sound will actually play when Play() is invoked. SetPosition(position: Vector3): Returns: Sound Description: Sets the world position of the audio source. SetFollowTarget(target: Transform): Returns: Sound Description: Makes the source follow a target. SetSpatialSound(spatial: bool): Returns: Sound Description: Toggles 3-D spatial sound. SetFadeOut(duration: float): Returns: Sound Description: Sets fade-out duration. SetOutput(output: Output): Returns: Sound Description: Sends audio to a specific AudioMixerGroup. OnPlay(action: Action): Returns: Sound Description: Callback when playback starts. OnComplete(action: Action): Returns: Sound Description: Callback when playback ends or is stopped. OnLoopCycleComplete(action: Action): Returns: Sound Description: Callback at the end of each loop cycle. OnPause(action: Action): Returns: Sound Description: Callback when the sound is paused. OnPauseComplete(action: Action): Returns: Sound Description: Callback after the pause fade-out finishes. OnResume(action: Action): Returns: Sound Description: Callback when the sound resumes. Play(fadeInTime: float): Returns: void Description: Plays the sound (optional fade-in). Pause(fadeOutTime: float): Returns: void Description: Pauses with optional fade-out. Resume(fadeInTime: float): Returns: void Description: Resumes with optional fade-in. Stop(fadeOutTime: float): Returns: void Description: Stops with optional fade-out. ``` -------------------------------- ### Sound Class API Reference Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/sound/methods Comprehensive API documentation for the `Sound` class, detailing its constructors and various methods for controlling audio properties, playback, and event callbacks. This includes methods for setting volume, pitch, spatialization, looping, clip management, and handling play/pause/stop events. ```APIDOC Sound.Sound() ``` ```APIDOC Sound.Sound(sfx: SFX) ``` ```APIDOC Sound.Sound(tag: string) ``` ```APIDOC Sound.SetVolume(volume: float) -> Sound ``` ```APIDOC Sound.SetHearDistance(minHearDistance: float, maxHearDistance: float) -> Sound ``` ```APIDOC Sound.SetVolumeRolloffCurve(curve: VolumeRolloffCurve) -> Sound ``` ```APIDOC Sound.SetCustomVolumeRolloffCurve(customCurve: AnimationCurve) -> Sound ``` ```APIDOC Sound.ChangeVolume(newVolume: float, lerpTime: float) -> void ``` ```APIDOC Sound.SetPitch(pitch: float) -> Sound ``` ```APIDOC Sound.SetRandomPitch() -> Sound ``` ```APIDOC Sound.SetRandomPitch(pitchRange: Vector2) -> Sound ``` ```APIDOC Sound.SetDopplerLevel(dopplerLevel: float) -> Sound ``` ```APIDOC Sound.SetId(id: string) -> Sound ``` ```APIDOC Sound.SetLoop(loop: bool) -> Sound ``` ```APIDOC Sound.SetClip(tag: string) -> Sound ``` ```APIDOC Sound.SetClip(sfx: SFX) -> Sound ``` ```APIDOC Sound.SetRandomClip(random: bool) -> Sound ``` ```APIDOC Sound.SetClipByIndex(index: int) -> Sound ``` ```APIDOC Sound.SetPlayProbability(probability: float) -> Sound ``` ```APIDOC Sound.SetPosition(position: Vector3) -> Sound ``` ```APIDOC Sound.SetFollowTarget(followTarget: Transform) -> Sound ``` ```APIDOC Sound.SetSpatialSound(activate: bool) -> Sound ``` ```APIDOC Sound.SetFadeOut(fadeOutTime: float) -> Sound ``` ```APIDOC Sound.SetOutput(output: Output) -> Sound ``` ```APIDOC Sound.OnPlay(onPlay: Action) -> Sound ``` ```APIDOC Sound.OnComplete(onComplete: Action) -> Sound ``` ```APIDOC Sound.OnLoopCycleComplete(onLoopCycleComplete: Action) -> Sound ``` ```APIDOC Sound.OnPause(onPause: Action) -> Sound ``` ```APIDOC Sound.OnPauseComplete(onPauseComplete: Action) -> Sound ``` ```APIDOC Sound.OnResume(onResume: Action) -> Sound ``` ```APIDOC Sound.Play(fadeInTime: float) -> void ``` ```APIDOC Sound.Pause(fadeOutTime: float) -> void ``` ```APIDOC Sound.Resume(fadeInTime: float) -> void ``` ```APIDOC Sound.Stop(fadeOutTime: float) -> void ``` -------------------------------- ### Playlist OnNextTrackStart Callback Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/playlist/methods Registers a callback action to be invoked each time the playlist transitions to the next track. ```APIDOC Playlist OnNextTrackStart(Action onNextTrackStart) ``` -------------------------------- ### Play a Sound in Unity (C#) Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/editor-windows This snippet demonstrates how to play a registered sound in the Sounds Good system using a single line of C# code. It instantiates a `Sound` object by its tag and immediately plays it. ```C# new Sound("Laser").Play(); ``` -------------------------------- ### SoundsGoodManager Static Methods API Reference Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/soundsgoodmanager Detailed API documentation for the static methods available in the SoundsGoodManager class, covering their purpose, parameters, and return types for comprehensive audio control. ```APIDOC SoundsGoodManager: void ChangeOutputVolume(Output output, float value) Description: Adjusts the fader of the AudioMixerGroup linked to 'output' and saves the value in PlayerPrefs. Parameters: output: The Output enum value representing the audio output group. value: The volume level (float, 0-1). ``` ```APIDOC SoundsGoodManager: void ChangeOutputVolume(string outputName, float value) Description: Adjusts the fader of the AudioMixerGroup linked to 'outputName' and saves the value in PlayerPrefs, using the exact group name. Parameters: outputName: The name of the output group (string). value: The volume level (float, 0-1). ``` ```APIDOC SoundsGoodManager: void PauseAll(float fadeOutTime = 0) Description: Applies a fade-out of 'fadeOutTime' seconds and pauses all Sound, Music, Playlist, and DynamicMusic. Parameters: fadeOutTime: The duration of the fade-out in seconds (float, default 0). ``` ```APIDOC SoundsGoodManager: void Pause(string id, float fadeOutTime = 0) Description: Pauses the audio whose SetId("id") matches, with optional fade-out. Parameters: id: The identifier of the audio to pause (string). fadeOutTime: The duration of the fade-out in seconds (float, default 0). ``` ```APIDOC SoundsGoodManager: void ResumeAll(float fadeInTime = 0) Description: Resumes any paused audio, applying fade-in if specified. Parameters: fadeInTime: The duration of the fade-in in seconds (float, default 0). ``` ```APIDOC SoundsGoodManager: void Resume(string id, float fadeInTime = 0) Description: Resumes the audio identified by 'id', provided it is paused. Parameters: id: The identifier of the audio to resume (string). fadeInTime: The duration of the fade-in in seconds (float, default 0). ``` ```APIDOC SoundsGoodManager: void StopAll(float fadeOutTime = 0) Description: Stops (not just pauses) all audio; if 'fadeOutTime' > 0 it fades out before stopping. Parameters: fadeOutTime: The duration of the fade-out in seconds (float, default 0). ``` ```APIDOC SoundsGoodManager: void Stop(string id, float fadeOutTime = 0) Description: Stops the audio with the given 'id'. Useful for loops or music you want to cut on demand. Parameters: id: The identifier of the audio to stop (string). fadeOutTime: The duration of the fade-out in seconds (float, default 0). ``` -------------------------------- ### DynamicMusic.Resume API Reference Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/dynamicmusic/methods Resumes all stems with optional fade-in. ```APIDOC void Resume(float fadeInTime) fadeInTime: float ``` -------------------------------- ### Playlist Play Method Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/playlist/methods Initiates playback of the playlist, applying any configured fade-in effect. ```APIDOC void Play() ``` -------------------------------- ### DynamicMusic.SetOutput API Reference Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/dynamicmusic/methods Routes stems to a specific output channel in the Audio Mixer. ```APIDOC DynamicMusic SetOutput(Output output) output: Output ``` -------------------------------- ### DynamicMusic Object Properties Reference Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/dynamicmusic/properties Detailed API documentation for the properties available on the `DynamicMusic` object, including their data types and comprehensive descriptions of their functionality and usage. ```APIDOC DynamicMusic Properties: Using: bool Description: Returns true if the dynamic music is in use. This includes both active playback and paused states, as long as it’s still assigned to one or more AudioSource instances. Playing: bool Description: Returns true if the dynamic music is actively playing. Returns false if it’s paused or stopped. Paused: bool Description: Returns true if the dynamic music is paused. This property is unaffected by any fade-out effects. PlayingTime: float Description: Total time (in seconds) that has elapsed since the dynamic music began playing. CurrentLoopCycleTime: float Description: Elapsed time (in seconds) of the current loop cycle. If looping is disabled, this value matches the elapsed time of the current clip. CompletedLoopCycles: int Description: Number of times the dynamic music has completed a full loop cycle since starting. Only increments if looping is active. ClipDuration: float Description: Duration (in seconds) of each clip. All clips are assumed to share the same length, so this reflects the length of the first clip. Clips: AudioClip[] Description: Array containing all AudioClip stems that form the dynamic music. Each clip typically represents a separate instrumental layer you can control independently. ``` -------------------------------- ### Play Sound and Control Output Volume in C# Source: https://melenitass-organization.gitbook.io/sounds-good-docs/create-and-use-audio-outputs This C# code snippet demonstrates how to play a sound using the Sounds Good system and direct it to a specific audio output channel, such as 'Voicechat'. It also shows how to programmatically adjust the global volume of that output channel at runtime using SoundsGoodManager.ChangeOutputVolume. ```C# // Play a sound through the new channel new Sound(SFX.RadioBeep) .SetOutput(Output.Voicechat) // already available in the enum! .Play(); // Set the global volume of the channel to 60 % SoundsGoodManager.ChangeOutputVolume(Output.Voicechat, 0.6f); ``` -------------------------------- ### Audio Creator Window Elements Reference Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/editor-windows/audio-creator Reference for the various UI elements within the Sounds Good Audio Creator window, detailing their function and usage for managing audio assets. ```APIDOC Tabs `Sounds` / `Music`: Description: Switch between creating SFX (highlighted in yellow) or Music tracks (grey). Changing tabs resets the form. Tag field: Description: Enter a unique identifier (no special characters or leading numbers). This becomes the value you use in code or in the `SFX` / `Track` enum. Drop your Audio Clips here area: Description: Drag one or more `AudioClip` files (WAV, MP3, OGG…). If multiple clips are added, Sounds Good will choose one at random when `SetRandomClip(true)` or if no specific index is set. Optimize your audio clips group: Description: Apply a compression preset and optionally force Mono. Includes: Compression Preset dropdown: Values: `FrequentSound`, `OccasionalSound`, `AmbientMusic` Descriptive text for the selected preset Force to Mono checkbox CREATE button: Description: Creates the audio object and registers it in the database. Becomes enabled once a valid tag is entered and at least one clip is present. ``` -------------------------------- ### Register Sound Loop Cycle Callback (Action) Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/sound/methods Executed each time a loop cycle finishes, if `loop` is enabled. ```APIDOC `Sound` OnLoopCycleComplete(`Action` onLoopCycleComplete) ``` -------------------------------- ### Sounds Good Plugin Assemblies and Contents Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/assemblies-and-namespaces This section specifies the Assembly Definition Files (.asmdef) included with the Sounds Good plugin, detailing the runtime code, models, editor windows, and system utilities contained within each assembly. This structure ensures modularity and efficient project integration. ```APIDOC Assembly: SoundsGood.Application Contains: Runtime code (Sound, Music, Playlist, DynamicMusic, SoundsGoodManager) Assembly: SoundsGood.Domain Contains: Models and data shared by runtime and editor Assembly: SoundsGood.Editor Contains: Editor windows (Audio Creator, Audio Collection, Output Manager, Version Upgrader) Assembly: SoundsGood.SystemUtilities Contains: Helpers for reflection, pooling, coroutines and internal extensions Assembly: SoundsGood.Demo Contains: Scripts and scenes inside the Demo folder ``` -------------------------------- ### DynamicMusic.SetFollowTarget API Reference Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/dynamicmusic/methods Makes each audio source follow the specified `Transform`. ```APIDOC DynamicMusic SetFollowTarget(Transform target) target: Transform ``` -------------------------------- ### Set Sound Follow Target (Transform) Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/sound/methods Makes the audio source follow the given `Transform` every frame. ```APIDOC `Sound` SetFollowTarget(`Transform` followTarget) ``` -------------------------------- ### Playlist SetOutput Method Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/playlist/methods Routes the playlist's audio output to a specified AudioMixerGroup channel. ```APIDOC Playlist SetOutput(Output output) ``` -------------------------------- ### Music Object Properties API Reference Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/music/properties Comprehensive API documentation for the properties of the `Music` audio object, including their data types, short descriptions, and detailed explanations of their behavior and usage within the Sounds Good framework. ```APIDOC Property: Using Type: bool Description: True if the music is in use, even if it's paused. Detailed Description: Returns true if the music is in use. This includes both active playback and cases where the music has been paused but is still assigned to an AudioSource. ``` ```APIDOC Property: Playing Type: bool Description: True if the music is currently playing. Detailed Description: Returns true if the music is actively playing at the moment. If it’s paused or stopped, this property will be false. ``` ```APIDOC Property: Paused Type: bool Description: True if the music is paused, ignoring any fade out. Detailed Description: Returns true if the music is paused. Unlike Playing, this property ignores any fade out effect and focuses solely on the actual playback state. ``` ```APIDOC Property: Volume Type: float Description: Current music volume (value between 0 and 1). Detailed Description: Represents the current volume level of the music. Its value is normalized between 0 (silent) and 1 (maximum volume). ``` ```APIDOC Property: ClipIndex Type: int Description: Index of the playing clip. Returns -1 if there's none selected. Detailed Description: Indicates the index of the currently playing clip within the available clip set for that music track. If none is selected, it returns -1. ``` ```APIDOC Property: PlayingTime Type: float Description: Total time (in seconds) the music has been playing. Detailed Description: Indicates the total time (in seconds) the music has been playing since it was last started. ``` ```APIDOC Property: CurrentLoopCycleTime Type: float Description: Current time (in seconds) of the loop cycle being played. Detailed Description: Returns the time the current loop cycle has been playing. If the music is not looping, this value will match the total play time. ``` ```APIDOC Property: CompletedLoopCycles Type: int Description: Number of completed loop cycles. Detailed Description: Number of times the music has completed a full loop cycle. This property only increases when looping is enabled. ``` ```APIDOC Property: ClipDuration Type: float Description: Total duration of the currently playing clip. Detailed Description: Total duration in seconds of the clip currently being played. If no clip is assigned, the value will be 0. ``` ```APIDOC Property: Clip Type: AudioClip Description: The current music clip being played. ``` -------------------------------- ### Music Class API Reference Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/music/methods Detailed API reference for the Music class, including constructors, methods, their parameters, return types, and descriptions. This class is central to managing audio assets within the SoundsGood system. ```APIDOC Music Class: Description: Manages music playback, volume, spatialization, and callbacks. Constructors: Music(): Description: Empty constructor. You must assign a clip or tag before calling Play(). Returns: Music Music(track: Track): Description: Creates a new Music instance using the specified Track enum entry. Parameters: track: Track - The Track enum entry. Returns: Music Music(tag: string): Description: Creates a new Music instance using the tag registered in Audio Creator. Parameters: tag: string - The tag registered in Audio Creator. Returns: Music Methods: SetVolume(volume: float): Description: Sets the initial volume, normalized between 0 (silent) and 1 (full volume). Parameters: volume: float - The volume level (0-1). Returns: Music SetHearDistance(minHearDistance: float, maxHearDistance: float): Description: Defines the distance at which the music is fully audible and where it begins to fade in. Parameters: minHearDistance: float - Minimum hearing distance. maxHearDistance: float - Maximum hearing distance. Returns: Music SetVolumeRolloffCurve(curve: VolumeRolloffCurve): Description: Chooses between Logarithmic or Linear rolloff for distance attenuation. Parameters: curve: VolumeRolloffCurve - The rolloff curve type. Returns: Music SetCustomVolumeRolloffCurve(customCurve: AnimationCurve): Description: Applies a custom attenuation curve you provide. Parameters: customCurve: AnimationCurve - The custom attenuation curve. Returns: Music ChangeVolume(newVolume: float, lerpTime: float): Description: Changes the volume during playback. If lerpTime > 0, the change is interpolated smoothly. Parameters: newVolume: float - The target volume. lerpTime: float - The time over which to interpolate the volume change. Returns: void SetPitch(pitch: float): Description: Sets a fixed pitch, affecting both pitch and playback speed. Parameters: pitch: float - The pitch value. Returns: Music SetDopplerLevel(dopplerLevel: float): Description: Adjusts the Doppler effect intensity (range 0 – 5). Parameters: dopplerLevel: float - The Doppler effect intensity (0-5). Returns: Music SetId(id: string): Description: Assigns a unique identifier so you can reference this music via SoundsGoodManager. Parameters: id: string - The unique identifier. Returns: Music SetLoop(loop: bool): Description: Enables (true) or disables (false) infinite looping. Parameters: loop: bool - True to loop, false otherwise. Returns: Music SetClip(tag: string): Description: Assigns a clip by its tag from the Audio Creator configuration. Parameters: tag: string - The tag of the clip. Returns: Music SetClip(track: Track): Description: Assigns a clip using the Track enum entry. Parameters: track: Track - The Track enum entry. Returns: Music SetRandomClip(random: bool): Description: If true, selects a random clip from the group on each Play() call. Parameters: random: bool - True to enable random clip selection. Returns: Music SetClipByIndex(index: int): Description: Selects a specific clip by its index within the group's clip array. Parameters: index: int - The index of the clip. Returns: Music SetPosition(position: Vector3): Description: Sets the 3D world position from which the music is emitted. Parameters: position: Vector3 - The world position. Returns: Music SetFollowTarget(followTarget: Transform): Description: Makes the audio source follow the specified Transform target. Parameters: followTarget: Transform - The Transform to follow. Returns: Music SetSpatialSound(activate: bool): Description: Toggles spatialized 3D audio (true) or global 2D audio (false). Parameters: activate: bool - True for 3D sound, false for 2D sound. Returns: Music SetFadeOut(fadeOutTime: float): Description: Defines how long the fade-out lasts when stopping the music. Parameters: fadeOutTime: float - The fade-out duration. Returns: Music SetOutput(output: Output): Description: Routes the music to a given AudioMixerGroup output. Parameters: output: Output - The AudioMixerGroup output. Returns: Music OnPlay(onPlay: Action): Description: Callback invoked at playback start. Parameters: onPlay: Action - The callback action. Returns: Music OnComplete(onComplete: Action): Description: Callback invoked at end or stop. Parameters: onComplete: Action - The callback action. Returns: Music OnLoopCycleComplete(onLoopCycleComplete: Action): Description: Callback each time a loop cycle completes. Parameters: onLoopCycleComplete: Action - The callback action. Returns: Music OnPause(onPause: Action): Description: Callback when paused. Parameters: onPause: Action - The callback action. Returns: Music OnPauseComplete(onPauseComplete: Action): Description: Callback after pause fade-out ends. Parameters: onPauseComplete: Action - The callback action. Returns: Music OnResume(onResume: Action): Description: Callback when resumed. Parameters: onResume: Action - The callback action. Returns: Music Play(fadeInTime: float): Description: Plays the music (optional fade-in). Parameters: fadeInTime: float - The fade-in duration. Returns: void Pause(fadeOutTime: float): Description: Pauses with optional fade-out. Parameters: fadeOutTime: float - The fade-out duration. Returns: void Resume(fadeInTime: float): Description: Resumes with optional fade-in. Parameters: fadeInTime: float - The fade-in duration. Returns: void Stop(fadeOutTime: float): Description: Stops with optional fade-out. Parameters: fadeOutTime: float - The fade-out duration. Returns: void ``` -------------------------------- ### DynamicMusic.SetClips (string[]) API Reference Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/dynamicmusic/methods Replaces all current stems with the provided tags array. ```APIDOC DynamicMusic SetClips(string[] tags) tags: string[] ``` -------------------------------- ### DynamicMusic.SetClips (Track[]) API Reference Source: https://melenitass-organization.gitbook.io/sounds-good-docs/documentation/audio-objects/dynamicmusic/methods Replaces all current stems with the provided `Track` array. ```APIDOC DynamicMusic SetClips(Track[] tracks) tracks: Track[] ```