Click here to Skip to main content
Click here to Skip to main content
Go to top

Simple Mixer Control Wrapper

, 9 Jan 2000
Rate this:
Please Sign up or sign in to vote.
A small audio mixer control wrapper
  • Download source files - 2.7 Kb
  • <!-- Article Starts -->

    This is small and useful C++ class which can encapsulate any windows multimedia mixer control.

    I wrote a simple class CAlexfMixer to wrap any multimedia mixer control. You can manipulate the Master Volume, Mute or someone elses mixer control with this class, as long as the control support these operations. You can also retrieve information such as the Peak Meter.

    Let's look at class definition:

    class CAlexfMixer
    {
    protected:
      HMIXER m_HMixer;
      INT m_iMixerControlID;
      MMRESULT mmr;
      DWORD m_dwChannels;
      BOOL m_bSuccess;
      void ZeroAll();
    public:
      BOOL IsOk() {return m_bSuccess;};
      BOOL On();
      BOOL Off();
      DWORD GetControlValue();
      BOOL SetControlValue(DWORD dw);
      CAlexfMixer(DWORD DstType, DWORD SrcType, DWORD ControlType);
      CAlexfMixer(HWND hwnd, DWORD DstType, DWORD SrcType, DWORD ControlType);
      virtual ~CAlexfMixer();
    };
    

    The class has two constructors - with and without the callback window.

    The class has member IsOk to check whether the specified control can be manipulated, and member functions to get and set the control's state.

    How it works

    Example 1. Master Volume Control.

    CAlexfMixer mixer(m_hWnd, MIXERLINE_COMPONENTTYPE_DST_SPEAKERS,
                      NO_SOURCE, MIXERCONTROL_CONTROLTYPE_VOLUME);
    if (!mixer.IsOk()) 
       return;
    
    mixer.SetControlValue(500);
    

    First we create an object associated with the Master Volume meter control. The third parameter NO_SOURCE is a constant defined in the header file. It means that the control does not have a source line, only a destination line.

    Second we check if is this type of control available or not.

    Finally, we set the volume to 500.

    Example 2. Master Mute.

    CAlexfMixer mixer(MIXERLINE_COMPONENTTYPE_DST_SPEAKERS,
                      NO_SOURCE, MIXERCONTROL_CONTROLTYPE_MUTE );
    mixer.Off();
    

    Here we create an object associated with Master Mute control, and turn it off.

    License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here

    Share

    About the Author

    Alexander Fedorov
    Web Developer SEO
    Ukraine Ukraine
    AlexF's Blog in Russian
    Owner Spy competition analysis
    Rating Burner Rating of blogs

    Comments and Discussions

     
    Questioncan u guide me i am new for mixer control Pinmemberrajneshmalik30-Aug-07 2:18 
    GeneralNo Mixer Present!!! PinmemberDexterND14-May-07 1:45 
    QuestionHow to choose FrontPanel MIC or BackPanel MIC? Pinmemberguzeliang10-Oct-06 15:42 
    AnswerRe: How to choose FrontPanel MIC or BackPanel MIC? Pinmemberguzeliang11-Oct-06 17:09 
    GeneralHow did you solve that problem? Pinmembercheong junhwan26-Aug-07 23:50 
    GeneralNEW VERSION Pinmemberuwgmxbscdb@mailinator.com21-Apr-06 15:43 
    GeneralMute or Pause Sounds from other Applications PinmemberSuntai7-Feb-06 2:04 
    Generalmodify change fault code PinmemberJS Lee1-May-05 19:25 
    GeneralForget My Email,Sorry! Pinmemberpeposi30-Aug-04 22:12 
    GeneralI Can not Download you code! Pinmemberpeposi30-Aug-04 22:01 
    GeneralPeak Meter not working PinmemberAtif Goheer19-Nov-03 7:38 
    GeneralRe: Peak Meter not working PinmemberAkikoAkikoChan17-Oct-04 17:44 
    GeneralControlling mic loudness PinsussIn-Chul, Yang24-Jul-03 17:07 
    GeneralRe: Controlling mic loudness PinmemberFBKK12-Sep-06 22:57 
    QuestionSolved balance problem? Pinmembergeert jacobs8-May-03 22:39 
    AnswerRe: Solved balance problem? Pinmembergeert jacobs8-May-03 22:57 
    GeneralRe: Solved balance problem? PinmemberAkikoAkikoChan17-Oct-04 17:42 
    AnswerRe: Solved balance problem? [modified] PinmemberultraVBCoder25-Jun-06 17:26 
    GeneralCallback handling Pinmemberrjo290928-Apr-03 18:43 
    Questionhow to close Aux? PinmemberTangQin24-Feb-03 20:44 
    AnswerRe: how to close Aux? PinmemberTangQin24-Feb-03 21:06 
    GeneralUnmute does not work. PinmemberJobe14-Jan-03 4:08 
    GeneralRe: Unmute does not work. PinmemberJobe14-Jan-03 5:11 
    GeneralRe: Unmute does not work to wave too PinmemberBurgao24-Dec-04 8:32 
    GeneralRe: Unmute does not work to wave too Pinmembersabit23-Jun-06 18:10 
    Generalexcuse me PinmemberNeverGrief21-Nov-02 6:37 
    GeneralQuestion about using this class PinsussAnonymous20-Aug-02 3:22 
    QuestionAbout Recording Control? PinsussAnonymous8-Aug-02 20:26 
    AnswerRe: About Recording Control? PinsussAnonymous11-Aug-02 5:43 
    Generalmix several wav fils PinmemberER__6-Jan-02 9:55 
    GeneralRe: mix several wav fils PinmemberPeteCIS5-Feb-02 7:47 
    GeneralRe: mix several wav fils Pinmembermice16-Aug-02 22:54 
    GeneralRe: mix several wav fils Pinmemberbegray14-Oct-05 21:45 
    GeneralGREAT! And yet so simple! Amazing PinmemberPeter B. Hardwick3-Oct-01 16:54 
    GeneralDoes not work PinmemberAnonymous2-Jul-01 10:30 
    GeneralRecording information Pinmemberroland22-Nov-00 6:14 
    GeneralWhere can i Find...... PinsussJon13-Jul-00 5:18 
    Where can i find some information about Multimedia programming with MFC. I really need to know about CD Audio.
     
    Than
    GeneralIt's very nice Pinsussalex11-Jan-00 22:04 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

    | Advertise | Privacy | Mobile
    Web03 | 2.8.140926.1 | Last Updated 10 Jan 2000
    Article Copyright 2000 by Alexander Fedorov
    Everything else Copyright © CodeProject, 1999-2014
    Terms of Service
    Layout: fixed | fluid