This audio encoder object converts audio from PCM16 format into an MPEG-1 format. MPEG-1 is the Moving Pictures Experts Group standard for a compressed audio stream (ISO document number 11172-3). The Audio Encoder object is capable of producing either Layer I or Layer II compressed data. The input data format, PCM16, is 16 bits per sample, twos complement data, with MSB first.
In order to encode the audio data, a minimum amount of data must be delivered each time the filter/compression operation is called. The minimum amount needed can be determined using the get_minimum_input_size method. This amount of data must be delivered each time the compress method is called, otherwise an error return is generated. Handling the last chunk of input data may require some planning.
The reset method discards any previous input data samples that might be stored in the compression object. This method should be called before compressing a new audio stream.
The MPEG-1 Audio Encoder object inherits from the UMSFilter object and contains all those methods plus the following, MPEG-1 unique methods. The compression format (Layer I or Layer II), bit rate, and various header flags are all settable using the following methods.
To learn more about the UMSPCM16toMPEG1 object, see:
For introductory information, see Audio Codec Objects.
enum CompressType { UMSPCM16toMPEG1_LAYER_1, /* Layer I audio format */ UMSPCM16toMPEG1_LAYER_2} /* Layer II audio format */
enum channelEncode { UMSPCM16toMPEG1_MONO, /* Monophonic audio */ UMSPCM16toMPEG1_STEREO, /* Stereo audio signal */ UMSPCM16toMPEG1_JOINT_STEREO}; /* Intensity stereo */
enum OnOff { UMSPCM16toMPEG1_On, /* Bit ON */ UMSPCM16toMPEG1_Off}; /* Bit OFF */
This method returns the current setting of the compression type.
inout CompressType compress_type | The return value of compress_type gives the current compression format. |
This method queries the state of the copyright flag.
inout OnOff flag | The returned value, flag, indicates whether the copyright bit is enabled or disabled. |
This method returns the state of the error protection flag.
inout OnOff flag | The return value, indicates whether error protection is turned On or Off. |
The value minimum_size will be filled in with the minimum amount of data needed in the filter method in order to do the compression. The PCM16toMPEG1 object requires a certain amount of data in order to begin encoding.
inout long minimum_size | The minimum of input data that must be available during a compress frame operation. |
This method queries the current state of the original flag.
inout OnOff flag | The enum type, flag, queries the state of the original bit. |
Returns the current bit rate setting.
inout long bit_rate | The return value, bit_rate, is the compressed bits-per-second target rate for audio encoder. |
This method allows the user to select the MPEG-1 format for compression. Layer I typically gives a lower compression rate, but is somewhat easier to decode, while Layer II gives better compression at a cost of additional decoding complexity. Layer I is recommended for bit rates above 128 Kbits/s per channel. Layer II is recommended for bit rates around 128 kbits/s per channel.
in CompressType compress_type | The compress_type specifies the encoding format, Layer I or Layer II. |
If this flag is set Off, then the copyright bit in the MPEG-1 header is turned off; On turns the bit on, and indicates the audio material is copyrighted.
in OnOff flag | The enum type, flag, enables or disables the setting of the copyright bit in the header. |
This method sets the flag to add a 16-bit parity-check word for optional error protection within the encoded bitstream. The MPEG-1 decoder would check the integrity of the compressed data stream. Error checking should only be enabled where data integrity is a problem.
in OnOff flag | The enum type, flag, indicates whether error protection should be enabled or disabled. |
This method sets the MPEG-1 compressed audio bit rate. The combined audio and video compressed data rate is typically set to be less than 1.5 Megabits per second. Typical data rates are around 200 kilobits per second. Valid values for Mono files are 32 to 192 kbit/s. Valid values for stereo files are 64 to 384 kbit/s.
inout long bit_rate | The input value, bit_rate, requested by the user. The actual rate set is returned by the object and specifies the average compressed data rate. |
Set this flag to Off if the audio bitstream is a copy and On if the bitstream is an original.
in OnOff flag | The enum type, flag, sets the original bit in the MPEG-1 header. |
For introductory information, see Audio Codec Objects.