Jump to content
  • Advertisement
Sign in to follow this  
Doggan

Muting the System Sound from an app

This topic is 4827 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a button in my options menu to disable the sound. It can be toggled on/off during gameplay. I am using OpenAL. I don't want to kill all active sounds currently playing, I just want to actually MUTE the system sound, so that when it turns back on, all previously playing sounds will still be playing. Is there a function that will let me do this? Thanks. edit: OS = WindowsXP, Language = C++

Share this post


Link to post
Share on other sites
Advertisement
Check out Windows SDK at MSDN.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sdkintro/sdkintro/devdoc_platform_software_development_kit_start_page.asp

Check out my website for software development links.

http://www.dslextreme.com/users/kuphryn/links.html

Kuphryn

Share this post


Link to post
Share on other sites
You might want to be carefull when playing with someone's system sound settings. I got in trouble for that with my first game's beta a few years ago. Problem was that if it crashed, it didn't restore the settings to their original values, so...

Anyway, what if you set the position value in OpenAL for something really far away... wouldn't that effectivly mute the sound?

Share this post


Link to post
Share on other sites
Quote:
Original post by Sam Gamgee
Anyway, what if you set the position value in OpenAL for something really far away... wouldn't that effectivly mute the sound?


Sounds a bit hackish, but it works. Easy to implement too :P Thanks for the replies.

Share this post


Link to post
Share on other sites
I haven't used OpenAL enough to know how it works but what I've done in the past using (FMod and Miles) is that if there is not global mute function, you can emulate it by setting the master volume to 0 or iterating through all sounds and manually muting them (and in your play sound function, be sure to immediately mute any new sound).

Share this post


Link to post
Share on other sites
Here's how to mute the system mixer using the Win32 API:

#include<windows.h>
#include<mmsystem.h>

//Mutes the system mixer
void mute()
{
MIXERLINE mixer_line_info; //Structure for info regarding a mixer line
mixer_line_info.cbStruct=sizeof(MIXERLINE);
mixer_line_info.dwDestination=0;
mixerGetLineInfo(NULL,&mixer_line_info,MIXER_GETLINEINFOF_DESTINATION); //Get mixer line ID


//Structure for info regarding a line control (mute control in this case)
MIXERLINECONTROLS mixer_line_ctrl_info;

mixer_line_ctrl_info.cbStruct=sizeof(MIXERLINECONTROLS);
mixer_line_ctrl_info.dwLineID=mixer_line_info.dwLineID;
mixer_line_ctrl_info.dwControlType=MIXERCONTROL_CONTROLTYPE_MUTE;
mixer_line_ctrl_info.cControls=1;
mixer_line_ctrl_info.cbmxctrl=sizeof(MIXERCONTROL);

MIXERCONTROL mixer_ctrl_info; //Structure for info regarding the mixer control

mixer_line_ctrl_info.pamxctrl=&mixer_ctrl_info;

/*Get the ID of the mixer line control of interest (mute control)*/
mixerGetLineControls(NULL,&mixer_line_ctrl_info,MIXER_GETLINECONTROLSF_ONEBYTYPE);

//Structure containing the flag used to set the new mixer mute state
MIXERCONTROLDETAILS_BOOLEAN mute_state;

mute_state.fValue=true;

//Structure of details regarding the control that is about to be changed
MIXERCONTROLDETAILS control_details;

control_details.cbStruct=sizeof(MIXERCONTROLDETAILS);
control_details.dwControlID=mixer_ctrl_info.dwControlID;
control_details.cChannels=1;
control_details.cMultipleItems=0;
control_details.cbDetails=sizeof(MIXERCONTROLDETAILS_BOOLEAN);
control_details.paDetails=&mute_state;

/*Mute system mixer*/
mixerSetControlDetails(NULL,&control_details,MIXER_GETCONTROLDETAILSF_VALUE);
}




I hope you'll forgive me for the poor commenting and formatting, but it's rather late around these parts.[smile]

EDIT: I had forgotten to include the appropriate header. Code updated.

[Edited by - shuma-gorath on July 9, 2005 12:43:13 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!