naudio / NLayer

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

Strange result when convert MP3 to WAV with NLayer #19

Closed kamchii closed 2 years ago

kamchii commented 4 years ago

I have mp3 file created with NAudio.Lame. Conversion to wav with naudio (with default acm driver) is ok, but with nlayer result is noised. Please help, I don't understand my mp3 file corrupted or NLayer has some restriction I didn't notice? Project (code+mp3 file): TestNLayer.zip

How it looks in Audacity (first row original mp3, second wav by naudio, third by nlayer): TestNLayer

ioctlLR commented 4 years ago

OK, looks like NLayer's MPEG2 Layer III decoding isn't quite right... Best guess is it's reading the scale factors incorrectly, but I'd have to compare what NLayer is doing vs. a known-good decoder. That might take me some time.

Lexiphan commented 3 years ago

I have similar problem. Example file: TestMp3File_and_ConvertResult.zip

LeatonChuter commented 3 years ago

Me too, converting from MP3 to Wav is substantially reducing the quality of the audio by adding some sort of noise.

mikegoatly commented 2 years ago

OK, looks like NLayer's MPEG2 Layer III decoding isn't quite right... Best guess is it's reading the scale factors incorrectly, but I'd have to compare what NLayer is doing vs. a known-good decoder. That might take me some time.

@ioctlLR I realise this issue is a couple of years old now, but I strongly suspect the issue I was running into was this. Hopefully my PR makes sense - I think it's in the area your intuition was leading you towards.

mikegoatly commented 2 years ago

I've just tested the sample file that @kamchii attached and it looks like this does fix the reported issue as well:

image

The first is decoded by Audacity, the second is NLayer without the fix, the third is with the fix.

I notice that the duration of the NLayer-decoded version is slightly different to the Audacity decoded version, but given that's true without the fix in place I suspect that's a completely different issue.

ocinon commented 1 year ago

@ioctlLR @mikegoatly I tried converting an mp3 file with 44.1 kHz today and got very noisy results. As far as I can tell from the MR, only the values for 16, 22.05, and 24 kHz were changed. Could it be that the other bands need to be corrected as well?

mikegoatly commented 1 year ago

I wouldn't rule it out - I don't remember seeing any other differences though.

AlekseyMartynov commented 1 year ago

NuGet package v1.14.0 still has this bug, master branch is OK.

markheath commented 10 months ago

Have published v1.15.0