Fixed a bug where the fix for the volume would cause music loops to stop working

This commit is contained in:
JappaWakkaP3D 2020-10-25 16:21:33 +01:00 committed by Vitaly Mikhailov
parent 620f4d8325
commit 3799887e15

View File

@ -94,8 +94,8 @@ Public Class MusicManager
Private Shared _isFadingIn As Boolean = False Private Shared _isFadingIn As Boolean = False
' NAudio properties ' NAudio properties
Public Shared outputDevice As WaveOutEvent Public Shared outputDevice As WaveOutEvent
Public Shared audioFile As WaveChannel32 Public Shared audioFile As VorbisWaveReader
Public Shared _loop As WaveStream Public Shared _stream As WaveChannel32
Public Shared Property MasterVolume As Single = 1.0F Public Shared Property MasterVolume As Single = 1.0F
Public Shared ReadOnly Property CurrentSong As SongContainer Public Shared ReadOnly Property CurrentSong As SongContainer
@ -271,8 +271,8 @@ Public Class MusicManager
Public Shared Sub UpdateVolume() Public Shared Sub UpdateVolume()
_lastVolume = Volume * MasterVolume _lastVolume = Volume * MasterVolume
If Not audioFile Is Nothing Then If Not _stream Is Nothing Then
audioFile.Volume = Volume * MasterVolume _stream.Volume = Volume * MasterVolume
End If End If
End Sub End Sub
@ -317,13 +317,13 @@ Public Class MusicManager
outputDevice.Dispose() outputDevice.Dispose()
End If End If
outputDevice = New WaveOutEvent() outputDevice = New WaveOutEvent()
audioFile = New NAudio.Wave.WaveChannel32(New VorbisWaveReader(song.Song)) audioFile = New VorbisWaveReader(song.Song)
_loop = New LoopStream(audioFile, _isLooping) _stream = New NAudio.Wave.WaveChannel32(New LoopStream(audioFile, _isLooping))
outputDevice.Init(_loop) outputDevice.Init(_stream)
If Paused = False Then If Paused = False Then
outputDevice.Play() outputDevice.Play()
End If End If
audioFile.Volume = Volume * MasterVolume _stream.Volume = Volume * MasterVolume
_currentSongExists = True _currentSongExists = True
_currentSongName = song.Name _currentSongName = song.Name
_currentSong = song _currentSong = song