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:
To learn more about using audio filter objects, see:
For introductory information, see Programming with Audio Filter Objects.
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.
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:
And to convert audio data samples at 8000 Hz 16-bit PCM data (one channel) into G723 compressed data, follow these steps:
/* Now set up the PCM16 to G723 filter */ G723Filter = UMSPCM16toG723New();
/* Determine input samples needed */ UMSPCM16toG723_get_minimum_input_size(G723Filter,env,&minRead);
/* Set the sampling rate */ UMSPCM16toG723_set_bit_rate(G723Filter,env, UMSPCM16toG723_Rate63K);
/* Determine output buffer size */ UMSFilter_calculate_output_size(chainFilter,env,readSize, &output_size);
/* Compress the data */ UMSPCM16toG723_filter_block(G723Filter,env,audBuffer._buffer audBuffer._length + minRead, bout,&amtRead);
For introductory information, see Programming with Audio Filter Objects.