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

IT Offers

Comments

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

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

Go Deeper

  • When the economy is stable, a company's IT organization may view Finance as just one of many internal customers competing for attention. But …
  • Spend Less and Get More with Today's New Unified Enterprise IT Monitoring Solutions Live Event Date: May 28, 2013 @ 2:00 pm ET / 11:00 am …
  • Increasing demands placed on IT, along with tightening budgets has prompted IT leaders to seek out alternative technologies and improved …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds