Skip to content

Commit

Permalink
- On exit program the pc master volume will be setted to initial value
Browse files Browse the repository at this point in the history
  • Loading branch information
Speedvicio committed Oct 20, 2022
1 parent 92ab596 commit 6b01055
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
12 changes: 12 additions & 0 deletions gUiADE/AudioCtrl.vb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Module AudioCtrl
Dim NumLEDS As Integer = 20
Dim devEnum
Dim defaultDevice
Public oldVol As Integer

Public Sub StartPeak()

Expand All @@ -14,11 +15,13 @@ Module AudioCtrl
If Val(Environment.OSVersion.Version.Major) >= 6 Then
devEnum = New CoreAudioApi.MMDeviceEnumerator
defaultDevice = devEnum.GetDefaultAudioEndpoint(CoreAudioApi.EDataFlow.eRender, CoreAudioApi.ERole.eMultimedia)
oldVol = defaultDevice.AudioEndpointVolume.MasterVolumeLevelScalar * 100
Form1.TrackBar1.Value = defaultDevice.AudioEndpointVolume.MasterVolumeLevelScalar * 100
Form1.PeakMeterCtrl1.Start(1000 / 20)
Form1.PeakMeterCtrl2.Start(1000 / 20)
Else
Form1.TrackBar1.Value = GetApplicationVolume()
oldVol = GetApplicationVolume()
End If
Form1.ToolTip1.SetToolTip(Form1.TrackBar1, "Volume " & Form1.TrackBar1.Value.ToString & "%")
End Sub
Expand Down Expand Up @@ -70,6 +73,15 @@ Module AudioCtrl
End If
End Sub

Public Sub ResetVol()
If Val(Environment.OSVersion.Version.Major) >= 6 Then
defaultDevice.AudioEndpointVolume.MasterVolumeLevelScalar = oldVol / 100
Else
Dim vol As UInteger = CUInt((UShort.MaxValue / 100) * oldVol)
waveOutSetVolume(IntPtr.Zero, CUInt((vol And &HFFFF) Or (vol << 16)))
End If
End Sub

Private Function GetApplicationVolume() As Integer
Dim vol As UInteger = 0
waveOutGetVolume(IntPtr.Zero, vol)
Expand Down
26 changes: 13 additions & 13 deletions gUiADE/Form1.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions gUiADE/Form1.vb
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ Public Class Form1
Action_UADE("kill")
UseThread("stop")
DeleteTemp()
ResetVol()
End Sub

Private Sub MakeBat(testo As StreamWriter, nBat As String, bPar As String, dbName As String)
Expand Down

0 comments on commit 6b01055

Please sign in to comment.