From 620f4d83252c338c6c4ef8f54aa1db94940b950d Mon Sep 17 00:00:00 2001 From: JappaWakkaP3D Date: Sun, 25 Oct 2020 15:27:55 +0100 Subject: [PATCH] Actually fix the music sharing its volume with the soundeffects --- P3D/Resources/Sound/MusicManager.vb | 58 ++++++++++++++--------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/P3D/Resources/Sound/MusicManager.vb b/P3D/Resources/Sound/MusicManager.vb index d4fdda018..ed12776b2 100644 --- a/P3D/Resources/Sound/MusicManager.vb +++ b/P3D/Resources/Sound/MusicManager.vb @@ -94,8 +94,8 @@ Public Class MusicManager Private Shared _isFadingIn As Boolean = False ' NAudio properties Public Shared outputDevice As WaveOutEvent - Public Shared audioFile As VorbisWaveReader - Public Shared _loop As WaveStream + Public Shared audioFile As WaveChannel32 + Public Shared _loop As WaveStream Public Shared Property MasterVolume As Single = 1.0F Public Shared ReadOnly Property CurrentSong As SongContainer @@ -271,9 +271,9 @@ Public Class MusicManager Public Shared Sub UpdateVolume() _lastVolume = Volume * MasterVolume - If Not outputDevice Is Nothing Then - outputDevice.Volume = Volume * MasterVolume - End If + If Not audioFile Is Nothing Then + audioFile.Volume = Volume * MasterVolume + End If End Sub Public Shared Sub PauseForSound(ByVal sound As SoundEffect) @@ -310,32 +310,32 @@ Public Class MusicManager End Sub - Private Shared Sub Play(song As SongContainer) - If Not song Is Nothing Then - Logger.Debug($"Play song [{song.Name}]") - If Not outputDevice Is Nothing Then - outputDevice.Dispose() - End If - outputDevice = New WaveOutEvent() - audioFile = New VorbisWaveReader(song.Song) - _loop = New LoopStream(audioFile, _isLooping) - outputDevice.Init(_loop) - If Paused = False Then - outputDevice.Play() - End If - outputDevice.Volume = Volume * MasterVolume - _currentSongExists = True - _currentSongName = song.Name - _currentSong = song - Else - _currentSongExists = False - _currentSongName = NO_MUSIC - _currentSong = Nothing - End If + Private Shared Sub Play(song As SongContainer) + If Not song Is Nothing Then + Logger.Debug($"Play song [{song.Name}]") + If Not outputDevice Is Nothing Then + outputDevice.Dispose() + End If + outputDevice = New WaveOutEvent() + audioFile = New NAudio.Wave.WaveChannel32(New VorbisWaveReader(song.Song)) + _loop = New LoopStream(audioFile, _isLooping) + outputDevice.Init(_loop) + If Paused = False Then + outputDevice.Play() + End If + audioFile.Volume = Volume * MasterVolume + _currentSongExists = True + _currentSongName = song.Name + _currentSong = song + Else + _currentSongExists = False + _currentSongName = NO_MUSIC + _currentSong = Nothing + End If - End Sub + End Sub - Private Shared Sub FadeInto(song As SongContainer, fadeSpeed As Single) + Private Shared Sub FadeInto(song As SongContainer, fadeSpeed As Single) _isFadingOut = True If Not song Is Nothing Then _nextSong = song.Name