Normalise MP3's

For everything that's not in any way related to PureBasic. General chat etc...
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post by ricardo »

Don't want to be 'heavy', but want to explain one more thing:

In fact in radio broadcast or even in live concerts they DO 'normalize' the music.

When you go to a rock live concert, the idea behind the enigneer is NOT the same as if they where in studio.

At live concert they use limiter,s compressonr, etc. to make sue you listen almost at same level if the singer whisper or if he scream. They HAVE to make sure that EVERYTHING get to the people and almost at same level.

The idea behind radio broadcasting is not to different.

Ofcourse NONE of both are REALLY high quality, because they are sending info to noise environments and want to make sure that people receive all info.

Yes, they sacrified quality... but is a rock concert!! :twisted:

Its NOT the same if you go to listen a Mozart concert is a NOT noisy environment... AND Mozart music HAS dinamyc... most modern music don't have it at all.
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

PB wrote:> Just found MP3Gain through google

I've been using MP3Gain for years and recommend it! Free, and it isn't a lossy
conversion because it only adjusts the MP3 volume without recompressing.
Very easy to adjust new MP3s to the same volume as previous ones too.
Yeah, it is very easy, a couple of clicks and it's away. Thanks for the info about it not being lossy. Always good to know if someone has been using it. :)
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

ricardo wrote:In second place, the idea behind normalizing is to let people listen all the song and many passages of the music at an audible level without needing to raise to much the volume of the player.
That's not right. Normalizing means to scan for the highest peak value and
amplify the rest accordingly, so that the highest peak will be at a given
value (most likely somewhere around 0db). No changes to the dynamic
are applied.

What you mean is compression or in that case limiting, which squashes
the dynamic, thus making a song sound loud from beginning to end,
which is what we hear on every professional album since 1960 or something.
Compression everywhere.

Rescator is totally right with his hint about the levels of old vs. new recordings.
Good programmers don't comment their code. It was hard to write, should be hard to read.
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post by ricardo »

traumatic wrote:
ricardo wrote:In second place, the idea behind normalizing is to let people listen all the song and many passages of the music at an audible level without needing to raise to much the volume of the player.
That's not right. Normalizing means to scan for the highest peak value and
amplify the rest accordingly, so that the highest peak will be at a given
value (most likely somewhere around 0db). No changes to the dynamic
are applied.

What you mean is compression or in that case limiting, which squashes
the dynamic, thus making a song sound loud from beginning to end,
which is what we hear on every professional album since 1960 or something.
Compression everywhere.

Rescator is totally right with his hint about the levels of old vs. new recordings.
I think you are wrong.

What you or anyone hear in any album is NOT that. Its a finall mix done by the engineer choice on giving levels, eqs, panning, etc. and of course the idea is NOT to have everything at louder levels. THATS WHY PEOPLE NEED NORMALIZERS NOW.

If recording studios normalize their albums, nobody needs to normalize now.

And thats something COMPLET different to the approach for live concerts or broadcasting where they DO normalize (let me use the term).

Once we agree with that, have to understand that listening mp3s is similar to some autobroadcast, nothing to do with high quality.
Its very similar to listen to the radio, where YES crompressing, limitors, etc. takes the place for make all sounds more or less the same.

About 'normalizing'... it means a lot of different things because are used by common people.

I think that atm people don't look for replay gain when search for a 'normalizer', but looks to have something applied to his music that make every song (and part of the song) to sound more or less at an audible level if you are in a noise environment.

The peak theory is oldfashion and outdated in my point of view, since it don't give any guaranty that the song will be audible if you try to listen it in the middle of avenue traffic.

Times when people seat in front a hifi looking at the album images and ONLY listining the music (at high level) its about 70s and 80s, not 2000.

In fact, the Sony Walkman (80s) was the first step to that not well defined thing that people tend to call normalize.

*Its like TV. At the beggining the TV was in the livingroom... now TV are at kitchen, rooms, etc. Well, same happends with listening music, now its everywhere, not only in the fron of a hifi equipment and as noise is everywhere, pleople need to give some push to the volume level to be able to hear it.
Nobody feels that needs a normalizer in the 80s, because people listen music in a silent environment, seating in fron of a hifi. Now that idea is outdated, mp3s are verywhere.
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

Ricardo, maybe we're talking about the same thing using different terms,
I don't know. The thing is, "normalizing" does NOT mean a dozen of different
things, it's used for what I described (peak-level).

Normalizing does NOT affect the dynamic.

This is not about "mine's bigger than yours" but I recorded, mixed and
mastered enough records to absolutely know what I am talking about.

Well, I don't want to argue on that, normalization is just a fixed term,
leading to "conversation trouble" (like we have now) when used incorrectly.
Good programmers don't comment their code. It was hard to write, should be hard to read.
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post by Rings »

well, in 'mixing & making music' i'm a totaly novice
(or Aprentice,lamer or just in normal words a beginner).
For my next project (MP3 kbs-converter) i need
also a normalizer as a plugin.
Well, before talking bullshit (remember i'm a novice)
i put some code here to talk about.
don't argue that it is win32 only, but i use
Filemapping for speed.

a short description how my algo works :
-enumerate whole data and get peaks for left&right
-Set max-Distance ($FFFF - TopPeak) for left&right
-put back this distance.

for a test, i also put a dynamic in it
(experimental, coz you already know, i'm a novice)

no here is the code:
(please test with a copy of a 16bit stereo file only)

Code: Select all

;Normalize WAV file(s)
;please test with copy's only !!
;(C) 2007 by Siegfried Rings

Structure WAV
 ChunkName.c[4] ;'RIFF'
 ChunkLen.l     ;
 RiffType.c[4]  ;'WAVE' 
EndStructure 

Structure FMT
 ChunkName.c[4] ;'FMT '
 ChunkLen.l     ;= 16
 Format.w       ;= 0 = Mono 1=Stereo
 ChannelCount.w ;on stereo 2
 SampleRate.l   ;in hz
 BytesPerSecond.l
 BytesperSample.w ; 1=8 Bit Mono 2=8 Bit Stereo or 16Bit Mono 4=16Bit Stereo
 BitsperSample.w  ;8, 12 or 16
EndStructure 

Structure DataChunk
 ChunkName.c[4] ;'DATA'
 ChunkLen.l     ;= n
 ;Data.c[n]
EndStructure


Filename.s="c:\test.wav"
Filename=OpenFileRequester("choose wav file to normalize",Filename,"*.WAV|*.WAV",0)


length=FileSize(Filename)
If length>0 



Debug Str(length)+" bytes  "+ Filename
;I will use filemapping, a bit faster then ;
 handle=CreateFile_(Filename, #GENERIC_READ+#GENERIC_WRITE	, 3, 0, 3, #OPEN_EXISTING ,0)
 If handle
  MapHandle = CreateFileMapping_(handle, 0, #PAGE_READWRITE, 0, length, 0)
  If MapHandle
   ViewHandle = MapViewOfFile_(MapHandle, #FILE_MAP_ALL_ACCESS	, 0, 0, 0)
   If ViewHandle
     
     
     lRiffHeader=SizeOf(WAV);12
     lFMTChunk=SizeOf(FMT) ;24
     
     *MyWav.WAV=Viewhandle
     *MyFMT.FMT=Viewhandle + lRiffHeader
     *MyDataChunk.DataChunk=Viewhandle + lRiffHeader + lFMTChunk
     
     ;Valid WAV File ?
     Debug PeekS( @ *MyWav\Chunkname, 4 ) 
     Debug PeekS( @ *MyFMT\Chunkname, 4)
     Debug PeekS( @ *MyDataChunk\Chunkname, 4)
     
     Debug "Datablocklength=" + Str(*MyDataChunk\ChunkLen) 
     
     Debug Str(*MyDataChunk\ChunkLen / (*MyFMT\BytesPerSecond ) ) +" Seconds"
     
     Distance=lRiffHeader + lFMTChunk + SizeOf(DataChunk)
     
     adr=Viewhandle + Distance ;Adr in Memory where data begins
     Debug adr-viewhandle
     
     
     
     
     MaxFrames=*MyDataChunk\ChunkLen / (2*2)  ;2 channels a 2 byte is 4 byte per sample
     Value.l
     
     
     ;First Scan, get MaxValues
     For I=1 To MaxFrames
      ;Left Value
      Value=0;PeekW(adr)
      CopyMemory(adr,@Value,2)
      If MaxAmplitudeLeft<Value:MaxAmplitudeLeft = Value:EndIf
      adr + 2
      
      ;Right Value
      Value=0;PeekW(adr)
      CopyMemory(adr,@value,2)
      If MaxAmplitudeRight<Value:MaxAmplitudeRight = Value:EndIf
       adr + 2
     Next I


      Debug "------------"
      Debug MaxAmplitudeLeft
      Debug MaxAmplitudeRight
     
      StepL=65536-MaxAmplitudeLeft
      StepR=65536-MaxAmplitudeRight 
      
      Dynamic=$FFFF/4 ;To increase complete Loudness about 1/4, set this 
      Dynamic=$1FF
      Dynamic=0
      
     ;Next Step, normalize
      adr=Viewhandle + Distance ;Adr in Memory where data begins
     ;First Scan, get MaxValues
     For I=1 To MaxFrames
      ;Left Value
      Value=0;PeekW(adr)
      CopyMemory(adr,@Value,2) ;Get Value from file
      Value + Stepl
      
      Value + Dynamic: If Value>$FFFF: Value=$FFFF:EndIf
      
      CopyMemory(@Value,adr,2) ;copy back to file
      adr + 2
      
      ;Right Value
      Value=0;PeekW(adr)
      CopyMemory(adr,@value,2)
      Value + StepR
      Value + Dynamic: If Value>$FFFF: Value=$FFFF:EndIf
      CopyMemory(@Value,adr,2) ;copy back to file
      adr + 2
     
     Next I


    UnmapViewOfFile_(ViewHandle)
   EndIf
  EndIf
  CloseHandle_(MapHandle)  ;okay, now close the Maphandle
 EndIf
 CloseHandle_(handle);okay, now close the Filehandle 
 Debug "ready"

EndIf
so, the non-novice can put their comments here (please)
SPAMINATOR NR.1
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post by ricardo »

traumatic wrote:Ricardo, maybe we're talking about the same thing using different terms,
I don't know. The thing is, "normalizing" does NOT mean a dozen of different
things, it's used for what I described (peak-level).

Normalizing does NOT affect the dynamic.

This is not about "mine's bigger than yours" but I recorded, mixed and
mastered enough records to absolutely know what I am talking about.

Well, I don't want to argue on that, normalization is just a fixed term,
leading to "conversation trouble" (like we have now) when used incorrectly.
Yes, this is a friendly conversation, count with that.

But, however im not agree with what you said.

In first place the absence of dynamics in modern music is not because any compression, its because the music itself. In any real professional mastering, the engineer try to apply dynamics as much as possible (as much as the poor music allows it).

In second place, in every professional mastering all song has it peaks fine.

The concepts involved in mastering or even in a professional home listening has NOTHING to do with mp3 and nothing to do with doing things like normalize.

The error i found in some arguments is trying to extrapolate concepts from professional mastering to something like playing mp3s in winamp in a PC or in a protable player!!!

Thats a nonsense in my opinion.

As i explained before, if music where played in a appropiate equipment and environment nobody needs to normalize nothing.

Thats why the normalize concept is very recent, at least its being know by many people now, not in the past... and that because its NOW that people feels that need to do SOMETHING to they files.

If you buy 10 great CDs and listen to it in an appropiate equipment and envirmonment, you will never feel you need to make something to that albums.

BUT when you encode this same albums to mp3 and play ot in portable mp3 player or in your PC... you may start feeling that something is not fine... and much more if you use to listen your mp3s in noise envirnments and MUCH MORE if you get your files from here and there (not all encoded by same encoder, etc).

I know that in theory the normalize reffer about peak normalize... but THAT concept is obsolete for the usage people are trying to do.

Maybe people need to use a new term, that don't really mean normalize or replay gain (another non satisfactory way to try to resolve the problem)... but atm people are looking for a 'normalizer' when trying to resolve the problem that i describe.

Then, imho, the solution for the problem that people find when:

-Listen mp3s in computer, portable players, etc.
-Get songs from many sources
-Listen to them in noise situations

Solution to this problem is not peak normalizing and not replay gain.

But people still call normalizing what they are looking for.

Try to use professional concepts to this specific situations are in imho a mistake.
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post by ricardo »

Rings wrote: so, the non-novice can put their comments here (please)
I take a fast lookm into your code.
I think that you are trying to find peaks and increase all.

In my opinion, its very easy to get some results similar to distortion. In the other hand, problem will persist for people playing mp3s in computer/portable devices, etc.

In my personal experience the way to resolve this is more complicated. You need to have models (curves) and then compare what you are reading from the file with that curves and as a results of that comparison make the needed changes.

Increasing all in the same level or without models (the curves i describe) in many cases will not be the appropiate answer or can even add indeseable results... thats only my personal opinion.
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post by Rings »

i found some resource here:

https://neon1.net/prog/normalizer.html

so, there is all i need, a fine small prg that
can normalize wav files in a batch mode
SPAMINATOR NR.1
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post by ricardo »

Rings wrote:i found some resource here:

https://neon1.net/prog/normalizer.html

so, there is all i need, a fine small prg that
can normalize wav files in a batch mode
Yes, this sounds that has some appropiate approachs (build some curves in memory to compare and use what he call 'smart peaks' and not absolute peaks).

Im using a different approach, but this one you point sounds interesting.

Personally i use some 'ideal' curve in memory and let my app to 'learn' from the file its normalizing to find the optimal one for this file. Just a different approach, not neccesary better, but gives me good results.

But again, the one you are pointing sound interesteing.

Did you hear resullts? Because in this matter the theory many times sound fine, but no the results (I learn this when researching for developing mine).
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

ricardo wrote:Yes, this is a friendly conversation, count with that.
Good, same here :)

But we're up to a point where this talk turns out reeeaaally leisured and
straining, so I think we'd better stop this here.
Good programmers don't comment their code. It was hard to write, should be hard to read.
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post by ricardo »

traumatic wrote:
ricardo wrote:Yes, this is a friendly conversation, count with that.
Good, same here :)

But we're up to a point where this talk turns out reeeaaally leisured and
straining, so I think we'd better stop this here.
Ok, lets take a beer and talk about womans he he :P
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

ricardo wrote:Ok, lets take a beer and talk about womans he he :P
:D
Good programmers don't comment their code. It was hard to write, should be hard to read.
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

No, carry on, I was enjoying thinking it was because of me that you too were arguing. :twisted:
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post by ricardo »

Rings wrote:i found some resource here:

https://neon1.net/prog/normalizer.html

so, there is all i need, a fine small prg that
can normalize wav files in a batch mode
I hope you add some media library to your app, because i feel that there is no 'definitive' media library yet. I tried many but none make my ahppy yet.
Post Reply