Click here to Skip to main content
11,410,333 members (60,177 online)
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

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 
Hello, I am new in vc++, i use visual basic and
need to control the record sound mic volume as
(sndvol32.exe -R -D control) in windows.

The are some dll that implement the record volume sound?
Best wishes,
Efrain Munoz
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 
GeneralRe:How to Add Winmm.lib? Pinmembermmjd11-Apr-04 23:20 
GeneralRe:Thank you for your help!! Pinmembersevereight13-Apr-04 18:22 
Generalquesions,thanks PinmemberNeverGrief21-Nov-02 7:09 
GeneralRe: quesions,thanks PinmemberWhoo22-Nov-02 6:33 
GeneralDirectSound PinmemberRainer Schmidt18-Mar-02 0:30 
GeneralRe: DirectSound PinmemberWhoo22-Nov-02 6:35 
General#include "send.h" Pinmembervila8-Dec-01 10:12 
GeneralRe: #include "send.h" PinmemberWhoo8-Dec-01 19:24 
GeneralRTFM PinmemberAlexander Fedorov29-Oct-01 5:28 
GeneralRe: RTFM PinmemberAnonymous29-Oct-01 16:01 
GeneralRe: RTFM PinmemberPackRat12-Dec-01 5:14 

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.150414.5 | Last Updated 28 Oct 2001
Article Copyright 2001 by Whoo
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid