Fading sound in/out

后端 未结 2 2034
南旧
南旧 2020-12-11 17:52

I have a background sound playing in an endless loop. I want it to fade out when the user does press a button.

I tried the following:

  • A DirectSoundOut
2条回答
  •  青春惊慌失措
    2020-12-11 18:34

    Or you can just, do this:

    while (waveOut.volume > 0.1)
    {
      waveOut.volume -= 0.1;
      System.Threading.Thread.Sleep(10);
    }
    

    ^ An example of a fade-out. I use it in my own programs, works fine.

提交回复
热议问题