Jump to content

MMAPG - Waveform Audio Device

From EDM2
Multimedia Application Programming Guide
  1. Introduction
  2. What's New...
  3. Multimedia Application Programming Environment
  4. Media Control Interface
  5. Multimedia Logical Devices
  6. Amplifier-Mixer Device
  7. Waveform Audio Device
  8. Sequencer Device
  9. CD Audio Device
  10. CD-XA Device
  11. Videodisc Device
  12. Digital Video Device
  13. Direct Interface Video Extensions (DIVE)
  14. Captioning
  15. OS/2 Multimedia Controls
  16. Multimedia I/O File Services
  17. Resource Interchange File Format (RIFF) Services
  18. Sample Application Programs
  19. Installing a Program Using MINSTALL
  20. Caption DLL
  21. High-Level Service API
  22. Notices
  23. Glossary

Reprint Courtesy of International Business Machines Corporation, © International Business Machines Corporation

The OS/2 waveform audio (waveaudio) device allows an application to play or record digital audio using files or application memory buffers. While audio refers to the sound waves (changes in air pressure) that have a perceived effect on the human ear, waveform refers to a digital representation of the original audio sound wave. Using one technique called pulse code modulation (PCM), discrete samples of the sound wave are encoded by an audio adapter at precise intervals. The numerical value of the sample increases when the sound wave's force (loudness) increases. The variation of the sample increases as the frequency of the sound wave increases.

The number of samples per second taken of the original sound wave as well as the precision (or resolution) of the sample dictate the quality of the sound reproduction. Typical sampling rates include 44 kHz, 22 kHz, and 11 kHz, where kHz is an abbreviation for kilohertz or thousands of cycles per second. The sampling precision is usually measured in bits where 8 or 16 bits per sample are representative of most audio adapters. Mono or stereo refers to the number of channels transferring digital audio. Mono represents one channel and stereo represents two channels.

Generally, the higher the sampling rate and resolution, the higher the perceived quality; however this comes at the expense of potentially enormous data rates and file sizes. For example, audio quality equivalent to that produced by a CD audio device requires a sampling rate of 44.1 kHz, and 16-bit resolution for each of the channels in a stereo recording. This information alone results in a data rate of 176 kilobytes per second! Luckily, many applications of digital audio are adequately supported with sampling rates and resolutions as low as 22 kHz and 8 bits respectively. The exact choice of parameters will vary, depending on the requirements of the application.

The Wave Stream Connector

The wave stream connector represents the flow of digital information to and from the waveaudio device to its associated amplifier-mixer (ampmix) device. During playback, the waveaudio device sends digitized sounds from either application memory or files to the ampmix device for subsequent conversion into audio that can be heard through conventional speakers or headphones. When recording, the waveaudio device receives waveforms from the ampmix device and stores the digital information in a file or in application memory.

Control of the characteristics of the waveform information is provided by the waveaudio device. The quality of the waveform can be controlled by setting the format, sampling rate, bits per sample, and the number of channels. As an additional service, the waveaudio device will also allow the volume to be controlled. This service is actually provided by the ampmix device in a way that is transparent to the calling application. If other advanced audio shaping features are required, the application can retrieve the device ID of the ampmix device using the MCI_CONNECTION message. Once the device ID has been obtained, the application can send commands directly to the ampmix device. Examples include set commands to manipulate treble, bass, and balance.

Waveaudio Device Features

  • Multiple time formats
  • Waveform characteristics
  • Data Format


File format (RIFF WAVE, AVC, or others if an MMIO procedure is supplied)
Sampling rate
Bits per sample (resolution)
Number of channels

  • Playback and record sources
  • File system


Application memory

  • Audio shaping
  • Volume control


Other features that might be available through the associated ampmix device

  • Cue point and position advise notification


Waveform Data Formats

There are several formats used for storing waveform data within a computer system. OS/2 multimedia recognizes several resolutions of the Pulse Code Modulation (PCM) format, because it is supported by most audio adapters. OS/2 multimedia also recognizes ADPCM formats. Refer to the Appendix of the OS/2 Multimedia Programming Reference for descriptions of these formats.

Pulse Code Modulation (PCM) refers to the variation of a digital signal to represent audio amplitude. This method of assigning binary values to amplitude levels supports the conversion of analog signals to digital signals by adapters such as the M-Audio Capture and Playback Adapter.

Adaptive Differential Pulse Code Modulation (ADPCM) is a technique for compressing waveform samples. ADPCM can reduce the amount of data storage required by a factor of 16 to 1, but some price is paid in fidelity for the higher compression rates.

M-Audio Adapter Specifics

The following tables list the valid MCI_WAVE_SET items for the operation modes currently supported by the M-Audio Capture and Playback Adapter.

Note: Numbers in table stand for number of channels supported in this mode-- mono (1), stereo (2), N/A (Not Available)

Data Size       8000 Hz      11025 Hz     22050 Hz     44100 Hz
8-bit           1, 2         1, 2         1, 2         1, 2
16-bit          1, 2         1, 2         1, 2         1, 2
Data Size       8000 Hz      11025 Hz     22050 Hz     44100 Hz
8-bit           N/A          N/A          N/A          N/A
16-bit          N/A                       1, 2
Data Size       8000 Hz      11025 Hz     22050 Hz     44100 Hz
8-bit           1,2          1,2          1,2          1,2
16-bit          N/A          N/A          N/A          N/A
Data Size       8000 Hz      11025 Hz     22050 Hz     44100 Hz
8-bit           1,2          1,2          1,2          1,2
16-bit          N/A          N/A          N/A          N/A

Audio Device Capabilities

If MCI_GETDEVCAPS_EXTENDED is specified in conjunction with MCI_GETDEVCAPS_ITEM, the MCI_GETDEVCAPS_WAVE_FORMAT value can be placed in the ulItem field for the waveaudio device as an extended request. The MCI_GETDEVCAPS_WAVE_FORMAT value allows an application to query if the device supports a specific waveaudio format. The application must fill in the ulBitsPerSample, ulFormatTag, ulSamplesPerSec, ulChannels, and ulFormatMode fields in the MCI_WAVE_GETDEVCAPS_PARMS data structure. The driver returns MCI_TRUE if the format is supported or returns a specific error describing why the command field failed if the format is not supported.

The following code fragment shows a portion of the Audio Recorder Sample program provided in the Toolkit (\TOOLKIT\SAMPLES\MM\RECORDER). This program uses the MCI_GETDEVCAPS message to determine the capabilities of the currently selected waveaudio device.

  ULONG                     ulRC;           /* return code from function */
  MCI_WAVE_GETDEVCAPS_PARMS mciAudioCaps; /* MCI_GETDEVCAPS_PARMS
                                             structure */
  memset( &mciAudioCaps , 0, sizeof(MCI_WAVE_GETDEVCAPS_PARMS));

  /* Test to see if the device can play 11 kHz, 8-bit, mono files. */
  mciAudioCaps.ulBitsPerSample = 8;
  mciAudioCaps.ulFormatTag     = DATATYPE_WAVEFORM;
  mciAudioCaps.ulSamplesPerSec = 11025;
  mciAudioCaps.ulChannels      = 1;
  mciAudioCaps.ulFormatMode    = MCI_PLAY;
  mciAudioCaps.ulItem          = MCI_GETDEVCAPS_WAVE_FORMAT;

  ulRC = mciSendCommand (mciOpenParms.usDeviceID,   /* Device ID    */
                         MCI_GETDEVCAPS,
                         MCI_WAIT | MCI_GETDEVCAPS_EXTENDED
                              | MCI_GETDEVCAPS_ITEM,
                         (PVOID) &mciAudioCaps,
                         0);
       .
       .
       .

/* Test to see if the device can record 11 kHz, 16-bit, mono files. */
  mciAudioCaps.ulBitsPerSample = 16;
  mciAudioCaps.ulFormatTag     = DATATYPE_WAVEFORM;
  mciAudioCaps.ulSamplesPerSec = 11025;
  mciAudioCaps.ulChannels      = 1;
  mciAudioCaps.ulFormatMode    = MCI_RECORD;
  mciAudioCaps.ulItem          = MCI_GETDEVCAPS_WAVE_FORMAT;

  ulRC = mciSendCommand (mciOpenParms.usDeviceID,  /* Device ID     */
                         MCI_GETDEVCAPS,
                         MCI_WAIT | MCI_GETDEVCAPS_EXTENDED
                              | MCI_GETDEVCAPS_ITEM,
                         (PVOID) &mciAudioCaps,
                         0);

Using the Waveform Audio Device

Because the waveaudio device is a compound device, it requires a device element. The device element is typically a file that contains a sampled waveform for playback. The waveaudio device can be opened with or without a device element. A device element can subsequently be specified using the load command.

Opening the Waveform Audio Device

The following string commands open the default waveaudio device and load a file onto it.

open waveaudio alias wave shareable
load wave c:\mysounds\train.wav

OS/2 multimedia allows you to specify the device to be used for a particular file based on the file's extension or its extended attributes (EAs). Using .TYPE EAs is the preferred method, because they remain with the files even when the files are renamed. Both file extensions and extended attributes can be associated with a device using the Multimedia Setup application. For instance, assuming files with an extension of .WAV have been associated with the waveaudio device, the following command will result in a file being loaded into the waveaudio device:

open c:\mysounds\monkey.wav alias monkey shareable

Finally, both the device element and the device type can be specified:

open c:\mysounds\paperjam.wav type waveaudio alias wave shareable

Recording a Waveform File

One of the typical uses of the waveform audio device is to digitize an input signal or sound into discrete samples for storage in a file. An example of this would be recording an electronic audio mail message to actually tell someone about an idea, as opposed to typing a memo on the same subject. An electronic audio mail application would be completely shielded from the complexity of digitizing a signal and would only need to specify a file, while providing the user with a simple control panel to allow the message to be recorded. The user might press a stop button on the control panel when finished describing the idea. The application could then issue a stop command to the waveaudio device to discontinue the recording.

open myidea.wav waveaudio alias wave wait
record wave notify
.
.
.
** recording the idea into myidea.wav **
.
.
.
stop wave wait

Like many text editors, the waveform audio media driver will not actually modify the original file until it receives a command to save the changes. Any temporary files created during the record operation will be located in the directory specified by the MSV_WORKPATH multimedia system variable. The path can be specified on the system page of the Multimedia Setup application. The use of temporary files is completely transparent to the application.

The file can be saved using the original file name, or a new file name can be specified. If a save command is not issued before closing the waveform audio device, all changes will be discarded.

save wave wait
close wave wait

It is possible to open or load the waveaudio device specifying a special readonly option. In this mode, the waveaudio device prevents any modification to the file from either the save or record commands. In certain circumstances, the driver might be able to optimize performance by utilizing the information that the file will not be modified. The option will also allow multiple applications to share the same file for playback purposes and will prevent inadvertent modification of the file.

open bigwave.wav type waveaudio alias wave readonly shareable

Creating New Files

The waveaudio device will create a new file on either the MCI_OPEN or MCI_LOAD commands if a file element is indicated (MCI_OPEN_ELEMENT_ID) and the specified file name does not exist. If no file name is indicated, the waveaudio driver will create an unnamed temporary file. If an unnamed temporary file is created, it can later be named by issuing the MCI_SAVE command, which must include the permanent name of the new file.

To support file creation from the string interface, a special file name called new is reserved for system use. This file name should be used in place of the usual application supplied file name. As in the command message interface, the save command must be issued to give the file a permanent name.

open new type waveaudio alias wave wait
record wave notify
.
.
.
** recording **
.
.
.
stop wave wait
save wave myspeech.wav wait

When a file is initially created, default settings will be assigned by the media driver and might depend on the capabilities of the audio adapter. The IBM waveform audio driver will use PCM, 22 kHz, 16 bits per sample, and mono as the default for 16-bit adapters. If the adapter does not support 16-bit PCM, then the resolution (bits per sample) will be downgraded to 8 bits.

The following table lists audio adapters supported by OS/2 multimedia. The default settings are those initially assigned by the media driver to a new file when that particular audio adapter is being used.

Audio Adapter            Format    Sampling  Bits per  Channels  
                                   rate      sample              
IBM M-Audio              PCM       22 kHz    16        1         
Sound Blaster            PCM       22 kHz    8         1         
Sound Blaster Pro        PCM       22 kHz    8         1         
Sound Blaster 16         PCM       22 kHz    16        1         
Pro AudioSpectrum 16     PCM       22 kHz    16        1         

OS/2 multimedia enables recording of digital audio information in the format that fits specific needs, such as space or quality. For example, assume that a new waveaudio file is created with the following command:

open new type waveaudio alias a wait

When the file is created, you might want a file that is compatible with mu-law (the compression scheme used by the telephone system). To change the compression scheme, the format tag must be set for the file. The following string commands prepare the file for recording mu-law by setting the format tag:

set a format tag mulaw wait
set a bitspersample 8 wait
set a channels 1 wait
set a samplespersec 11025 wait

If you wanted to record with a compression scheme commonly used in Europe (a-law), the following command could have been issued:

set a format tag alaw wait

An application should always set the waveform format, sampling rate, resolution, and number of channels to ensure that the waveform is created with the desired parameters as shown in the following string interface example.

set wave format tag PCM wait
set wave samplespersec 22050 wait
set wave bitspersample 8 wait
set wave channels 1 wait

Note: When modifying the settings on a waveaudio device, the format tag should be changed first, because it might force the automatic modification of other settings to make them compatible with the new format. For instance, a waveaudio device that supports 16-bit PCM might only support 8-bit ADPCM. Changing the format from PCM to ADPCM will automatically change the bits per sample setting.

Playing and Recording non-RIFF Waveforms

The waveform audio device will create new waveforms according to the RIFF WAVE data standard. It is possible, however to play other data formats using OS/2 multimedia if the appropriate MMIO procedure has been supplied. The selection of the appropriate I/O procedure (IOProc) is transparent to the application if the IOProc has been installed.

One example of this feature is OS/2 multimedia's ability to play waveform audio files that were created using IBM's AVC application and the M-Audio card. Note that the AVC support provides playback capabilities only. The waveform audio device will temporarily report FALSE to the save and record capabilities of the device capabilities (MCI_GETDEVCAPS) function when the underlying I/O procedure does not support the creation of files. Applications should check the device capabilities to appropriately display a user interface that reflects the true capabilities of the waveaudio driver and its associated I/O procedure.

For example, a waveform editor application should grey out its record button when an AVC file is loaded, as only playback operations are supported. Querying the device capabilities would return FALSE for can record. If a waveform file in the RIFF WAVE format is subsequently loaded, the record button should be enabled, because the same can record query will now return TRUE. In all instances, by using the high-level OS/2 multimedia mciSendString or mciSendCommand interface to reference device capabilities, the application is shielded from the underlying implementation.

Creating a Waveform Playlist

Specialized applications such as a waveform editor might require the capability of playing and recording using application memory buffers instead of files. The memory playlist feature of OS/2 multimedia provides the construct for supplying memory buffers to the waveaudio device. Besides implementing simple circular buffering schemes, memory playlists can be used to synthesize complex and unique waveform sounds. By following each DATA statement with a MESSAGE statement, an application can be informed as to when the buffer can be reused.

Playlist Structure

Depending on the complexity of the application, memory playlists can be used to provide a single large memory buffer, or multiple buffers in a circular buffering scheme. The following is an example of how a memory playlist might be constructed to implement a simple circular buffering scheme.

    0:    NOP
    1:    DATA...
    2:    MESSAGE...
    3:    DATA...
    4:    MESSAGE...
    5:    DATA...
    6:    MESSAGE...
    7:    BRANCH 0

Note that regardless of whether the playlist is being used for play or record operations, the MESSAGE instruction will notify the application when the playlist processor has consumed or filled the preceding DATA buffer. An MM_MCIPLAYLISTMESSAGE will be sent to the window procedure specified when the waveaudio device was originally opened.

The following code fragment shows the SetUpPlaylist procedure that is performed once, during initialization of the Clock Sample program. It calls the procedure CopyWaveformIntoMemory to copy the waveform files into memory buffers. It also initializes the playlist data structure by supplying the address and size of the memory buffers holding the data in the appropriate data structure fields.

VOID SetupPlayList( VOID )
{
 /*
  * This array keeps the address of each audio chime file.
  */
 static LONG *pulBaseAddress[ NUMBER_OF_CHIME_FILES ];

 USHORT usChimeFileId;            /* Chime audio file ID.        */
 ULONG  ulSizeOfFile,             /* Size of audio file.         */

ulMemoryAllocationFlags = PAG_COMMIT | PAG_READ | PAG_WRITE;
for(usChimeFileId=0; usChimeFileId<NUMBER_OF_CHIME_FILES;
    usChimeFileId++)
 {

    ulSizeOfFile = HowBigIsTheChimeFile( usChimeFileId );
  /*
   * If the returned file size is 0, there is a problem with the
   * chime files.  A message will already have been shown to the user
   * by the HowBigIsTheChimeFile function so exit this routine.
   */
    if ( ulSizeOfFile == 0 )
    {
       return;
    }
    if ( (pulBaseAddress[ usChimeFileId ] = (LONG *)
            malloc( ulSizeOfFile )) == (LONG *) NULL )
    {
       /*
        * The memory for the waveform files cannot be allocated.
        * Notify the user and return from this routine.  No playlist
        * can be created/played until memory is available.
        */
       ShowAMessage(
          acStringBuffer[
              IDS_NORMAL_ERROR_MESSAGE_BOX_TEXT - 1 ],
          IDS_CANNOT_GET_MEMORY, /* ID of the message to show. */
          MB_OK | MB_INFORMATION | MB_HELP |  MB_APPLMODAL |
              MB_MOVEABLE );           /* Style of the message box. */

       return;

    }  /* End of IF allocation fails. */
    /*
     * Place the waveform files into the memory buffer that was just
     * created.
     */
    CopyWaveformIntoMemory(
       pulBaseAddress[ usChimeFileId ],
       ulSizeOfFile,
       usChimeFileId );
    /*
     * Now that we've loaded the waveform into memory, we need to put
     * its address and size into the playlist data statements that
     * use this particular file.
     *
     * Its address must be placed into the data statement's first
     * operand and its size must be placed in the data
     * statement's second operand.
     *
     * For the four different playlists, one for each chime time
     * (1/4, 1/2, 3/4 and 1 hour increments),
     * the address of the chime file and its size will be loaded
     * into each data statement of the Playlist.
     */
    if ( usChimeFileId == 0 )
    /* If we just loaded CLOCK1.WAV */
    {
       /*
        * Put the address of this chime into the first operand of
        * every data operation that uses this particular chime.
        */
    apltPlayList[ 0 ][ 0 ].ulOperandOne =  /* 1/4 hour 1st data op */
    apltPlayList[ 1 ][ 0 ].ulOperandOne =  /* 1/2 hour 1st data op */
    apltPlayList[ 2 ][ 0 ].ulOperandOne =  /* 3/4 hour 1st data op */
    apltPlayList[ 2 ][ 2 ].ulOperandOne =  /* 3/4 hour 3rd data op */
    apltPlayList[ 3 ][ 0 ].ulOperandOne =  /* 1   hour 1st data op */
    apltPlayList[ 3 ][ 2 ].ulOperandOne =  /* 1   hour 3rd data op */
       (ULONG) pulBaseAddress[ usChimeFileId ];  /* address         */
    /*
     * Now put the size of the file into the second operand of every
     * data operation that uses this particular chime.
     */
    apltPlayList[ 0 ][ 0 ].ulOperandTwo =  /* 1/4 hour 1st data op */
    apltPlayList[ 1 ][ 0 ].ulOperandTwo =  /* 1/2 hour 1st data op */
    apltPlayList[ 2 ][ 0 ].ulOperandTwo =  /* 3/4 hour 1st data op */
    apltPlayList[ 2 ][ 2 ].ulOperandTwo =  /* 3/4 hour 3rd data op */
    apltPlayList[ 3 ][ 0 ].ulOperandTwo =  /* 1   hour 1st data op */
    apltPlayList[ 3 ][ 2 ].ulOperandTwo =  /* 1   hour 3rd data op */
       ulSizeOfFile;                             /* size         */
 }
 else
 if ( usChimeFileId == 1 )
 /* If we just loaded CLOCK2.WAV */
 {
    /*
     * Put the address of this chime into the first operand of
     * every data operation that uses this particular chime.
     */
    apltPlayList[ 1 ][ 1 ].ulOperandOne =  /* 1/2 hour 2nd data op */
    apltPlayList[ 2 ][ 1 ].ulOperandOne =  /* 3/4 hour 2nd data op */
    apltPlayList[ 3 ][ 1 ].ulOperandOne =  /* 1   hour 2nd data op */
    apltPlayList[ 3 ][ 3 ].ulOperandOne =  /* 1   hour 4th data op */
       (ULONG) pulBaseAddress[ usChimeFileId ];  /* address    */
    /*
     * Now put the size of the file into the second operand of every
     * data operation that uses this particular chime.
     */
    apltPlayList[ 1 ][ 1 ].ulOperandTwo =  /* 1/2 hour 2nd data op */
    apltPlayList[ 2 ][ 1 ].ulOperandTwo =  /* 3/4 hour 2nd data op */
    apltPlayList[ 3 ][ 1 ].ulOperandTwo =  /* 1   hour 2nd data op */
    apltPlayList[ 3 ][ 3 ].ulOperandTwo =  /* 1   hour 4th data op */
       ulSizeOfFile;                             /* size         */
 }
 else
 if ( usChimeFileId == 2 )
 /* If we just loaded CLOCK3.WAV          */
 /* (this is the gong part of the chime) */
 {
    /*
     * Put the address of this chime into the first operand of
     * every data operation that uses this particular chime.
     */
    apltPlayList[ 3 ][ 5 ].ulOperandOne =  /* 1 hour 5th data op */
       (ULONG) pulBaseAddress[ usChimeFileId ];

    /*
     * Now put the size of the file into the second operand of every
     * data operation that uses this particular chime.
     */

    apltPlayList[ 3 ][ 5 ].ulOperandTwo =   /* 1 hour 5th data op */
       ulSizeOfFile;
  }

 }  /* End of For loop of chime files. */

}  /* End of SetupPlayList */

Suggested Setups for Playlists

The following tables provide guidelines for setting up playlists to utilize memory more efficiently.

For a sampling rate of 8 kHz:

Bits Per   # of       Buffer Size Max. # of   # of Buffers
Sample     Channels               Buffers     before a   
                                              stream is  
                                              started    
           1          8KB         20          4          
           2          16KB        20          4          
16         1          16KB        20          4          
16         2          32KB        20          4          

For a sampling rate of 11 kHz:

Bits Per   # of       Buffer Size Max. # of   # of Buffers
Sample     Channels               Buffers     before a   
                                              stream is  
                                              started    
           1          8KB         20          4          
           2          16KB        20          4          
16         1          16KB        20          4          
16         2          32KB        20          4          

For a sampling rate of 22 kHz:

Bits Per   # of       Buffer Size Max. # of   # of Buffers
Sample     Channels               Buffers     before a   
                                              stream is  
                                              started    
           1          8KB         20          4          
           2          16KB        20          4          
16         1          16KB        20          4          
16         2          32KB        20          4          

For a sampling rate of 44 kHz:

Bits Per   # of       Buffer Size Max. # of   # of Buffers
Sample     Channels               Buffers     before a   
                                              stream is  
                                              started    
           1          16KB        20          4          
           2          32KB        20          4          
16         1          32KB        20          4          
16         2          60KB        20          4          

Waveform Audio Command Messages

Following are descriptions of the command messages used to control the recording, editing, and playback of waveform data. Analog input devices for recording waveforms are a microphone and tape deck. Analog output devices for waveform playback are a stereo amplifier or speakers connected to an audio adapter.

Message Description
MCI_CLOSE Closes the waveform audio player.
MCI_CONNECTOR Enables or disables a connector, queries its state, or identifies its type.
MCI_COPY Copies data from the device element to the clipboard or buffer.
MCI_CUE Cues the device for minimum delay in recording or playback.
MCI_CUT Removes data from the device element and places it in the clipboard or buffer.
MCI_DELETE Removes the specified range of data from the device element.
MCI_GETDEVCAPS Gets device capabilities.
MCI_INFO Gets the name of the currently loaded file.
MCI_LOAD Loads a waveform data file.
MCI_OPEN Initializes the waveform audio player.
MCI_PASTE Issues a DELETE on the selected range and inserts data into clipboard or buffer.
MCI_PAUSE Suspends the current play or record action.
MCI_PLAY Plays back waveform data by means of an audio adapter.
MCI_RECORD Records waveform data.
MCI_REDO Redoes the CUT, DELETE, PASTE, or RECORD operation most recently done by MCI_UNDO.
MCI_RESUME Resumes the current play or record action from a paused state.
MCI_SAVE Saves the device element in its current format.
MCI_SEEK Seeks to a specified location.
MCI_SET Sets device information.
MCI_SET_CUEPOINT Sets a cue point.
MCI_SET_POSITION_ADVISE Sets a position change notification request.
MCI_SET_SYNC_OFFSET Sets a synchronization offset.
MCI_STATUS Receives status on current settings for items used for recording, playback, and saving.
MCI_STOP Stops the waveform device before loading a new file.
MCI_UNDO Undoes the operation most recently performed by CUT, DELETE, PASTE, or RECORD.

Waveaudio Connectors

The waveaudio device directly supports one wave stream connector which is always enabled. As it is likely that an application will need to select the recording source or the output destination on the amplifier-mixer device, the waveaudio device will attempt to provide the following connector services to an application. If the requested connector is not available, the command will fail.

  • headphones
  • speakers
  • line out
  • microphone
  • line in

Additional connectors might be available on the ampmix device. To control these connectors obtain the device ID of the ampmix device using the MCI_CONNECTION message and issue the connector command directly to the associated amplifier-mixer.

To determine which connectors are supported by an amplifier-mixer device, use the MCI_CONNECTORINFO message.

The Audio Recorder Sample program illustrates the concept of recording audio data. In order to do this, it first configures the device settings such as the input source as shown in the following code fragment.

 MCI_CONNECTOR_PARMS  mciConnectorParms;   /* for MCI_CONNECTOR  */
 
 /*
  * Set up input source - microphone or line in.
  * Initialize MCI_CONNECTOR_PARMS structure with the pertinent
  * information, and then issue an MCI_CONNECTOR command by way of
  * mciSendCommand.
  */
 mciConnectorParms.ulConnectorType = usDeviceType;
                                          /* microphone/linein     */

 ulError = mciSendCommand( mciOpenParms.usDeviceID,
                           MCI_CONNECTOR,
                           MCI_WAIT | MCI_CONNECTOR_TYPE |
                           MCI_ENABLE_CONNECTOR,
                           (PVOID) &mciConnectorParms,
                           0 );
 if (ulError)
  {
    ShowMCIErrorMessage( ulError);
    return( FALSE);
  }