|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
Note: This is an unedited contribution. If this article is inappropriate,
needs attention or copies someone else's work without reference then please
Report This Article
IntroductionAdding a volume control to an application seems like it should be an easy thing to do, enter the Windows Multimedia Audio API that enables a programmer to add audio services to an application. The audio mixer functions of this API are used to set an audio device's volume but there is a steep learning curve penalty waiting for the first time user. Although Vista provides a new and somewhat easier to use set of user-mode audio components, Microsoft has stated that it does not plan to make the Vista core audio APIs available for use with earlier versions of Windows such as XP. Since there is a large population of users still using XP and older Windows operating systems, a solution is needed that applies to all of these older systems as well.BackgroundTo address this problem, I created an API in the form of a small wrapper library that provides a straightforward way to programmatically interact with standard audio controls such as volume, balance, and mute. Using this API still requires some understanding of the terminology and basic concepts used in the mixer documentation. Using the codeTo fully use the CMixer class you will need to familiarize yourself with three SDK defined structures used by the class to provide information about mixer components:- The MIXERCAPS structure describes the capabilities of a mixer device. - The MIXERLINE structure describes the state and metrics of a connection or destination. - The MIXERCONTROL structure describes the state and metrics of a single control for a connection or destination. If you are interested in associating a Windows control with a mixer control, you will only need to refer to the MIXERCONTROL structure definition in the SDK documentation as this structure contains the ID number, type, name, and bounds data for a control. The included VolumeControl sample application is a simple MFC dialog application with a single volume control that is synchronized with the first volume control of the first mixer found in the system. In the case where a specific audio device, such as a wave in/out, MIDI in/out, or auxiliary device has already been opened, the CMixer instance may be initialized using the device’s ID index value or opened handle. The AudioDialog sample MFC dialog application has been included to address the situation where more extensive mixer information is required. It enumerates all mixers in the system and allows the user to display data associated with any of the mixers, destinations, connections, and controls found. It also presents a collection of volume, balance, and mute check box control groups based on the user selected mixer and destination similar to the system provided Volume Control utility. Build NotesBoth of the sample applications were built with Visual Studio 2005 as I felt that most people would at least have this version and that updating a project to a newer version of VS is much simpler than converting one to a previous version. Both applications were tested with Vista, XP, and 2K. The AudioDialog application should be built first as it creates the mixer API library file used by the VolumeControl application. HistoryInitial Release 10.20.08
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||