Click here to Skip to main content
15,892,480 members
Articles / Desktop Programming / Win32

Windows Audio Mixer API Wrapper Library

Rate me:
Please Sign up or sign in to vote.
4.11/5 (12 votes)
20 Oct 2008CPOL5 min read 122.6K   5K   27  
A small wrapper library to programmatically interact with standard audio controls
// -----------------------------------------------------------------------------
// ControlGroup.h
//
//  Copyright (C) 2008 Peter C. Studt
//
//  This software is provided 'as-is', without any express or implied
//  warranty.  In no event will the author be held liable for any damages
//  arising from the use of this software. It can be redistributed and/or 
//  modified under the terms of The Code Project Open License (CPOL)
//
// -----------------------------------------------------------------------------
#pragma once

#include <afxmt.h>
#include "..\AudioMixerAPI\Mixer.h"
#include "MixerSliderCtrl.h"
#include "MixerSliderHorz.h"
#include "MixerCheckBoxMute.h"

// -----------------------------------------------------------------------------
class CControlGroup
{
public:
	CControlGroup(void);
	virtual ~CControlGroup(void);

	int CreateControls( CMixer* pCMixer, int destIndex, CWnd* pcWnd, 
						int offsetX, int offsetY, unsigned int resourceID ) ;
	int UpdateMixerControlState( unsigned int winCtrlID ) ;
	int UpdateWinControlState( unsigned int mixerID ) ;

protected:
	struct sChannelData {
		sStateData stateData ;
		int nChannels ;
	} ;

	void InitGroupLabel(   CString csText, int nGroup, int offsetX, int offsetY ) ;
	void InitBalanceLabel( CString csText, int nGroup, int offsetX, int offsetY ) ;
	void InitVolLabel(     CString csText, int nGroup, int offsetX, int offsetY ) ;
	int  InitBalSlider( MIXERCONTROL mixerControl, sChannelData channelData, int nGroup, int offsetX, int offsetY ) ;
	int  InitVolSlider( MIXERCONTROL mixerControl, sChannelData channelData, int nGroup, int offsetX, int offsetY ) ;
	int  InitCheckBox(  MIXERCONTROL mixerControl, sChannelData channelData, int nGroup, int offsetX, int offsetY ) ;
	void GetDestTargetTypeStr( DWORD dwType, CString& strType ) ;
	int  GetControlsForID( unsigned int groupIndex, CMixerSliderCtrl** pVolCtrl, 
						   CMixerSliderHorz** pBalCtrl, CMixerCheckBoxMute** pMuteCtrl ) ;

	CMixer* mpCMixer ;
	CWnd* mpcWnd ;
	int mDestID ;
	int mConnID ;
	int mOffsetX ;
	int mOffsetY ;
	int mnGroups ; 
	unsigned int nextResourceID ;

	enum ctrlType {
		Bal = 0, 
		Vol, 
		Mute
	} ;

	struct sCtrl_LUT {
		unsigned int winCtrlID ;
		unsigned int mixerCtrlID ;
		unsigned int groupIndex ;
		ctrlType	 CtrlType ;	
		CWnd*		 cWnd ;
	} ;

	sCtrl_LUT* mpCtrl_LUT ;
	unsigned int Ctrl_LUT_Index ;
	unsigned int Ctrl_LUT_Count ;

	CStatic*			mpCStaticLabel ;
	CStatic*			mpCStaticBal ;
	CMixerSliderHorz*	mpCSliderCtrlBal ;
	CStatic*			mpCStaticVol ;
	CMixerSliderCtrl*	mpCSliderCtrlVol ;
	CMixerCheckBoxMute*	mpCCheckBoxMute ;
};

// -----------------------------------------------------------------------------

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions