I think a technique like yours might work, but looking for the highest amplitude reached is not the right way to go, because it really won't give you an accurate idea of the "volume" of the song.

Here's an extreme example: consider a song that is quiet throughout, but has one single sample that sticks way up. Normalizing the song based on that one sample would still keep it too quiet. I think this is what Tony is referring to when he talks about dynamic range compression; it's a "peak to mean" ratio problem.

But with one simple change, I think your idea would work great. Instead of measuring the peak amplitude, measure the average power instead. In other words, square each sample's amplitude, add them up, and divide by the total number of samples. To translate that to a decibel measure, just take 10 * log10( value ). That's going to be a more accurate picture of the "volume level" of the song.

I've seen MP3 rippers that do this kind of normalization. But when they use it to modify the original MP3 file, the have to be careful not to introduce clipping. So they often will have a flag that prevents normalization if the peak amplitude exceeds, say, 95%.

With this little change I think your idea would work really well!

Michael


_________________________
Michael Grant 12GB Green 080000266