Question: Have you got any issues with "Joint-Stereo" MP3's?
I have a customer who sends me the attached MP3 and when I convert it to a mono format, it effectively cancels out the audio.

Answer: The problem is that in Mp3 Joint Stereo sound file mirror is opposite. For example the left channel = -1, and the right channel = +1.
When converting a file into single channels are merged: -1 + 1 = 0. So you hear the silence.
You can solve this problem in that way. Instead of combining the channels keep only one channel (left or right).
The code below solves this problem.
private void Mp3ToUlaw()
{
string FileName = @"d:\Work\10\SBL 6 Year 0511.mp3";
Mp3Reader mr = new Mp3Reader(File.OpenRead(FileName));
IntPtr formatMp3 = mr.ReadFormat();
IntPtr formatPcm = AudioCompressionManager.GetCompatibleFormat(formatMp3, AudioCompressionManager.PcmFormatTag);
byte[] dataMp3 = mr.ReadData();
byte[] dataPcm = AudioCompressionManager.Convert(formatMp3, formatPcm, dataMp3, false);
mr.Close();
IntPtr format8000 = AudioCompressionManager.GetPcmFormat(2, 16, 8000);
byte[] data8000 = AudioCompressionManager.Resample(formatPcm, dataPcm, format8000);
IntPtr formatMono = IntPtr.Zero;
byte[] dataLeft = null;
byte[] dataRight = null;
AudioCompressionManager.SplitStereo(format8000, data8000, ref formatMono, ref dataLeft, ref dataRight);
//mono 8bit 8Khz u-law format
IntPtr format = AudioCompressionManager.GetCompatibleFormat(formatMono, AudioCompressionManager.MuLawFormatTag);
byte[] data = AudioCompressionManager.Convert(formatMono, format, dataLeft, false);
WaveWriter ww = new WaveWriter(File.Create(FileName + ".wav"),
AudioCompressionManager.FormatBytes(format));
ww.WriteData(data);
ww.Close();
}
No comments:
Post a Comment