VCX. Volume control

News

Describes how to implement a volume control in your application using Visual Studio (C#, Visual Basic .NET, Visual Basic 6.0 or Visual C++ 6.0).

Downloads

Binary (.NET framework is required)

Source code: C# 2005
Source code: Visual Basic .NET 2005
Source code: Visual Basic 6.0
Source code: Visual C++ 6.0

(source code requires the VCX library installed)

Introduction

In some cases you have to control sound volume in your application. You may need to select a particular recording source, e.g. microphone, CD audio, etc., or change the recording/playback volume of some channels, e.g. total, wave, etc.

Click for full sized image

Simple volume control

The simple volume control approach implies that you use a number of pre-defined channels such as Microphone, CD Audio, Wave, etc.

Recording channels are represented by the vcRecSource enumeration. Playback channels are represented by vcPlayDest one.

This demo uses the VolumeControl component.

Change RecSource property to select a default recording channel (microphone, CD audio, etc.)

Call the GetPlayVolume/GetRecVolume methods passing a channel constant to get playback or recording volume of the corresponding channel.

Similarly, call the SetPlayVolume/SetRecVolume methods to set playback or recording volume of a channel.

Complete volume control

Use the IvcproVolumeControl2X interface of the VolumeControl component to access the methods which provides you full control over your sound card playback/recording channels.

VolumeControl component reference