I am using the UMC MP3Encoder class. I am having trouble figuring out how to handle audio files with 8 bits per sample. When trying to encode these files, I get distorted audio (the MP3 audio that results from the encoding is about half the length that it should be and vocals sound like a chipmunk). This only happens when I am working with WAV files that have a bits per sample of 8. When I test files with 16 it works fine.
Is there something I am doing wrong with my initialization:
// Read wav file into buffer
.... Read in WAV file ....
// Setup encoder defaults
MP3EncoderParams.m_pData = &inMediaBuffer;
MP3EncoderParams.m_info_in.sample_frequency = wavInfo.sample_rate;
MP3EncoderParams.m_info_in.channels = wavInfo.channels_number;
MP3EncoderParams.m_info_in.channel_mask = wavInfo.channel_mask;
MP3EncoderParams.m_info_in.bitPerSample = wavInfo.resolution;
MP3EncoderParams.m_info_out.bitrate = 128000;
MP3EncoderParams.m_info_out.sample_frequency = wavInfo.sample_rate;
MP3EncoderParams.m_info_out.channels = wavInfo.channels_number;
MP3EncoderParams.m_info_out.channel_mask = wavInfo.channel_mask;
MP3EncoderParams.m_info_out.stream_type = UMC::MP1L3_AUDIO;
MP3EncoderParams.m_info_out.bitPerSample = wavInfo.resolution;
// Initialize encoder
Thanks for your help.
There is comment from our expert:
Input stream format for all UMC audio encoders is 16 bit PCM. To encode 8 bit per sample audio stream you should convert it to 16 bit audio stream. You should also take into account that 8 bit stream can have linear, mu-law or a-law format (information about actual format of your file you can find in the WAV file header)