Click here to Skip to main content
13,624,955 members
Click here to Skip to main content
Add your own
alternative version


48 bookmarked
Posted 27 Oct 2001

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

You may also be interested in...


Comments and Discussions

QuestionIs error? Pin
yangzmpang@22-Aug-10 20:54
memberyangzmpang@22-Aug-10 20:54 
GeneralCMixer constructor error Pin
anandveerappan4-Mar-10 23:24
memberanandveerappan4-Mar-10 23:24 
GeneralAnother Code Project article on this topic Pin
daluu5-Sep-07 9:06
memberdaluu5-Sep-07 9:06 
GeneralPlease, I need help Pin
wanhaven27-Feb-07 4:00
memberwanhaven27-Feb-07 4:00 
GeneralConversion error Pin
sraigiuz25-Jan-07 22:44
membersraigiuz25-Jan-07 22:44 
GeneralThe archive file is not avaible ... Pin
jere44trial@yahoo.fr29-Nov-06 5:28
memberjere44trial@yahoo.fr29-Nov-06 5:28 
QuestionHow to choose FrontPanel MIC or BackPanel MIC? Pin
guzeliang9-Oct-06 21:48
memberguzeliang9-Oct-06 21:48 
AnswerRe: How to choose FrontPanel MIC or BackPanel MIC? Pin
knightriderjon30-May-07 23:21
memberknightriderjon30-May-07 23:21 
GeneralRecord Volume Control on Vista OS Pin
varungarg25-Jul-06 19:01
membervarungarg25-Jul-06 19:01 
QuestionAdjusting Record Volume Pin
~Jabeen~22-Jun-06 20:46
member~Jabeen~22-Jun-06 20:46 
AnswerRe: Adjusting Record Volume [modified] Pin
Martin Skibye25-Mar-07 21:14
memberMartin Skibye25-Mar-07 21:14 
GeneralMixer.obj : error LNK2001 Pin
LowFly23-Nov-05 3:21
memberLowFly23-Nov-05 3:21 
GeneralIt was a valiant effort, but... Pin
Prodelos15-Jun-05 5:01
memberProdelos15-Jun-05 5:01 
GeneralRe: It was a valiant effort, but... Pin
koehler10-Feb-06 2:28
memberkoehler10-Feb-06 2:28 
GeneralCMixer class to controll multiple cards in one system Pin
sujudavid2-Mar-05 0:30
membersujudavid2-Mar-05 0:30 
GeneralRe: CMixer class to controll multiple cards in one system Pin
Prodelos15-Jun-05 3:35
memberProdelos15-Jun-05 3:35 
GeneralThank you very much Pin
niukaimin27-Jan-05 16:45
memberniukaimin27-Jan-05 16:45 
GeneralComawhite is right. Pin
Whoo17-Dec-04 1:52
memberWhoo17-Dec-04 1:52 
QuestionHow do you SELECT the Control Pin
ckathrani16-Dec-04 10:17
memberckathrani16-Dec-04 10:17 
AnswerRe: How do you SELECT the Control Pin
daluu5-Sep-07 8:50
memberdaluu5-Sep-07 8:50 
AnswerRe: How do you SELECT the Control Pin
Martin Skibye25-Feb-08 20:37
memberMartin Skibye25-Feb-08 20:37 
Generalmicrophone record volume Pin
Anonymous15-Dec-04 17:41
sussAnonymous15-Dec-04 17:41 
GeneralLink doesn't work Pin
ramontxu6-Jul-04 2:08
memberramontxu6-Jul-04 2:08 
GeneralRe: Link doesn't work Pin
oyljerry8-Nov-04 2:07
memberoyljerry8-Nov-04 2:07 
GeneralPlayback Pin
whacker30-Jun-04 8:41
memberwhacker30-Jun-04 8:41 

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

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

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01 | 2.8.180712.1 | Last Updated 28 Oct 2001
Article Copyright 2001 by Whoo
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid