Fade in and fade out music

This forum is currently in read-only mode.
From the Asset Store
6 looping tracks to use in your games and projects. These tracks are in the style of the 1960s detective movie genre.
  • Hello

    Does anyone know how to make a fade in and fade out effect using the XAudio2

    Thanks

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Do you mean like positional sounds? (they get louder and quieter as you get closer to them), or pure volume fade?

    If so, then the best way is to use a global variable for volume (eg: "MusVol"), maybe a second global variable for whether to fade in/out or not at all (eg: "MusFade", 0 for no fade, -1 for out, 1 for in), then a variable for how much to fade by per second (eg: "FadeSpeed").

    Code would look something like this:

    IF MusFade = -1 & MusVol > 0 THEN MusVol = MusVol - (FadeSpeed * timedelta)

    IF MusFade = 0 THEN MusVol = 100% (I forget exactly if it's in a value between 0-1, or 0-100, or even in dB where 0 is loudest)

    IF MusFade = 1 & MusVol < 100% THEN MusVol = MusVol + (FadeSpeed * timedelta)

    That's in pseudocode (not real code of any language), so things like "MusFade" would have to be written in Construct's way like: global.value('MusFade')

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)