Simple Mixer Control Wrapper | CodeGuru

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 […]

Written By
CodeGuru Staff
CodeGuru Staff
Jan 22, 2000
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

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

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.