How to set master volume?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: How to set master volume?

  1. #1
    Join Date
    Mar 2008
    Posts
    18

    How to set master volume?

    I'm trying to find a function that will be able to set the master volume and turn it on/off. Is there a function like waveOutSetVolume, but works for the master volume? thx

  2. #2
    Join Date
    Mar 2008
    Posts
    18

    Re: How to set master volume?

    Can anyone tell me why this code isn't working? It's supposed to mute the master volume.

    #include <cstdlib>
    #include <iostream>
    #include <windows.h>

    using namespace std;

    int main(int argc, char *argv[])
    {
    MMRESULT result;
    HMIXER hMixer;
    result = mixerOpen(&hMixer, MIXER_OBJECTF_MIXER, 0, 0, 0);
    MIXERLINE ml = {0};
    ml.cbStruct = sizeof(MIXERLINE);
    ml.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;
    result = mixerGetLineInfo((HMIXEROBJ) hMixer,
    &ml, MIXER_GETLINEINFOF_COMPONENTTYPE);
    MIXERLINECONTROLS mlc = {0};
    MIXERCONTROL mc = {0};
    mlc.cbStruct = sizeof(MIXERLINECONTROLS);
    mlc.dwLineID = ml.dwLineID;
    mlc.dwControlType = MIXERCONTROL_CONTROLTYPE_MUTE;
    mlc.cControls = 1;
    mlc.pamxctrl = &mc;
    mlc.cbmxctrl = sizeof(MIXERCONTROL);
    result = mixerGetLineControls((HMIXEROBJ) hMixer,
    &mlc, MIXER_GETLINECONTROLSF_ONEBYTYPE);
    MIXERCONTROLDETAILS mcd = {0};
    MIXERCONTROLDETAILS_BOOLEAN mcb = {0};
    mcb.fValue = true; //true for mute, false for unmute
    mcd.paDetails = &mcb;
    mcd.cbDetails = sizeof(MIXERCONTROLDETAILS_BOOLEAN);
    result = mixerSetControlDetails((HMIXEROBJ) hMixer,
    &mcd, MIXER_SETCONTROLDETAILSF_VALUE);
    return 0;
    }

  3. #3
    Join Date
    Jun 2006
    Location
    M31
    Posts
    885

    Re: How to set master volume?

    Quote Originally Posted by C++N00bie
    Can anyone tell me why this code isn't working? It's supposed to mute the master volume.
    Why are you still not using code tags?

    Anyhow, check the value of result and see what error it corresponds to.

  4. #4
    Join Date
    Mar 2016
    Posts
    1

    Re: How to set master volume?

    hey....i wanted to access my master volume using Qt which uses c++. Could you please post your code if its working. Thanks....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This a Codeguru.com survey!


HTML5 Development Center