Click here to Skip to main content
Click here to Skip to main content

A simple record and playback volume control class

, 27 Oct 2001
Rate this:
Please Sign up or sign in to vote.
A class to make setting the record and playback volume easier
<!-- Download Links --> <!-- Main HTML starts here -->


Sometimes we need to control the volume of our soundcard and Microsoft has provided an API waveOutSetVolume() to do this. Unfortunately this can only set the playback volume. When we want to set the volume of other lines such as mic or MIDI or the line-in for recording, there is NO API to help!

At first I thought that DirectMedia may provide an interface to do this, and it does, but after I coded it and tested, the result is not so good. The interface IAMAudioInputMixer can only handle the record, not the playback, and most of all:

"The name of each pin, such as "Line in" or "Microphone", reflects the type of input"

but the name is not the same on different machines!

I want to set the volume of the microphone, so I find the pin by name "Microphone" and control it, it works on my computer. When I tested it at another machine, it failed because the name of the pin is "Mic Volume"!

I tried many ways and at last I worked out how to do it using MIXER.

There may be some people that have had a headache over the same quetion, so I released my solution. I hope it helps you.


  1. include the Mixer.h and Mixer.cpp into your project;
  2. add code like this:


The constructor takes two parameters, the first is ComponentType from MIXERLINE (see MSDN for all possible values), and the second is an enum type, which can be Record or Play. The above controls the record (waveIn) volume, you can also control the playback (waveout) volume using:


Notice that there is no default constructor takes no parameters, so if you use it in a C++ class, you should code it like this:

// MyClass.h
class CMixer;
class CMyClass
  CMixer m_mixer;


if you have any suggestion or improvement, plz let me know:


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

China China
No Biography provided

Comments and Discussions

QuestionIs error? Pinmemberyangzmpang@22-Aug-10 21:54 
GeneralCMixer constructor error Pinmemberanandveerappan5-Mar-10 0:24 
GeneralAnother Code Project article on this topic Pinmemberdaluu5-Sep-07 10:06 
GeneralPlease, I need help Pinmemberwanhaven27-Feb-07 5:00 
GeneralConversion error Pinmembersraigiuz25-Jan-07 23:44 
GeneralThe archive file is not avaible ... Pinmemberjere44trial@yahoo.fr29-Nov-06 6:28 
I work on a cpp project and I want to change the microphone record volume.
this sources files will really help me.
Please re-upload it.
Thanks !
QuestionHow to choose FrontPanel MIC or BackPanel MIC? Pinmemberguzeliang9-Oct-06 22:48 
AnswerRe: How to choose FrontPanel MIC or BackPanel MIC? Pinmemberknightriderjon31-May-07 0:21 
GeneralRecord Volume Control on Vista OS Pinmembervarungarg25-Jul-06 20:01 
QuestionAdjusting Record Volume Pinmember~Jabeen~22-Jun-06 21:46 
AnswerRe: Adjusting Record Volume [modified] PinmemberMartin Skibye25-Mar-07 22:14 
GeneralMixer.obj : error LNK2001 PinmemberLowFly23-Nov-05 4:21 
GeneralIt was a valiant effort, but... PinmemberProdelos15-Jun-05 6:01 
GeneralRe: It was a valiant effort, but... Pinmemberkoehler10-Feb-06 3:28 
GeneralCMixer class to controll multiple cards in one system Pinmembersujudavid2-Mar-05 1:30 
GeneralRe: CMixer class to controll multiple cards in one system PinmemberProdelos15-Jun-05 4:35 
GeneralThank you very much Pinmemberniukaimin27-Jan-05 17:45 
GeneralComawhite is right. PinmemberWhoo17-Dec-04 2:52 
QuestionHow do you SELECT the Control Pinmemberckathrani16-Dec-04 11:17 
AnswerRe: How do you SELECT the Control Pinmemberdaluu5-Sep-07 9:50 
AnswerRe: How do you SELECT the Control PinmemberMartin Skibye25-Feb-08 21:37 
Generalmicrophone record volume PinsussAnonymous15-Dec-04 18:41 
GeneralLink doesn't work Pinmemberramontxu6-Jul-04 3:08 
GeneralRe: Link doesn't work Pinmemberoyljerry8-Nov-04 3:07 
GeneralPlayback Pinmemberwhacker30-Jun-04 9:41 
GeneralRe: Playback PinmemberComawhite11-Oct-04 15:03 
GeneralRe: Playback Pinmemberfritzpas24-Aug-05 11:21 
GeneralA poorly documented article PinmemberAtif Mushtaq16-Jun-04 21:09 
GeneralRe: A poorly documented article PinmemberRavi Bhavnani16-Jun-04 21:52 
GeneralRe: A poorly documented article Pinsusscoldembrace30-Jun-04 21:42 
GeneralRe: A poorly documented article Pinmembercoldembrace30-Jun-04 21:43 
GeneralRe: A poorly documented article PinmemberRavi Bhavnani1-Jul-04 4:22 
GeneralI cannot control mic &quot;play&quot; volume on XP PinsussAnonymous13-Apr-04 12:38 
GeneralRe: I cannot control mic &quot;play&quot; volume on XP PinsussAnonymous15-Apr-04 17:49 
GeneralRe: I cannot control mic &quot;play&quot; volume on XP PinsussAnonymous2-Mar-05 18:50 
GeneralRecording from Soundcard PinsussAnonymous5-Nov-03 18:59 
GeneralRe: Recording from Soundcard PinmemberWhoo15-Apr-04 18:07 
Questionwhat about paning? (n.t.) PinmemberDonGuitar30-Sep-03 15:20 
Generalgetting slider value Pinmembertmf690228-Aug-03 9:12 
GeneralRe: getting slider value PinmemberWhoo28-Aug-03 20:35 
GeneralRe: getting slider value Pinsusstmf29-Aug-03 9:25 
GeneralRe: getting slider value PinmemberWhoo29-Aug-03 19:11 
GeneralRe: getting slider value PinmemberSohailB15-Jun-05 22:14 
GeneralRecord Sound Volume Control PinmemberEfrain Munoz7-Jul-03 7:45 
GeneralRe: Record Sound Volume Control PinmemberWhoo8-Jul-03 2:15 
GeneralRe: Record Sound Volume Control PinmemberEfrain Munoz9-Jul-03 10:35 
GeneralRe: Record Sound Volume Control PinmemberWhoo15-Apr-04 17:58 
GeneralMixer.obj : error LNK2001: unresolved external symbol __imp__mixerGetLineControlsA@12 Pinmembertvhead802-Apr-03 3:56 
GeneralRe: Add Winmm.lib.:laugh: Pinmembertvhead802-Apr-03 4:01 
GeneralRe:How to Add Winmm.lib? Pinmembersevereight1-Apr-04 18:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150327.1 | Last Updated 28 Oct 2001
Article Copyright 2001 by Whoo
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid