naudio / NAudio

Audio and MIDI library for .NET
MIT License
5.47k stars 1.1k forks source link

Changing WaveOutEvent volume changes master volume in Mixer / nerfs all other audio #668

Open nightblade9 opened 4 years ago

nightblade9 commented 4 years ago

My game setup:

Everything works fine. Until I try to set Volume on WaveOutEvent. Bad things happen:

The perception of this in-game is that changing BGM volume changes all SFX volumes, too.

You can see a tweet of this in action here: https://twitter.com/nightblade99/status/1283223485670719488/video/1

I tested it on two machines (Windows 10 and Windows 8.1) and this behaviour is the same on both machines.

How do I work around this / is it a bug? (It could be a MonoGame bug; playing multiple audio .wav files shows different issues.)

markheath commented 4 years ago

No, it's not a bug - it's calling a Windows API that sets the volume for that output device

A better approach is to actually change the volume of the samples you are sending to that device. E.g. If your SoundEffect instance has a volume property you can set it on that.

nightblade9 commented 4 years ago

A better approach is to actually change the volume of the samples you are sending to that device. E.g. If your SoundEffect instance has a volume property you can set it on that.

Is there a code sample for this? I thought SoundEffect and SoundEffectInstance don't work with OGG files. If they do, I don't know how to get that working.

markheath commented 4 years ago

SoundEffect is not part of NAudio, so I'm afraid I don't know what it's capabilities are