The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: sjums on January 19, 2011, 12:22:22 PM

Title: winmm.lib
Post by: sjums on January 19, 2011, 12:22:22 PM
hello, again, my dears :)

last time i got great help.. this time i think i have a harder question :p

i wan't to set the volume in windows.. but can't fingure out something ^^

So far what I've found out is that i need the lib winmm.lib and invoke the waveOutSetVolume call :) http://msdn.microsoft.com/en-us/library/aa908146.aspx

but how do i get the HWAVEOUT handle to make the call ?

or am I totally wrong on it?

i don't have much code.. but this is what i got :)


.386
.model flat, stdcall
option casemap :none

include \masm32\include\masm32.inc
include \masm32\include\winmm.inc

includelib \masm32\lib\masm32.lib
includelib \masm32\lib\winmm.lib


.data
vol dw 100h,100h
.code
start:

invoke waveOutSetVolume, NULL, addr vol
invoke ExitProcess, 0
end start

Title: Re: winmm.lib
Post by: oex on January 19, 2011, 12:44:59 PM
You probably dont need it.... NULL should work unless you want to specify a non default device....

   .if rv(waveOutGetVolume, NULL, ADDR oexOldVolume) == MMSYSERR_NOERROR
      invoke waveOutSetVolume, 0, oexVolume
   .endif
Title: Re: winmm.lib
Post by: sjums on January 19, 2011, 01:07:38 PM
NULL doesnt work, with that I mean,it doesn't change the volume

The program assemble and link with no errors and run to end with no crashes, but I'll try with 0 (zero) when I get home :)

Looks like what you did in the example.

Also, it's the master I'm trying to change, so it's. Not some specific device :)
Title: Re: winmm.lib
Post by: dedndave on January 19, 2011, 01:16:47 PM
Bill Craven gives an example in masm32\examples\bcraven\mvolume
Title: Re: winmm.lib
Post by: oex on January 19, 2011, 02:05:58 PM
The master volume is different from the wave volume.... Use Dave's example above ^ to manage the master volume....

The wave volume will work on playback of a wave file so long as the DWORD parameter is in the WORD range for right and left speakers.... I dont manually set DWORDs like above but it looks wrong to me....

Is that
vol dw 100h,100h
2 * 256 WORD values?

If so that will barely be audable.... 0FFFFh,0FFFFh is full volume (range 0-65,535)
Title: Re: winmm.lib
Post by: sjums on January 19, 2011, 04:33:08 PM
just to be sure, when you invoke something, the return value will be in the eax register?
Title: Re: winmm.lib
Post by: Gunner on January 19, 2011, 04:36:10 PM
Yes, majority of the time the return value is in eax.  but it could be in any register really....  you should always check the docs for the function.
Title: Re: winmm.lib
Post by: sjums on January 20, 2011, 02:53:55 PM
problem not solved. The solution is in the example dave refers to, but I'm still a bit too noob to fully understand it :)

but thanks for coming with the solution... now i just need to be ready for it :)
Title: Re: winmm.lib
Post by: dedndave on January 20, 2011, 04:01:43 PM
it's cool
just post the code, as you have it
you can add an attachment to your post below the reply window
it must be a ZIP file - or, at least, it must have a ZIP extension