News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Speaker Volume Setting

Started by Mr Earl, September 28, 2005, 09:45:26 PM

Previous topic - Next topic

Mr Earl

Is there an API to GET the current speaker volume setting?

Farabi

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.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Mr Earl

Thanks Farabi, it gives me a start .

dougiem

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]

Mr Earl

Thanks dougiem.  EXACTLY what I needed.  Works great.