system sound

ian watkins

New Member
Joined
Feb 4, 2003
Messages
28
Don't know if this is possible but I'd like to know if I can use Excel to set the system volume to maximum. I've got a sound file that will play using the auto_open procedure and would like it to be as loud as possible.

Any ideas
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Yep... something like this seems to work:

<font face=Courier New><SPAN style="color:#00007F">Option</SPAN> <SPAN style="color:#00007F">Explicit</SPAN>

<SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Declare</SPAN> <SPAN style="color:#00007F">Function</SPAN> waveOutSetVolume <SPAN style="color:#00007F">Lib</SPAN> "Winmm" (<SPAN style="color:#00007F">ByVal</SPAN> wDeviceID <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Integer</SPAN>, <SPAN style="color:#00007F">ByVal</SPAN> dwVolume <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>) <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Integer</SPAN>

<SPAN style="color:#00007F">Function</SPAN> ChangeWavVolume(Percent <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Double</SPAN>) <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Boolean</SPAN>
    <SPAN style="color:#007F00">'Percent is a value between 0 and 1, where 0 is mute, 1 is highest value</SPAN>
    <SPAN style="color:#00007F">Dim</SPAN> sTemp <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>
    <SPAN style="color:#00007F">Dim</SPAN> sVolume <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>
    
    sTemp = Right$((Hex$(65535 * Percent + 65536)), 4)
    sVolume = <SPAN style="color:#00007F">CLng</SPAN>("&H" & sTemp & sTemp)
    ChangeWavVolume = (waveOutSetVolume(0, sVolume) = 0)
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Function</SPAN>

<SPAN style="color:#00007F">Sub</SPAN> TestIt()
    <SPAN style="color:#00007F">If</SPAN> ChangeWavVolume(1) <SPAN style="color:#00007F">Then</SPAN>
        MsgBox "Loudest !", vbInformation
    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
    
    <SPAN style="color:#00007F">If</SPAN> ChangeWavVolume(0) <SPAN style="color:#00007F">Then</SPAN>
        MsgBox "Mute...", vbInformation
    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

Are you trying to scare someone ??? :lol:
 
Upvote 0
In the event that you also want to tweak the Main Volume and System Mute Settings, see the following:

<font face=Courier New><SPAN style="color:darkblue">Option</SPAN> <SPAN style="color:darkblue">Explicit</SPAN>

<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN> ***************************************************************************</SPAN></SPAN></SPAN>
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN>                        Mixer API Support (winmm.dll)</SPAN>
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN> ***************************************************************************</SPAN></SPAN></SPAN>
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MMSYSERR_NOERROR = 0
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXER_SHORT_NAME_CHARS = 16
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXER_LONG_NAME_CHARS = 64
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MAXPNAMELEN = 32                  <SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN> max product name length (including NULL)</SPAN>
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MAXERRORLENGTH = 128              <SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN> max error text length (including final NULL)</SPAN>
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MM_MIXM_LINE_CHANGE = &H3D0       <SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN> mixer line change notify</SPAN>
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MM_MIXM_CONTROL_CHANGE = &H3D1    <SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN> mixer control change notify</SPAN></SPAN>
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN>
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN>   MMRESULT error return values specific to the mixer API</SPAN>
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN>
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERR_BASE = 1024
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERR_INVALLINE = (MIXERR_BASE + 0)
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERR_INVALCONTROL = (MIXERR_BASE + 1)
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERR_INVALVALUE = (MIXERR_BASE + 2)
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERR_LASTERROR = (MIXERR_BASE + 2)

<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXER_OBJECTF_HANDLE = &H80000000
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXER_OBJECTF_MIXER = &H0&
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXER_OBJECTF_HMIXER = _
    (MIXER_OBJECTF_HANDLE Or MIXER_OBJECTF_MIXER)
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXER_OBJECTF_WAVEOUT = &H10000000
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXER_OBJECTF_HWAVEOUT = _
    (MIXER_OBJECTF_HANDLE Or MIXER_OBJECTF_WAVEOUT)
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXER_OBJECTF_WAVEIN = &H20000000
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXER_OBJECTF_HWAVEIN = _
    (MIXER_OBJECTF_HANDLE Or MIXER_OBJECTF_WAVEIN)
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXER_OBJECTF_MIDIOUT = &H30000000
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXER_OBJECTF_HMIDIOUT = _
    (MIXER_OBJECTF_HANDLE Or MIXER_OBJECTF_MIDIOUT)
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXER_OBJECTF_MIDIIN = &H40000000
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXER_OBJECTF_HMIDIIN = _
    (MIXER_OBJECTF_HANDLE Or MIXER_OBJECTF_MIDIIN)
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXER_OBJECTF_AUX = &H50000000
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN>
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN>   MIXERLINE.fdwLine</SPAN>
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN>
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERLINE_LINEF_ACTIVE = &H1&
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERLINE_LINEF_DISCONNECTED = &H8000&
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERLINE_LINEF_SOURCE = &H80000000
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN>
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN>   MIXERLINE.dwComponentType</SPAN>
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN>
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERLINE_COMPONENTTYPE_DST_FIRST = &H0&
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERLINE_COMPONENTTYPE_DST_UNDEFINED = _
    (MIXERLINE_COMPONENTTYPE_DST_FIRST + 0)
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERLINE_COMPONENTTYPE_DST_DIGITAL = _
    (MIXERLINE_COMPONENTTYPE_DST_FIRST + 1)
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERLINE_COMPONENTTYPE_DST_LINE = _
    (MIXERLINE_COMPONENTTYPE_DST_FIRST + 2)
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERLINE_COMPONENTTYPE_DST_MONITOR = _
    (MIXERLINE_COMPONENTTYPE_DST_FIRST + 3)
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERLINE_COMPONENTTYPE_DST_SPEAKERS = _
    (MIXERLINE_COMPONENTTYPE_DST_FIRST + 4)
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERLINE_COMPONENTTYPE_DST_HEADPHONES = _
    (MIXERLINE_COMPONENTTYPE_DST_FIRST + 5)
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERLINE_COMPONENTTYPE_DST_TELEPHONE = _
    (MIXERLINE_COMPONENTTYPE_DST_FIRST + 6)
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERLINE_COMPONENTTYPE_DST_WAVEIN = _
    (MIXERLINE_COMPONENTTYPE_DST_FIRST + 7)</FONT>

<font face=Courier New><SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERLINE_COMPONENTTYPE_SRC_FIRST = &H1000&
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERLINE_COMPONENTTYPE_SRC_LINE = _
    (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 2)
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE = _
    (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 3)
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER = _
    (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 4)
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC = _
    (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 5)
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERLINE_COMPONENTTYPE_SRC_PCSPEAKER = _
    (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 7)
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT = _
    (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 8)
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY = _
    (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 9)
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN>
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN>   MIXERLINE.Target.dwType</SPAN>
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN>
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERLINE_TARGETTYPE_UNDEFINED = 0
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERLINE_TARGETTYPE_WAVEOUT = 1
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERLINE_TARGETTYPE_WAVEIN = 2
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERLINE_TARGETTYPE_MIDIOUT = 3
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERLINE_TARGETTYPE_MIDIIN = 4
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERLINE_TARGETTYPE_AUX = 5

<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXER_GETLINEINFOF_COMPONENTTYPE = &H3&
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN>
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN>   MIXERCONTROL.fdwControl</SPAN>
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN>
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERCONTROL_CONTROLF_UNIFORM = &H1&
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERCONTROL_CONTROLF_MULTIPLE = &H2&
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERCONTROL_CONTROLF_DISABLED = &H80000000
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN>
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN>   MIXERCONTROL_CONTROLTYPE_xxx building block defines</SPAN>
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN>
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERCONTROL_CT_CLASS_SWITCH = &H20000000
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERCONTROL_CT_CLASS_FADER = &H50000000
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERCONTROL_CT_SC_SWITCH_BOOLEAN = &H0&
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERCONTROL_CT_UNITS_BOOLEAN = &H10000
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERCONTROL_CT_UNITS_UNSIGNED = &H30000
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN>
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN>   Commonly used control types for specifying MIXERCONTROL.dwControlType</SPAN>
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN>
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERCONTROL_CONTROLTYPE_BOOLEAN = _
    (MIXERCONTROL_CT_CLASS_SWITCH Or MIXERCONTROL_CT_SC_SWITCH_BOOLEAN _
        Or MIXERCONTROL_CT_UNITS_BOOLEAN)
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERCONTROL_CONTROLTYPE_MUTE = _
    (MIXERCONTROL_CONTROLTYPE_BOOLEAN + 2)
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERCONTROL_CONTROLTYPE_FADER = _
    (MIXERCONTROL_CT_CLASS_FADER Or MIXERCONTROL_CT_UNITS_UNSIGNED)
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXERCONTROL_CONTROLTYPE_VOLUME = _
    (MIXERCONTROL_CONTROLTYPE_FADER + 1)


<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXER_GETLINECONTROLSF_ONEBYID = &H1&
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXER_GETLINECONTROLSF_ONEBYTYPE = &H2&

<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXER_GETCONTROLDETAILSF_VALUE = &H0&

<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Const</SPAN> MIXER_SETCONTROLDETAILSF_VALUE = &H0&


<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN> mixer API types</SPAN></FONT>

<font face=Courier New><SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Type</SPAN> Target    <SPAN style="color:green">' for use in MIXERLINE and others (embedded structure)</SPAN>
   dwType          <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>                 <SPAN style="color:green">'  MIXERLINE_TARGETPrivate Type_xxxx</SPAN>
   dwDeviceID      <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>                 <SPAN style="color:green">'  target device ID of device Private Type</SPAN>
   wMid            <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Integer</SPAN>              <SPAN style="color:green">'  of target device</SPAN>
   wPid            <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Integer</SPAN>              <SPAN style="color:green"><SPAN style="color:green">'       "</SPAN></SPAN>
   vDriverVersion  <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>                 <SPAN style="color:green"><SPAN style="color:green">'       "</SPAN></SPAN>
   szPname         <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">String</SPAN> * MAXPNAMELEN
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Type</SPAN>

<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Type</SPAN> MIXERLINE
   cbStruct        <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>                 <SPAN style="color:green">'  size of MIXERLINE structure</SPAN>
   dwDestination   <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>                 <SPAN style="color:green">'  zero based destination index</SPAN>
   dwSource        <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>                 <SPAN style="color:green">'  zero based source index (if source)</SPAN>
   dwLineID        <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>                 <SPAN style="color:green">'  unique line id for mixer device</SPAN>
   fdwLine         <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>                 <SPAN style="color:green">'  state/information about line</SPAN>
   dwUser          <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>                 <SPAN style="color:green">'  driver specific information</SPAN>
   dwComponentType <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>                 <SPAN style="color:green">'  component Private Type line connects to</SPAN>
   cChannels       <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>                 <SPAN style="color:green">'  number of channels line supports</SPAN>
   cConnections    <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>                 <SPAN style="color:green">'  number of connections (possible)</SPAN>
   cControls       <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>                 <SPAN style="color:green">'  number of controls at this line</SPAN>
   szShortName     <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">String</SPAN> * MIXER_SHORT_NAME_CHARS
   szName          <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">String</SPAN> * MIXER_LONG_NAME_CHARS
   tTarget         <SPAN style="color:darkblue">As</SPAN> Target
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Type</SPAN>

<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Type</SPAN> MIXERCONTROL
   cbStruct        <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>                 <SPAN style="color:green">'  size in Byte of MIXERCONTROL</SPAN>
   dwControlID     <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>                 <SPAN style="color:green">'  unique control id for mixer device</SPAN>
   dwControlType   <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>                 <SPAN style="color:green">'  MIXERCONTROL_CONTROLPrivate Type_xxx</SPAN>
   fdwControl      <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>                 <SPAN style="color:green">'  MIXERCONTROL_CONTROLF_xxx</SPAN>
   cMultipleItems  <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>                 <SPAN style="color:green">'  if MIXERCONTROL_CONTROLF_MULTIPLE set</SPAN>
   szShortName(1 To MIXER_SHORT_NAME_CHARS) <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Byte</SPAN>
   szName(1 To MIXER_LONG_NAME_CHARS) <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Byte</SPAN>
   <SPAN style="color:green">'Bounds(1 To 6)  As Long                 '  Longest member of the Bounds union</SPAN>
   <SPAN style="color:green">'Metrics(1 To 6) As Long                 '  Longest member of the Metrics union</SPAN>
   <SPAN style="color:green">' alternate defs for two items above</SPAN>
   lMinimum <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>                        <SPAN style="color:green">'  Minimum value</SPAN>
   lMaximum <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>                        <SPAN style="color:green">'  Maximum value</SPAN>
   RESERVED(10) <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>                    <SPAN style="color:green">'  reserved structure space</SPAN>
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Type</SPAN>

<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Type</SPAN> MIXERLINECONTROLS
       cbStruct        <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>             <SPAN style="color:green">'  size in Byte of MIXERLINECONTROLS</SPAN>
       dwLineID        <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>             <SPAN style="color:green">'  line id (from MIXERLINE.dwLineID)</SPAN>
                                           <SPAN style="color:green">'  MIXER_GETLINECONTROLSF_ONEBYID or</SPAN>
       dwControl       <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>             <SPAN style="color:green">'  MIXER_GETLINECONTROLSF_ONEBYPrivate Type</SPAN>
       cControls       <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>             <SPAN style="color:green">'  count of controls pmxctrl points to</SPAN>
       cbmxctrl        <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>             <SPAN style="color:green">'  size in Byte of _one_ MIXERCONTROL</SPAN>
       <SPAN style="color:green">'pamxctrl        As MIXERCONTROL     <SPAN style="color:green">'  pointer to first MIXERCONTROL array</SPAN></SPAN>
       pamxctrl        <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>             <SPAN style="color:green">'  pointer to first MIXERCONTROL array</SPAN>
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Type</SPAN>

<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Type</SPAN> MIXERCONTROLDETAILS
       cbStruct        <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>             <SPAN style="color:green"><SPAN style="color:green">'  size in Byte of MIXERCONTROL</SPAN>DETAILS</SPAN>
       dwControlID     <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>             <SPAN style="color:green">'  control id to get/set details on</SPAN>
       cChannels       <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>             <SPAN style="color:green">'  number of channels in paDetails array</SPAN>
       item            <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>             <SPAN style="color:green">'  hwndOwner or cMultipleItems</SPAN>
       cbDetails       <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>             <SPAN style="color:green">'  size of _one_ details_XX struct</SPAN>
       paDetails       <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>             <SPAN style="color:green">'  pointer to array of details_XX structs</SPAN>
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Type</SPAN>

<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Type</SPAN> MIXERCONTROLDETAILS_UNSIGNED
       dwValue <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Type</SPAN>

<SPAN style="color:green">' mixer API prototypes</SPAN>
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Declare</SPAN> <SPAN style="color:darkblue">Function</SPAN> mixerGetNumDevs <SPAN style="color:darkblue">Lib</SPAN> "winmm.dll" () <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Declare</SPAN> <SPAN style="color:darkblue">Function</SPAN> mixerOpen <SPAN style="color:darkblue">Lib</SPAN> "winmm.dll" (phmx <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>, _
    <SPAN style="color:darkblue">ByVal</SPAN> uMxId <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>, <SPAN style="color:darkblue">ByVal</SPAN> dwCallback <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>, _
        <SPAN style="color:darkblue">ByVal</SPAN> dwInstance <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>, <SPAN style="color:darkblue">ByVal</SPAN> fdwOpen <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>) <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Declare</SPAN> <SPAN style="color:darkblue">Function</SPAN> mixerClose <SPAN style="color:darkblue">Lib</SPAN> "winmm.dll" (<SPAN style="color:darkblue">ByVal</SPAN> hmx <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>) <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Declare</SPAN> <SPAN style="color:darkblue">Function</SPAN> mixerGetLineInfo <SPAN style="color:darkblue">Lib</SPAN> "winmm.dll" _
    Alias "mixerGetLineInfoA" (<SPAN style="color:darkblue">ByVal</SPAN> hmxobj <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>, pmxl <SPAN style="color:darkblue">As</SPAN> MIXERLINE, _
        <SPAN style="color:darkblue">ByVal</SPAN> fdwInfo <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>) <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Declare</SPAN> <SPAN style="color:darkblue">Function</SPAN> mixerGetLineControls <SPAN style="color:darkblue">Lib</SPAN> "winmm.dll" _
    Alias "mixerGetLineControlsA" (<SPAN style="color:darkblue">ByVal</SPAN> hmxobj <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>, pmxlc _
        <SPAN style="color:darkblue">As</SPAN> MIXERLINECONTROLS, <SPAN style="color:darkblue">ByVal</SPAN> fdwControls <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>) <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Declare</SPAN> <SPAN style="color:darkblue">Function</SPAN> mixerGetControlDetails <SPAN style="color:darkblue">Lib</SPAN> "winmm.dll" Alias _
    "mixerGetControlDetailsA" (<SPAN style="color:darkblue">ByVal</SPAN> hmxobj <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>, pmxcd As _
        MIXERCONTROLDETAILS, <SPAN style="color:darkblue">ByVal</SPAN> fdwDetails <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>) <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Declare</SPAN> <SPAN style="color:darkblue">Function</SPAN> mixerSetControlDetails <SPAN style="color:darkblue">Lib</SPAN> "winmm.dll" _
    (<SPAN style="color:darkblue">ByVal</SPAN> hmxobj <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>, pmxcd <SPAN style="color:darkblue">As</SPAN> MIXERCONTROLDETAILS, _
        <SPAN style="color:darkblue">ByVal</SPAN> fdwDetails <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>) <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>

<SPAN style="color:green">' misc API prototypes</SPAN>
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Declare</SPAN> <SPAN style="color:darkblue">Sub</SPAN> CopyStructFromPtr <SPAN style="color:darkblue">Lib</SPAN> "kernel32" Alias _
    "RtlMoveMemory" (struct <SPAN style="color:darkblue">As</SPAN> Any, <SPAN style="color:darkblue">ByVal</SPAN> ptr <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>, <SPAN style="color:darkblue">ByVal</SPAN> cb <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>)
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Declare</SPAN> <SPAN style="color:darkblue">Sub</SPAN> CopyPtrFromStruct <SPAN style="color:darkblue">Lib</SPAN> "kernel32" Alias _
    "RtlMoveMemory" (<SPAN style="color:darkblue">ByVal</SPAN> ptr <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>, struct <SPAN style="color:darkblue">As</SPAN> Any, <SPAN style="color:darkblue">ByVal</SPAN> cb <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>)
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Declare</SPAN> <SPAN style="color:darkblue">Function</SPAN> GlobalAlloc <SPAN style="color:darkblue">Lib</SPAN> "kernel32" (<SPAN style="color:darkblue">ByVal</SPAN> wFlags <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>, _
    <SPAN style="color:darkblue">ByVal</SPAN> dwBytes <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>) <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Declare</SPAN> <SPAN style="color:darkblue">Function</SPAN> GlobalLock <SPAN style="color:darkblue">Lib</SPAN> "kernel32" (<SPAN style="color:darkblue">ByVal</SPAN> hMem <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>) <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Declare</SPAN> <SPAN style="color:darkblue">Function</SPAN> GlobalFree <SPAN style="color:darkblue">Lib</SPAN> "kernel32" (<SPAN style="color:darkblue">ByVal</SPAN> hMem <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>) <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>

<SPAN style="color:darkblue">Private</SPAN> uMixerControls(20)      <SPAN style="color:darkblue">As</SPAN> MIXERCONTROL <SPAN style="color:green">' local array to store mixer controls</SPAN>
<SPAN style="color:darkblue">Private</SPAN> hMixerHandle            <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>         <SPAN style="color:green">' handle for mixer</SPAN>

<SPAN style="color:green">' enums to identify mixer volume controls</SPAN>
<SPAN style="color:darkblue">Public</SPAN> <SPAN style="color:darkblue">Enum</SPAN> VOL_CONTROL
   Speaker = 0
   LINEIN = 1
   MICROPHONE = 2
   SYNTHESIZER = 3
   COMPACTDISC = 4
   WAVEOUT = 5
   AUXILIARY = 6
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Enum</SPAN>

<SPAN style="color:green">' enums to identify mixer mute controls</SPAN>
<SPAN style="color:darkblue">Public</SPAN> <SPAN style="color:darkblue">Enum</SPAN> MUTE_CONTROL
   SPEAKER_MUTE = 7
   LINEIN_MUTE = 8
   MICROPHONE_MUTE = 9
   SYNTHESIZER_MUTE = 10
   COMPACTDISC_MUTE = 11
   WAVEOUT_MUTE = 12
   AUXILIARY_MUTE = 13
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Enum</SPAN></FONT>
 
Upvote 0
<font face=Courier New><SPAN style="color:darkblue">Public</SPAN> <SPAN style="color:darkblue">Function</SPAN> OpenMixer(<SPAN style="color:darkblue">ByVal</SPAN> MixerNumber <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>) <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
<SPAN style="color:darkblue">Dim</SPAN> ret <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>

<SPAN style="color:green">' is there a mixer available?</SPAN>
<SPAN style="color:darkblue">If</SPAN> MixerNumber < 0 <SPAN style="color:darkblue">Or</SPAN> MixerNumber > mixerGetNumDevs - 1 <SPAN style="color:darkblue">Then</SPAN> <SPAN style="color:darkblue">Exit</SPAN> <SPAN style="color:darkblue">Function</SPAN>

<SPAN style="color:green">' open the mixer</SPAN>
ret = mixerOpen(hMixerHandle, MixerNumber, 0, 0, 0)
<SPAN style="color:darkblue">If</SPAN> ret <> MMSYSERR_NOERROR <SPAN style="color:darkblue">Then</SPAN> <SPAN style="color:darkblue">Exit</SPAN> <SPAN style="color:darkblue">Function</SPAN>

<SPAN style="color:green">' get the primary line controls by name, (this does not get all of the controls).</SPAN>

<SPAN style="color:green">' speaker (master) volume</SPAN>
ret = GetMixerControl(hMixerHandle, MIXERLINE_COMPONENTTYPE_DST_SPEAKERS, _
MIXERCONTROL_CONTROLTYPE_VOLUME, uMixerControls(Speaker))
<SPAN style="color:green">' microphone volume</SPAN>
ret = GetMixerControl(hMixerHandle, MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE, _
MIXERCONTROL_CONTROLTYPE_VOLUME, uMixerControls(MICROPHONE))
<SPAN style="color:green">' Line volume</SPAN>
ret = GetMixerControl(hMixerHandle, MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY, _
MIXERCONTROL_CONTROLTYPE_VOLUME, uMixerControls(AUXILIARY))
<SPAN style="color:green">' CD volume</SPAN>
ret = GetMixerControl(hMixerHandle, MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC, _
MIXERCONTROL_CONTROLTYPE_VOLUME, uMixerControls(COMPACTDISC))
<SPAN style="color:green">' Synthesizer volume</SPAN>
ret = GetMixerControl(hMixerHandle, MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER, _
MIXERCONTROL_CONTROLTYPE_VOLUME, uMixerControls(SYNTHESIZER))
<SPAN style="color:green">' wave volume</SPAN>
ret = GetMixerControl(hMixerHandle, MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT, _
MIXERCONTROL_CONTROLTYPE_VOLUME, uMixerControls(WAVEOUT))
<SPAN style="color:green">' Aux volume</SPAN>
ret = GetMixerControl(hMixerHandle, MIXERLINE_COMPONENTTYPE_SRC_LINE, _
MIXERCONTROL_CONTROLTYPE_VOLUME, uMixerControls(LINEIN))

<SPAN style="color:green">' speaker (master) mute</SPAN>
ret = GetMixerControl(hMixerHandle, MIXERLINE_COMPONENTTYPE_DST_SPEAKERS, _
MIXERCONTROL_CONTROLTYPE_MUTE, uMixerControls(SPEAKER_MUTE))
<SPAN style="color:green">' microphone mute</SPAN>
ret = GetMixerControl(hMixerHandle, MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE, _
MIXERCONTROL_CONTROLTYPE_MUTE, uMixerControls(MICROPHONE_MUTE))
<SPAN style="color:green">' Line mute</SPAN>
ret = GetMixerControl(hMixerHandle, MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY, _
MIXERCONTROL_CONTROLTYPE_MUTE, uMixerControls(AUXILIARY_MUTE))
<SPAN style="color:green">' CD mute</SPAN>
ret = GetMixerControl(hMixerHandle, MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC, _
MIXERCONTROL_CONTROLTYPE_MUTE, uMixerControls(COMPACTDISC_MUTE))
<SPAN style="color:green">' Synthesizer mute</SPAN>
ret = GetMixerControl(hMixerHandle, MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER, _
MIXERCONTROL_CONTROLTYPE_MUTE, uMixerControls(SYNTHESIZER_MUTE))
<SPAN style="color:green">' wave mute</SPAN>
ret = GetMixerControl(hMixerHandle, MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT, _
MIXERCONTROL_CONTROLTYPE_MUTE, uMixerControls(WAVEOUT_MUTE))
<SPAN style="color:green">' Aux mute</SPAN>
ret = GetMixerControl(hMixerHandle, MIXERLINE_COMPONENTTYPE_SRC_LINE, _
MIXERCONTROL_CONTROLTYPE_MUTE, uMixerControls(LINEIN_MUTE))

<SPAN style="color:green">' return the mixer handle</SPAN>
OpenMixer = <SPAN style="color:darkblue">True</SPAN>

<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Function</SPAN>

<SPAN style="color:darkblue">Public</SPAN> <SPAN style="color:darkblue">Function</SPAN> CloseMixer() <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
CloseMixer = mixerClose(hMixerHandle)
hMixerHandle = 0
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Function</SPAN>

<SPAN style="color:darkblue">Public</SPAN> <SPAN style="color:darkblue">Function</SPAN> SetVolume(Control <SPAN style="color:darkblue">As</SPAN> VOL_CONTROL, <SPAN style="color:darkblue">ByVal</SPAN> NewVolume <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>) <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
SetVolume = SetControlValue(hMixerHandle, uMixerControls(Control), NewVolume)

<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Function</SPAN>

<SPAN style="color:darkblue">Public</SPAN> <SPAN style="color:darkblue">Function</SPAN> GetVolume(Control <SPAN style="color:darkblue">As</SPAN> VOL_CONTROL) <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
GetVolume = GetControlValue(hMixerHandle, uMixerControls(Control))

<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Function</SPAN>

<SPAN style="color:darkblue">Public</SPAN> <SPAN style="color:darkblue">Function</SPAN> SetMute(Control <SPAN style="color:darkblue">As</SPAN> MUTE_CONTROL, _
<SPAN style="color:darkblue">ByVal</SPAN> MuteState <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Boolean</SPAN>) <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Boolean</SPAN>
<SPAN style="color:darkblue">Dim</SPAN> Mute <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>

Mute = Abs(MuteState)
SetMute = SetControlValue(hMixerHandle, uMixerControls(Control), Mute)

<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Function</SPAN>

<SPAN style="color:darkblue">Public</SPAN> <SPAN style="color:darkblue">Function</SPAN> GetMute(Control <SPAN style="color:darkblue">As</SPAN> MUTE_CONTROL) <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Boolean</SPAN>
GetMute = <SPAN style="color:darkblue">CBool</SPAN>(-GetControlValue(hMixerHandle, uMixerControls(Control)))

<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Function</SPAN>

<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Function</SPAN> GetMixerControl(<SPAN style="color:darkblue">ByVal</SPAN> hMixer <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>, <SPAN style="color:darkblue">ByVal</SPAN> componentType _
<SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>, <SPAN style="color:darkblue">ByVal</SPAN> ctrlType <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>, <SPAN style="color:darkblue">ByRef</SPAN> mxc <SPAN style="color:darkblue">As</SPAN> MIXERCONTROL) <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
<SPAN style="color:green">' This function attempts to obtain a mixer control. Returns True if successful.</SPAN>
<SPAN style="color:darkblue">Dim</SPAN> mxlc <SPAN style="color:darkblue">As</SPAN> MIXERLINECONTROLS
<SPAN style="color:darkblue">Dim</SPAN> mxl <SPAN style="color:darkblue">As</SPAN> MIXERLINE
<SPAN style="color:darkblue">Dim</SPAN> hMem <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
<SPAN style="color:darkblue">Dim</SPAN> ret <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>

mxl.cbStruct = Len(mxl)
mxl.dwComponentType = componentType

<SPAN style="color:green">' Obtain a line corresponding to the component type</SPAN>
ret = mixerGetLineInfo(hMixer, mxl, MIXER_GETLINEINFOF_COMPONENTTYPE)

<SPAN style="color:darkblue">If</SPAN> ret = MMSYSERR_NOERROR <SPAN style="color:darkblue">Then</SPAN>
mxlc.cbStruct = Len(mxlc)
mxlc.dwLineID = mxl.dwLineID
mxlc.dwControl = ctrlType
mxlc.cControls = 1
mxlc.cbmxctrl = Len(mxc)

<SPAN style="color:green">' Allocate a buffer for the control</SPAN>
hMem = GlobalAlloc(&H40, Len(mxc))
mxlc.pamxctrl = GlobalLock(hMem)
mxc.cbStruct = Len(mxc)

<SPAN style="color:green">' Get the control</SPAN>
ret = mixerGetLineControls(hMixer, mxlc, MIXER_GETLINECONTROLSF_ONEBYTYPE)

<SPAN style="color:darkblue">If</SPAN> ret = MMSYSERR_NOERROR <SPAN style="color:darkblue">Then</SPAN>
GetMixerControl = <SPAN style="color:darkblue">True</SPAN>

<SPAN style="color:green">' Copy the control into the destination structure</SPAN>
CopyStructFromPtr mxc, mxlc.pamxctrl, Len(mxc)
<SPAN style="color:darkblue">Else</SPAN>
GetMixerControl = <SPAN style="color:darkblue">False</SPAN>
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">If</SPAN>
GlobalFree (hMem)
<SPAN style="color:darkblue">Exit</SPAN> <SPAN style="color:darkblue">Function</SPAN>
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">If</SPAN>

GetMixerControl = <SPAN style="color:darkblue">False</SPAN>

<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Function</SPAN>

<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Function</SPAN> SetControlValue(<SPAN style="color:darkblue">ByVal</SPAN> hMixer <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>, _
mxc <SPAN style="color:darkblue">As</SPAN> MIXERCONTROL, <SPAN style="color:darkblue">ByVal</SPAN> NewVolume <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>) <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Boolean</SPAN>
<SPAN style="color:green">'This function sets the value for a control. Returns True if successful</SPAN>
<SPAN style="color:darkblue">Dim</SPAN> mxcd <SPAN style="color:darkblue">As</SPAN> MIXERCONTROLDETAILS
<SPAN style="color:darkblue">Dim</SPAN> vol <SPAN style="color:darkblue">As</SPAN> MIXERCONTROLDETAILS_UNSIGNED
<SPAN style="color:darkblue">Dim</SPAN> hMem <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
<SPAN style="color:darkblue">Dim</SPAN> ret <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>

mxcd.item = 0
mxcd.dwControlID = mxc.dwControlID
mxcd.cbStruct = Len(mxcd)
mxcd.cbDetails = Len(vol)

<SPAN style="color:green"><SPAN style="color:green">' Allocate a buffer for the control</SPAN> value buffer</SPAN>
hMem = GlobalAlloc(&H40, Len(vol))
mxcd.paDetails = GlobalLock(hMem)
mxcd.cChannels = 1

<SPAN style="color:green">' setup value, use percent of range if max is greater than 100</SPAN>
<SPAN style="color:darkblue">If</SPAN> mxc.lMaximum > 100 <SPAN style="color:darkblue">Then</SPAN>
vol.dwValue = NewVolume * (mxc.lMaximum \ 100)
<SPAN style="color:darkblue">Else</SPAN>
vol.dwValue = NewVolume
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">If</SPAN>
<SPAN style="color:darkblue">If</SPAN> vol.dwValue > mxc.lMaximum <SPAN style="color:darkblue">Then</SPAN> vol.dwValue = mxc.lMaximum
<SPAN style="color:darkblue">If</SPAN> vol.dwValue < mxc.lMinimum <SPAN style="color:darkblue">Then</SPAN> vol.dwValue = mxc.lMinimum

<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">' Copy the data into the control value buffer</SPAN></SPAN></SPAN>
CopyPtrFromStruct mxcd.paDetails, vol, Len(vol)

<SPAN style="color:green">' Set the control value</SPAN>
ret = mixerSetControlDetails(hMixer, mxcd, MIXER_SETCONTROLDETAILSF_VALUE)
GlobalFree (hMem)

<SPAN style="color:darkblue">If</SPAN> ret = MMSYSERR_NOERROR <SPAN style="color:darkblue">Then</SPAN> SetControlValue = <SPAN style="color:darkblue">True</SPAN>

<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Function</SPAN>

<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Function</SPAN> GetControlValue(<SPAN style="color:darkblue">ByVal</SPAN> hMixer <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>, mxc <SPAN style="color:darkblue">As</SPAN> MIXERCONTROL) _
<SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
<SPAN style="color:green">'This function gets the value for a control.</SPAN>
<SPAN style="color:darkblue">Dim</SPAN> mxcd <SPAN style="color:darkblue">As</SPAN> MIXERCONTROLDETAILS
<SPAN style="color:darkblue">Dim</SPAN> vol <SPAN style="color:darkblue">As</SPAN> MIXERCONTROLDETAILS_UNSIGNED
<SPAN style="color:darkblue">Dim</SPAN> hMem <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
<SPAN style="color:darkblue">Dim</SPAN> ret <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>

mxcd.item = 0
mxcd.dwControlID = mxc.dwControlID
mxcd.cbStruct = Len(mxcd)
mxcd.cbDetails = Len(vol)

hMem = GlobalAlloc(&H40, Len(vol))
mxcd.paDetails = GlobalLock(hMem)
mxcd.cChannels = 1

<SPAN style="color:green"><SPAN style="color:green">' Get the control</SPAN> value</SPAN>
ret = mixerGetControlDetails(hMixer, mxcd, MIXER_GETCONTROLDETAILSF_VALUE)

<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">' Copy the data into the control value buffer</SPAN></SPAN></SPAN>
CopyStructFromPtr vol, mxcd.paDetails, Len(vol)

<SPAN style="color:darkblue">If</SPAN> mxc.lMaximum > 100 <SPAN style="color:darkblue">Then</SPAN>
GetControlValue = (vol.dwValue * 100) / mxc.lMaximum - mxc.lMinimum
<SPAN style="color:darkblue">Else</SPAN>
GetControlValue = vol.dwValue
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">If</SPAN>

GlobalFree (hMem)

<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Function</SPAN></FONT>

________________________________________________________________________


<font face=Courier New><SPAN style="color:darkblue">Sub</SPAN> AdjVolume()
<SPAN style="color:darkblue">Dim</SPAN> y <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Boolean</SPAN>, z <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Boolean</SPAN>, a <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>, b <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
<SPAN style="color:darkblue">Call</SPAN> OpenMixer(0)
<SPAN style="color:darkblue">Let</SPAN> y = GetMute(SPEAKER_MUTE): <SPAN style="color:darkblue">Let</SPAN> z = GetMute(WAVEOUT_MUTE)
<SPAN style="color:darkblue">Let</SPAN> a = GetVolume(WAVEOUT): <SPAN style="color:darkblue">Let</SPAN> b = GetVolume(Speaker)

<SPAN style="color:darkblue">Call</SPAN> SetMute(SPEAKER_MUTE, <SPAN style="color:darkblue">False</SPAN>): <SPAN style="color:darkblue">Call</SPAN> SetMute(WAVEOUT_MUTE, <SPAN style="color:darkblue">False</SPAN>)
<SPAN style="color:darkblue">Call</SPAN> SetVolume(Speaker, 100): <SPAN style="color:darkblue">Call</SPAN> SetVolume(WAVEOUT, 100)

<SPAN style="color:green">'Play Your Song Here</SPAN>

Application.Wait Now + TimeSerial(0, 0, 5)
<SPAN style="color:green">'Delay before resetting sound settings</SPAN>

<SPAN style="color:darkblue">Call</SPAN> SetMute(SPEAKER_MUTE, y): <SPAN style="color:darkblue">Call</SPAN> SetMute(WAVEOUT_MUTE, z)
<SPAN style="color:darkblue">Call</SPAN> SetVolume(WAVEOUT, a): <SPAN style="color:darkblue">Call</SPAN> SetVolume(Speaker, b)
<SPAN style="color:darkblue">Call</SPAN> CloseMixer
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Sub</SPAN>
</FONT>
 
Upvote 0
Hi,
I found this solution from Juan but I can't seem to get it to work when I open a workbook.

Where should I place the code or do I need to add any more code?

Thanks

Nimo
 
Upvote 0

Forum statistics

Threads
1,223,249
Messages
6,171,031
Members
452,374
Latest member
keccles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top