🟧
Sounds Good Documentation
English
English
  • Welcome!
  • FIRSTS STEPS
    • Create your first sound
  • Create and use audio outputs
  • Included Prefabs
  • Update from 1.0 to 2.0
  • DOCUMENTATION
    • Assemblies and Namespaces
    • Prefixes
    • Audio objects
      • Sound
        • Properties
        • Methods
      • Music
        • Properties
        • Methods
      • Playlist
        • Properties
        • Methods
      • DynamicMusic
        • Properties
        • Methods
    • Editor windows
      • Audio Creator
      • Audio Collection
      • Output Manager
    • SoundsGoodManager
  • Extras
    • Credits
    • Acknowledgments
Powered by GitBook
On this page
  • πŸ›  How to create a DynamicMusic
  • πŸ“ Advanced Example
  1. DOCUMENTATION
  2. Audio objects

DynamicMusic

A DynamicMusic instance lets you play multiple music tracks simultaneously, perfectly synchronized. It’s perfect for adaptive soundtracks where different instrumental layers (e.g., drums, strings, vocals) are turned on or off at runtime based on gameplay. Use the same music tracks you created in the Audio Creator window under the Music tab.

All tracks must be exactly the same length or they can drift out of sync.


πŸ›  How to create a DynamicMusic

Group your pre-created tracks by their tags or by the Track enum identifiers. For example, to build a layered theme:

new DynamicMusic("BaseTrack", "Drums", "Strings").Play();

Or using the Track enum directly:

new DynamicMusic(Track.BaseTrack, Track.Drums, Track.Strings).Play();

If you rename a track’s tag in the Audio Collection window, any code reference will break.

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();

πŸ“ Advanced Example

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

πŸ‘‰ This sets up an adaptive soundtrack that begins with a soft base layer and then intensifies by bringing in percussion when combat begins.

PreviousMethodsNextProperties

Last updated 17 days ago