Simple Mixer Control Wrapper

Environment: VC6, Unicode

This is small and usefull C++ class which can encapsulate any windows multimedia mixer control. I wrote a simple class, named CAlexfMixer which can wrap any multimedia mixer control. You can manipulate with Master Volume, Mute or someone else mixer control with this class if control support this operations. You can retrieve information from Peak Meter and other controls like this.

There is some mixers here, but all of them are not so clear, simple and universal like my own... ;-)

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 callback window. The class has the member IsOk() to check ability of manipulation of specified control and members to get and set control state.

Using the class.

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 object associated with Master Volume meter control. Third parameter - NO_SOURCE - is a constant, defined in .h file, it mean than control have not a source line but only destination line. Second we check - is this type of control available or not? Third - if yes we set volume to 500.

Example 2. Master Mute.


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

Here we create object associated with Master Mute control. And next we switch it off.

Check for latest versions at http://members.xoom.com/lamer2000/.

Downloads

Download source - 3 Kb


Comments

  • This is Cool, but...

    Posted by Jerronimo on 05/27/2006 05:59pm

    Hello, nice job, this is similar to what i am looking for. I need a piece of soft to switch between audio devices. I have a rear and a front driver, just like i had two sound cards. But only one can be set as default so when i want to put my headphones i must goto ControlPanet->... etc. Could you please tell me how to change DEFAULT device to another? Should i go looking something about rundll32.exe? And where to look (a book?)? Any ideas?

    Reply
  • Good!!!

    Posted by Legacy on 10/13/2003 12:00am

    Originally posted by: Stefano Vaccari

    I found it very useful. Thanks a lot.

    Reply
  • Very good!

    Posted by Legacy on 10/29/2001 12:00am

    Originally posted by: Rogerio Silva

    Thank you !
    

    Reply
  • Where is Demo Project Source?

    Posted by Legacy on 10/08/2000 12:00am

    Originally posted by: hosang

    Where is Demo Project Source?

    Reply
  • Functions do nothing

    Posted by Legacy on 09/22/2000 12:00am

    Originally posted by: Clinton Morell

    I compiled a program using the demo examples and ran the demo code. Nothing happened. The volume level remained unchanged and unmuted.

    I am using the VC5.0 compiler; perhaps this code has no effect when compiled under v5.0.

    Reply
  • My mixer's maximum value is 65535

    Posted by Legacy on 03/29/2000 12:00am

    Originally posted by: Wuncheol Heo

    At first time, my program always set volume to zero.
    I try to find what's wrong. at last I know I set volume value to low (500 <- this value is from your example). My mixer's maximum is 65535 (0xffff).

    so I have one question.
    All mixer has maximum 65535 ? or differ each other?

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Learn How A Global Entertainment Company Saw a 448% ROI Every business today uses software to manage systems, deliver products, and empower employees to do their jobs. But software inevitably breaks, and when it does, businesses lose money -- in the form of dissatisfied customers, missed SLAs or lost productivity. PagerDuty, an operations performance platform, solves this problem by helping operations engineers and developers more effectively manage and resolve incidents across a company's global operations. …

  • Live Event Date: December 18, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT The Internet of Things (IoT) incorporates physical devices into business processes using predictive analytics. While it relies heavily on existing Internet technologies, it differs by including physical devices, specialized protocols, physical analytics, and a unique partner network. To capture the real business value of IoT, the industry must move beyond customized projects to general patterns and platforms. Check out this upcoming webcast …

Most Popular Programming Stories

More for Developers

RSS Feeds