naudio / NLayer

MPEG 1 & 2 Decoder for Layers 1, 2, & 3
MIT License
123 stars 30 forks source link

Issue converting MP3 to Wav files. #24

Open richardlatterPBA opened 3 years ago

richardlatterPBA commented 3 years ago

Hello All, I have an issue with converting from MP3 to Wav files using NLayer. There appears to be an anomaly when creating the .wav file. Let me explain. Steps.

  1. Using Audacity, I create a tone waveform to 10 minutes and save this as .mp3 file (Tone-10m.mp3).

  2. Using the following code (see below), I convert this to a .wav file (Tone-10m-to-wave.wav).

` static void Main(string[] args) {

        // set up source and target files
        var sourceFile = Path.Combine("C:\\tmp", "Tone-1m.mp3");
        var targetFile = Path.Combine("C:\\tmp", "Tone-1m-to-wave.wav");

        // create the builder
        var builder = new Mp3FileReaderBase.FrameDecompressorBuilder(wf => new Mp3FrameDecompressor(wf));

        // write the wav file
        using (var reader = new Mp3FileReaderBase(sourceFile, builder))
        {
            WaveFileWriter.CreateWaveFile(targetFile, reader);
        }

        Console.WriteLine("Done!");

    }`
  1. Comparing the two, waveforms in Audacity, I can see at 1.38m, 5.12m and at 8.46m there are spikes in the waveform. See original .mp3 and processed.wav files below.

  2. Processing other more musical waveforms, I cannot see any other anomalies. This seems to be just on this, but I’m wondering if there is a bug in the code somewhere.

Has anyone else experienced this?

tempsnip

Mp3ToWavConversion.zip