Click here to Skip to main content
13,355,726 members (60,557 online)
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

AnswerRe: How do you SELECT the Control Pin
daluu5-Sep-07 9:50
memberdaluu5-Sep-07 9:50 
AnswerRe: How do you SELECT the Control Pin
Martin Skibye25-Feb-08 21:37
memberMartin Skibye25-Feb-08 21:37 
Generalmicrophone record volume Pin
Anonymous15-Dec-04 18:41
sussAnonymous15-Dec-04 18:41 
GeneralLink doesn't work Pin
ramontxu6-Jul-04 3:08
memberramontxu6-Jul-04 3:08 
GeneralRe: Link doesn't work Pin
oyljerry8-Nov-04 3:07
memberoyljerry8-Nov-04 3:07 
GeneralPlayback Pin
whacker30-Jun-04 9:41
memberwhacker30-Jun-04 9:41 
GeneralRe: Playback Pin
Comawhite11-Oct-04 15:03
memberComawhite11-Oct-04 15:03 
GeneralRe: Playback Pin
fritzpas24-Aug-05 11:21
memberfritzpas24-Aug-05 11:21 
Hello all,

sorry Comawhite but i didn't think it is rather a user problem than a bug, because see the following lines.

Audio line is a source originating from the waveform-audio output digital-to-analog converter (DAC). Most audio cards for personal computers provide this component type as a source to the MIXERLINE_COMPONENTTYPE_DST_SPEAKERS destination. Some cards also allow this source to be routed to the MIXERLINE_COMPONENTTYPE_DST_WAVEIN destination.

I hope you know what I meen with user problem (not every user has a compatible sound card).

Here is my solution how I get the parameter CMixer::Play (Play) in the constructor to work
in my system.

Change the following line in the construtor
if (dkKind == Play)<br />

if (dkKind == Play)<br />

I hope this helps some other people

GeneralA poorly documented article Pin
Atif Mushtaq16-Jun-04 21:09
memberAtif Mushtaq16-Jun-04 21:09 
GeneralRe: A poorly documented article Pin
Ravi Bhavnani16-Jun-04 21:52
memberRavi Bhavnani16-Jun-04 21:52 
GeneralRe: A poorly documented article Pin
coldembrace30-Jun-04 21:42
susscoldembrace30-Jun-04 21:42 
GeneralRe: A poorly documented article Pin
coldembrace30-Jun-04 21:43
membercoldembrace30-Jun-04 21:43 
GeneralRe: A poorly documented article Pin
Ravi Bhavnani1-Jul-04 4:22
memberRavi Bhavnani1-Jul-04 4:22 
GeneralI cannot control mic &quot;play&quot; volume on XP Pin
Anonymous13-Apr-04 12:38
sussAnonymous13-Apr-04 12:38 
GeneralRe: I cannot control mic &quot;play&quot; volume on XP Pin
Anonymous15-Apr-04 17:49
sussAnonymous15-Apr-04 17:49 
GeneralRe: I cannot control mic &quot;play&quot; volume on XP Pin
Anonymous2-Mar-05 18:50
sussAnonymous2-Mar-05 18:50 
GeneralRecording from Soundcard Pin
Anonymous5-Nov-03 18:59
sussAnonymous5-Nov-03 18:59 
GeneralRe: Recording from Soundcard Pin
Whoo15-Apr-04 18:07
memberWhoo15-Apr-04 18:07 
Questionwhat about paning? (n.t.) Pin
DonGuitar30-Sep-03 15:20
memberDonGuitar30-Sep-03 15:20 
Generalgetting slider value Pin
tmf690228-Aug-03 9:12
membertmf690228-Aug-03 9:12 
GeneralRe: getting slider value Pin
Whoo28-Aug-03 20:35
memberWhoo28-Aug-03 20:35 
GeneralRe: getting slider value Pin
tmf29-Aug-03 9:25
susstmf29-Aug-03 9:25 
GeneralRe: getting slider value Pin
Whoo29-Aug-03 19:11
memberWhoo29-Aug-03 19:11 
GeneralRe: getting slider value Pin
SohailB15-Jun-05 22:14
memberSohailB15-Jun-05 22:14 
GeneralRecord Sound Volume Control Pin
Efrain Munoz7-Jul-03 7:45
memberEfrain Munoz7-Jul-03 7:45 

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 | Terms of Use | Mobile
Web02 | 2.8.180111.1 | Last Updated 28 Oct 2001
Article Copyright 2001 by Whoo
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid