The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: Mr Earl on September 28, 2005, 09:45:26 PM

Title: Speaker Volume Setting
Post by: Mr Earl on September 28, 2005, 09:45:26 PM
Is there an API to GET the current speaker volume setting?
Title: Re: Speaker Volume Setting
Post by: Farabi on September 29, 2005, 10:47:35 AM
WinMM. I take this code from MASM example.


;Code by Wiliam F.
GetMasterVolume proc

        invoke mixerOpen,ADDR MixerHandle,0,0,0,0
        .if eax == MMSYSERR_NOERROR
            mov mxlc.cbStruct,SIZEOF mxlc
            mov mxlc.dwLineID,SPEAKEROUTLINEID
            mov mxlc.dwControlType,MIXERCONTROL_CONTROLTYPE_VOLUME
            mov mxlc.cControls,1
            mov mxlc.cbmxctrl,SIZEOF mxc
            mov mxlc.pamxctrl,OFFSET mxc
            invoke mixerGetLineControls,MixerHandle,ADDR mxlc,MIXER_GETLINECONTROLSF_ONEBYTYPE
            mov eax,mxc.dwControlID
            mov VolCtlIDMtr,eax
            mov mxcdVol.dwValue,1
            mov mxcd.cbStruct,SIZEOF mxcd
            mov eax,VolCtlIDMtr 
            mov mxcd.dwControlID,eax
            mov mxcd.cChannels,1
            mov mxcd.cMultipleItems,0
            mov mxcd.cbDetails,SIZEOF mxcdVol
            mov mxcd.paDetails,OFFSET mxcdVol
            invoke mixerGetControlDetails,MixerHandle,ADDR mxcd,MIXER_GETCONTROLDETAILSF_VALUE
            mov eax,mxcdVol[0].dwValue
        .else
            mov eax,MIXER_ERROR
        .endif
        ret

GetMasterVolume endp
   
; ###############################################################

SetMasterVolume proc VolValue:DWORD

        mov eax,VolValue
        mov mxcdVol[0].dwValue,eax
        mov mxcd.cbStruct,SIZEOF mxcd
        mov eax,VolCtlIDMtr
        mov mxcd.dwControlID,eax
        mov mxcd.cChannels,1
        mov mxcd.cMultipleItems,0
        mov mxcd.cbDetails,SIZEOF mxcdVol
        mov mxcd.paDetails,OFFSET mxcdVol
        invoke mixerSetControlDetails,MixerHandle,ADDR mxcd,MIXER_GETCONTROLDETAILSF_VALUE
        .if eax == MMSYSERR_NOERROR
            mov eax,0
        .else
            mov eax,MIXER_ERROR
        .endif           
        ret

SetMasterVolume endp

; ###############################################################

CloseMasterVolume proc

        invoke mixerClose,ADDR MixerHandle
        ret

CloseMasterVolume endp


But I cannot get this code to work.
Title: Re: Speaker Volume Setting
Post by: Mr Earl on September 30, 2005, 10:09:16 AM
Thanks Farabi, it gives me a start .
Title: Re: Speaker Volume Setting
Post by: dougiem on October 01, 2005, 10:23:57 AM
This is a modified version of the 'VolCtrl' in the Masm examples. You now can specify which control of the mixer you want to adjust.
I hope this is of some use.
dougiem.

[attachment deleted by admin]
Title: Re: Speaker Volume Setting
Post by: Mr Earl on October 01, 2005, 01:32:43 PM
Thanks dougiem.  EXACTLY what I needed.  Works great.