[ Previous | Next | Contents | Glossary | Home | Search ]
Ultimedia Services Version 2 for AIX: Programmer's Guide and Reference

Using Audio Filter Objects

Objects for converting various audio formats to 16-bit PCM include:

Objects for converting 16-PCM data into other formats include:

Objects for converting data from 16-bit PCM to other formats include:

Object for converting between mono and stereo:

Other objects include:

To learn more about using audio filter objects, see:

For introductory information, see Programming with Audio Filter Objects.

Converting Sample Rate and Byte Order

Two objects convert the sampling rate and byte order of 16-bit PCM data: UMSSamplingRate and UMSByteOrder.

The UMSSamplingRate object changes the sampling rate of 16-bit PCM data using low-quality linear interpolation. The UMSSamplingRate object adds a method, set_input_output_rates, for specifying the source and destination sample rates in hertz (Hz).

The UMSByteOrder object converts the byte order from MSB to LSB and vice versa. It has no additional methods beyond those of the filter object and is not dependent on the sampling rate.

Chaining Filters Together

Audio filter objects can be chained together using the UMSChainFilter object. When several filters are chained together using a UMSChainFilter object, the UMSChainFilter object can be used as the filter object in calls to the filter_block method passing data from one filter to the next in the order the filter objects were added to the UMSChainFilter object. This object adds a method, add_next_filter, for chaining other filter objects together.

For example, to convert audio data sampled at 8000 Hz and encoded in A-law format to 16-bit PCM sampled at 22050 Hz, follow these steps:

  1. Create a UMSALAWtoPCM16 object, a UMSSamplingRate object, and a UMSChainFilter object.
  2. Add the UMSALAWtoPCM16 object and the UMSSamplingRate object to the UMSChainFilter object using the add_next_filter method.
  3. Use the UMSChainFilter object and an input buffer size with the calculate_output_size method to determine the minimum output buffer size needed to hold the converted data.
  4. Pass the A-law data to filter_block.

And to convert audio data samples at 8000 Hz 16-bit PCM data (one channel) into G723 compressed data, follow these steps:

  1. Create the UMSPCM16toG723 object.
    /* Now set up the PCM16 to G723 filter */
    G723Filter = UMSPCM16toG723New();
  2. Accumulate 240 16-bit samples of audio data in a buffer.
  3. Determine the minimum input buffer size.
    /* Determine input samples needed */
  4. Create the SOM sequence structure for the input sample data.
  5. Set the compressed bit rate, if different from the default, using the set_bit_rate method.
    /* Set the sampling rate */
  6. Set the filter mode, if different from the default, using the set_filter_mode method.
  7. After you have set the compressed bit rate, call the calculate_ouput_size method to determine the maximum size of the compressed buffer. The output buffer size varies with the compressed bit rate.
    /* Determine output buffer size */
  8. Create the SOM sequence structure to hold the output data.
  9. Pass the input audio data to the G.723 encoder using the filter_block method.
    /* Compress the data */
                                audBuffer._length + minRead,

For introductory information, see Programming with Audio Filter Objects.

[ Previous | Next | Contents | Glossary | Home | Search ]