This also refers to an older topic: SoundEffect & Volume
I’m currently playing a song in the mediaplayer and firing a SoundEffect whilst playing. For that I want two different set of volumes, namely:
However, just as the older topic indicates, it’s not working as I think it should. My current setup for playing a SoundEffect:
SoundEffectInstance i = FX.CreateInstance();
float test = SoundEffect.MasterVolume; // This will retrieve master volume for testing, it's set to 1.0f
i.Volume = 0.5f; // The volume for this SoundEffectInstance
The problem is as follows:
The SoundEffect seems to scale with MediaPlayer.Volume instead of SoundEffect.MasterVolume. Since I hear no soundeffects when the MediaPlayer.Volume is 0 even though the test from above indicates the SoundEffect.MasterVolume is 1.
I’m using MonoGame’s recent develop build, and this is a Windows application using DirectX.
Are your sound effects in mp3 or wave format? Its possible they were loaded as songs not effects?
The music (in mediaplayer) is .mp3. The soundeffects are .wav files. They are loaded from the SoundEffect.FromUri though. Does that matter?
Make sure the content type is set to the proper types in the project, such as music is a song and sound effect is effect. Play the sound effect with SoundEffect.Play() method. I had a similar issue while ago where my content type was all set to song and the media player was having issues playing properly.
I tried playing it as “SoundEffect.Play()” but that made no difference. For clarity, I’m not using any content projects, simply loading the music files from stream like so:
Song s = Song.FromUri(name, new Uri(path, UriKind.Relative));
SoundEffect s = SoundEffect.FromStream(path);
I’ve created a content project with the MGCB and converted both the .mp3 and the .wav files. I’m now loading in the sound files as follows:
This did not solve my problem. The SoundEffects still scale with the MediaPlayer.Volume instead of the SoundEffect.MasterVolume value. Is there a workaround for this problem?
I have the same problem. I found this:
github.com/mono/MonoGame/issues/2780 (sorry not allowed to link)
which seems to indicate that the bug was fixed, but I can confirm that the latest development build still has this issue.