mp3 sounds distorted after imported to audacity

Help for Audacity on Windows.
Forum rules
ImageThis forum is for Audacity on Windows.
Please state which version of Windows you are using,
and the exact three-section version number of Audacity from "Help menu > About Audacity".


Audacity 1.2.x and 1.3.x are obsolete and no longer supported. If you still have those versions, please upgrade at https://www.audacityteam.org/download/.
The old forums for those versions are now closed, but you can still read the archives of the 1.2.x and 1.3.x forums.
jademan
Forum Crew
Posts: 1179
Joined: Fri Jul 17, 2009 10:11 pm
Operating System: Please select

Re: mp3 sounds distorted after imported to audacity

Post by jademan » Sun Feb 07, 2021 6:50 pm

DVDdoug wrote:
Sun Feb 07, 2021 5:57 pm
I think I found a fix with MP3Gain !
<snip>
P.S.
MP3directCut can also normalize without decoding/decompressing. After selecting Normalize, check the box that says "Check For Overdrive",
Congratulations!

I couldn't get MP3Gain to install the first time, so I tried installing MP3DirectCut. But the most recent version 2.32 has had its Overdrive check removed. I guess they were having problems with it. So I downloaded the 2.30 version from here: https://mp3directcut.en.uptodown.com/windows/versions
Trackpanel002.png
Trackpanel002.png (26.7 KiB) Viewed 114 times
Here are the waveforms:

From top to bottom left channel shown:
1) Audacity import
2) Audacity import amplified by -18
3) VLC recorded via stereo mix
4) Audacity/FFmpeg import
5) From MP3DirectCut 2.30 Normalize+Overdrive Check

jademan
Forum Crew
Posts: 1179
Joined: Fri Jul 17, 2009 10:11 pm
Operating System: Please select

Re: mp3 sounds distorted after imported to audacity

Post by jademan » Sun Feb 07, 2021 6:53 pm

DVDdoug wrote:
Sun Feb 07, 2021 5:57 pm
I think I found a fix with MP3Gain !
<snip>
P.S.
MP3directCut can also normalize without decoding/decompressing. After selecting Normalize, check the box that says "Check For Overdrive",
Congratulations!

I couldn't get MP3Gain to install the first time, so I tried installing MP3DirectCut. But the most recent version 2.32 has had its Overdrive check removed. I guess they were having problems with it. So I downloaded the 2.30 version from here: https://mp3directcut.en.uptodown.com/windows/versions

Here are the waveforms:
Trackpanel002.png
Trackpanel002.png (26.7 KiB) Viewed 113 times
From top to bottom left channel shown:
1) Audacity import
2) Audacity import amplified by -18
3) VLC recorded via stereo mix
4) Audacity/FFmpeg import
5) From MP3DirectCut 2.30 Normalize+Overdrive Check

We have a winner! :D

steve
Site Admin
Posts: 80752
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: mp3 sounds distorted after imported to audacity

Post by steve » Sun Feb 07, 2021 10:10 pm

Another fix using VLC from the command line:

Code: Select all

cvlc "test.mp3" --no-sout-video --sout-audio --sout "#transcode{acodec=fl32 channels=1}:std{access=file,mux=wav,dst=test.wav}"
The resulting file is 32-bit float and peaks at +16.415 dB (which is why it sounds so distorted with most decoders).
After normalizing in Audacity to 0 dB, this is the result:
test-normalized.wav
(1.16 MiB) Downloaded 6 times
(The command line example was for Linux. The exact command may be slightly different on other platforms - I just followed VLC's documentation.)
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

one_quick_question
Posts: 7
Joined: Wed Feb 03, 2021 5:35 pm
Operating System: Windows 10

Re: mp3 sounds distorted after imported to audacity

Post by one_quick_question » Tue Feb 09, 2021 2:31 am

jademan wrote:
Sun Feb 07, 2021 4:53 pm
FWIW, I thought I would take a look at this.

I tried loading and playing test.mp3 in Audacity and in VLC. There is significant overmodulation in Audacity. When the Audio is loaded into Audacity (drag-and-drop), the Amplify effect uses -18.051 to bring it down to full scale - go figure! When I look closely at the peaks, there is apparent damage, but they are not flat as I might have suspected. And upon playing, the audio still sounds heavily damaged.

However, when I played test.mp3 in VLC 3.0.12 (windows), the audio played clearly and there was no distortion whatsoever.

I tried DVDdoug's suggestions:
FFmpeg import into Audacity: audio is heavily clipped at 1.0 as one might expect, so unlike Audacity import, no change with Amplify effect. Curiously, audio "sounds" much closer to VLC than to Audacity's import, but sound seems bassier and muddled.

Tried Kabuu Audio Converter: this was identical to FFmpeg's import. The only difference was dither. inverted this track, then mixed it with the FFmpeg track and found only about -90dB signal remaining.

Tried TAudioConverter: I had an installation error (BASS.dll not found) (both 32-bit and 64-bit versions).

So curiously, I tried playing the mp3 file via VLC and recording with Audacity. Here is what I saw:
Trackpanel000.png
Top = VLC, Bottom = FFmpeg. Note that the VLC curve does not clip. So it appears that VLC has some "magic" code the others do not have that fixes the problem.

:ugeek: ===================================== :ugeek:
MP3Diags (unstable) 1.501 reported:

====>MP3GAIN_MINMAX="122,238", MP3GAIN_UNDO="-028,-028,N", REPLAYGAIN_TRACK_GAIN="-5.330000 dB", REPLAYGAIN_TRACK_PEAK="6.618240"<=====

*No ID3V2.3.0 tag found, although this is the most popular tag for storing song information.

*ID3V2 tag doesn't have an APIC frame (which is used to store images).
:padding=0, unsynch=no; frames: TSSE="Lavf54.20.4"

:MPEG-1 Layer III, Stereo, 44100Hz, 48000bps, CRC=no; [Xing header info: frame count=134, byte count=56162, TOC present]

*Low quality MPEG audio stream. (What is considered "low quality" can be changed in the configuration dialog, under "Quality thresholds".)
:0:03, MPEG-1 Layer III, Joint stereo, 44100Hz, 128000bps CBR, CRC=no, frame count=134; last frame located at 0xd9e1
:ugeek: ===================================== :ugeek:

VLC has some "magic" code the others do not have that fixes the problem. Keep smiling. :D
Thanks a lot for your analysis!!!
Somehow I didn't think about analyzing the recorde vlc ouput in audacity. And I seem to have missed the MP3Diag tool gain part (tbh the whole thing seems a bit confusing to me)

one_quick_question
Posts: 7
Joined: Wed Feb 03, 2021 5:35 pm
Operating System: Windows 10

Re: mp3 sounds distorted after imported to audacity

Post by one_quick_question » Tue Feb 09, 2021 2:43 am

steve wrote:
Sun Feb 07, 2021 10:10 pm
Another fix using VLC from the command line:

Code: Select all

cvlc "test.mp3" --no-sout-video --sout-audio --sout "#transcode{acodec=fl32 channels=1}:std{access=file,mux=wav,dst=test.wav}"
The resulting file is 32-bit float and peaks at +16.415 dB (which is why it sounds so distorted with most decoders).
After normalizing in Audacity to 0 dB, this is the result:

test-normalized.wav

(The command line example was for Linux. The exact command may be slightly different on other platforms - I just followed VLC's documentation.)
Thanks a lot!
My solution: I ended up converting all of the files with vlc to mp3, but applying the normalize volume audio filter.
Tbh i i didn't think I had enough knowledge of audio to set all those parameters correctly and use the command line.
DVDdoug wrote:
Sun Feb 07, 2021 5:57 pm
I think I found a fix with MP3Gain !

Make a backup because MP3Gain changes the actual selected file.

Under options select Don't Clip.
Then select Modify Gain and Apply Track Gain.

It looks like the only problem is that it goes over 0dB and most decoders are clipping or distorting when you open or convert the file. Apparently, VLC can decode without clipping and it looks like VLC is also automatically normalizing the file (bringing down the volume for 0dB peaks).

MP3Gain changes the level without decoding.

P.S.
MP3directCut can also normalize without decoding/decompressing. After selecting Normalize, check the box that says "Check For Overdrive",
Also thanks to you!!!
jademan wrote:
Sun Feb 07, 2021 6:53 pm
DVDdoug wrote:
Sun Feb 07, 2021 5:57 pm
I think I found a fix with MP3Gain !
<snip>
P.S.
MP3directCut can also normalize without decoding/decompressing. After selecting Normalize, check the box that says "Check For Overdrive",
Congratulations!

I couldn't get MP3Gain to install the first time, so I tried installing MP3DirectCut. But the most recent version 2.32 has had its Overdrive check removed. I guess they were having problems with it. So I downloaded the 2.30 version from here: https://mp3directcut.en.uptodown.com/windows/versions

Here are the waveforms:
Trackpanel002.png
From top to bottom left channel shown:
1) Audacity import
2) Audacity import amplified by -18
3) VLC recorded via stereo mix
4) Audacity/FFmpeg import
5) From MP3DirectCut 2.30 Normalize+Overdrive Check

We have a winner! :D
I wish I had seen this before doing my vlc fix.
Since the vlc gui doesn't allow you to specify a destination folder when converting multiple files, I had to use some options which adds "--converted" in the file name. Removing this string again in windows actually required me to write a PowerShell one liner using regex....


So again: Big thanks for your help to you all!!!

steve
Site Admin
Posts: 80752
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: mp3 sounds distorted after imported to audacity

Post by steve » Tue Feb 09, 2021 10:38 am

one_quick_question wrote:
Tue Feb 09, 2021 2:43 am
My solution: I ended up converting all of the files with vlc to mp3, but applying the normalize volume audio filter.
Tbh i i didn't think I had enough knowledge of audio to set all those parameters correctly and use the command line.
Your way is absolutely fine. The only reason I was messing with the command line was because I was curious about what was going on.

My observations and "best guesses" at what's going on with that file:

1. The MP3 is faulty. Several of the command line tools reported errors in the file, indicating encoding and metadata errors.

2. The actual peak level of the audio is +16.415 dB

3. The file contains ReplayGain metadata, and correctly reports the peak level as 6.6182 (linear) = +16.414850 dB.

4. Most MP3 decoders appear to decode directly to 16-bit integer, which clips at 0 dB

5. Audacity's MP3 importer can handle "over 0 dB" MP3 files, but only up to +10 dB.

6. VLC (Windows) could play without distortion because it appears to apply ReplayGain peak correction before converting to 16-bit integer.

7. The VLC decoder is remarkably fault tolerant with MP3 files.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

jademan
Forum Crew
Posts: 1179
Joined: Fri Jul 17, 2009 10:11 pm
Operating System: Please select

Re: mp3 sounds distorted after imported to audacity

Post by jademan » Tue Feb 09, 2021 1:49 pm

one_quick_question wrote:
Tue Feb 09, 2021 2:43 am
Thanks a lot!
My solution: I ended up converting all of the files with vlc to mp3, but applying the normalize volume audio filter.
Tbh i i didn't think I had enough knowledge of audio to set all those parameters correctly and use the command line.

<snip>

Also thanks to you!!!
I wish I had seen this before doing my vlc fix.
Since the vlc gui doesn't allow you to specify a destination folder when converting multiple files, I had to use some options which adds "--converted" in the file name. Removing this string again in windows actually required me to write a PowerShell one liner using regex....

<snip>

So again: Big thanks for your help to you all!!!
:D You are quite welcome :D
one_quick_question wrote:
Tue Feb 09, 2021 2:43 am
I wish I had seen this before doing my vlc fix.
:D Not a problem.
I think we were all more curious as to what was happening. You deserve the accolades yourself for recognizing the discrepency. :D

Post Reply