Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Muting the master volume with Win API

Author
Message
Kelebrindae
21
Years of Service
User Offline
Joined: 15th Sep 2003
Location: Where cheeses are scarier than dragons.
Posted: 29th Oct 2004 19:26
Hi,
I need some help. My purpose is to mute and "un-mute" the Windows master volume by using the Windows API in "winmm.dll".

Determining the structures used in the DLL and translating a piece of code found in a forum into DBC was quite a pain, but after an hour or two, success was mine.

Well, that's what I thought. Though my code seems to find the mixer handle, the "master volume" line and the "Mute" control, when I try to set the value, it affects the "wave out" line.

I put my code under the "Source" button.
Is there an API Guru out there to help me ?

P.S.: (Yeah, I know it would be easier to double-clik on the little speaker in the taskbar, but this is not what I want...)

Ideas: memories of things which did not occur yet...
Kelebrindae
21
Years of Service
User Offline
Joined: 15th Sep 2003
Location: Where cheeses are scarier than dragons.
Posted: 4th Nov 2004 16:04
Nobody ?

Please, any advice will be welcome...

Ideas: memories of things which did not occur yet...
blanky
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: ./
Posted: 6th Nov 2004 03:45
It's not gonna work! (Well, not on Win9x (i think)...)

The sound is coming out through DirectSound.

Winmm.dll is the other way of playing sounds 'n' sods 'n' stuff, which uses the waveOut line, whilst DirectSound skips happily away to the sunset with it's own volume line.

You have to somehow get a handle on DB's DirectSound objects. Maybe through DLLs, maybe not...

Use the built-in DB commands:

function SetAllVolume(maxSoundNumUsed, vol)

For i=1 To maxSoundNumUsed
if sound exist(i) then set sound volume vol
Next i

endfunction



If your sounds are all at different volumes, you could make an array that remembers all their volumes, and a function to set them all back again. But if all your sounds' volumes are left alone:

To mute:
SetAllVolume(200OrWhatever, 0)

To unMute:
SetAllVolume(200OrWhatever, Whatever)

You probably knew this, but sum1's gotta find it useful..

[img src=http://blanky.pt-web.net/ddd.gif] >::p
Kelebrindae
21
Years of Service
User Offline
Joined: 15th Sep 2003
Location: Where cheeses are scarier than dragons.
Posted: 8th Nov 2004 18:48
Well, thanks Blanky, but this is not what I wanna do.

I want to check/uncheck the "Mute" control in the Window Mixer panel. My purpose is to play a sound that will be heard even if the user has muted the master volume on its PC...

It's for a prank: I send my program to a friend at work, he opens it and it plays an embarassing sound really loud in his office; no harm done, just a few laughes from his co-workers...

As a matter of fact, the code works: it uncheck the "mute" box if the mixer; but instead of muting the master volume, it mutes the waveout volume...

Can anyone run the code to tell me if it acts the same ?

Ideas: memories of things which did not occur yet...
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 9th Nov 2004 14:15
Kel,
I get the same results.

With both Master and Wave muted, it un-mutes the Wave only

Have you tried researching MSDN to find information on how it should work? Maybe there's something that you're not doing to grab the Master Volume control?

Jess.


Team EOD :: Programmer/All-Round Nice Guy
Aust. Convention!
Kelebrindae
21
Years of Service
User Offline
Joined: 15th Sep 2003
Location: Where cheeses are scarier than dragons.
Posted: 9th Nov 2004 15:54
Well, I guess I'll have to search the MSDN knowledge base, or some API forums...

Thanks for your help, Jess.

Ideas: memories of things which did not occur yet...

Login to post a reply

Server time is: 2025-05-24 12:34:28
Your offset time is: 2025-05-24 12:34:28