Adjust Audio Volume

A

AP

How can I adjust audio volume (for wav, MIDI, mp3 files) from within Excel ?

What declarations and functions would I need ?

Thanks,
AP
 
P

Piotr Lipski

How can I adjust audio volume (for wav, MIDI, mp3 files) from within Excel ?

For wav:

Declare Function waveOutSetVolume Lib "Winmm" (ByVal wDeviceID As Integer,
ByVal dwVolume As Long) As Integer
Declare Function waveOutGetVolume Lib "Winmm" (ByVal wDeviceID As Integer,
dwVolume As Long) As Integer

Public Function GetVolume()
Dim a, i As Long
Dim tmp As String
a = waveOutGetVolume(0, i)
tmp = "&h" & Right(Hex$(i), 4)
GetVolume = CLng(tmp)
End Function

Public Function SetVolume(vol As Long)
Dim a, i As Long
Dim tmp As String
tmp = Right((Hex$(vol + 65536)), 4)
vol = CLng("&H" & tmp & tmp)
a = waveOutSetVolume(0, vol)
End Function

For other devices, look at the examples in ApiGuide.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top