dcsimg

Simple Mixer Control Wrapper

WEBINAR:
On-Demand

Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame


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

  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

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

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date