Using the CD Audio Device

The CD audio device is a dynamic single context device and is serially shareable.

open cdaudio alias mycd shareable wait

By setting the shareable flag, an application allows other applications to share the device. When the device context is about to become active, the multimedia system posts an MM_MCIPASSDEVICE message with an event of MCI_GAINING_USE to your application.

Another common aspect of using the CD audio device is controlling the volume. Volume is controlled by indicating a percentage of the maximum achievable effect. Like all other devices in OS/2 multimedia, this volume level is automatically tempered by the master volume level that was set using the Volume Control application.

Volume Control Using the Internal DAC

By default the CD audio device utilizes the internal DAC on the CD drive which is represented by an enabled headphones connector. When the internal DAC is being used to process the CD audio data, requests to set the volume should be sent directly to the CD device.

set mycd audio volume 50 all wait

Depending on the capabilities of the actual CD-ROM drive, the degree of volume control might vary from on or off, to a reasonably linear range of settings. For example, the IBM PS/2 CD-ROM-II Drive supports 16 different levels of volume. An application might want to display either a simple two state mute button or a volume slider or dial depending on the degree of volume control provided by the CD drive. If a CD audio device can set the volume to some value other than 0 or 100, then it is likely the device supports several volume levels. For more information on two-state graphical buttons, see OS/2 Multimedia Controls. Refer to the PM Programming Reference for information on linear sliders and circular sliders (dials).

Volume Control Using the Ampmix Device

As stated previously, some CD audio devices have the capability to stream the audio data to a connected amplifier-mixer device. To determine if a particular CD audio device can stream CD audio data the device capabilities command can be used. If TRUE is returned, then the cd stream connector can subsequently be enabled.

capability mycd can stream wait
.
.
.
** If this CD audio device can stream **
.
.
.
connector mycd enable type cd stream wait

After enabling the cd stream, the CD audio device is utilizing the amplifier-mixer device to convert the audio data into sound. As such, the application must now send all volume commands to the connected ampmix device. Before a command can be sent to the ampmix device, the application must obtain the device ID of the amplifier-mixer device using the MCI_CONNECTION message. If using the string interface, an alias can be assigned to the connected ampmix device as follows:

connection mycd query type cd stream alias amp wait

In the previous example, the alias "amp" is assigned to the connected ampmix device. To set the volume or to control other audio attributes, the application can now send messages directly to the ampmix device.

set amp audio volume 25 over 2000 all wait
set amp audio treble 50 wait


[Back: CD-ROM Drives and Streaming]
[Next: Playing a Compact Disc]