(SOT) Programmatically detecting normalized wav files
Forum rules
Audacity 1.2.x is now obsolete. Please use the current Audacity 2.1.x version.
The final version of Audacity for Windows 98/ME is the legacy 2.0.0 version.
Audacity 1.2.x is now obsolete. Please use the current Audacity 2.1.x version.
The final version of Audacity for Windows 98/ME is the legacy 2.0.0 version.
-
dgoldsmith
- Posts: 26
- Joined: Mon Apr 06, 2009 8:25 pm
- Operating System: Please select
(SOT) Programmatically detecting normalized wav files
Hi, folks. I have a bunch of wav files - some are normalized (using audacity), some are not, and I don't know which are which. I'd like to write a Python script that can figure out which are which; is there some way, just by reading a wav file as binary data, to detect if it's normalized, e.g., grab it in 16 bit chunks (after a suitable offset), looking for a sequence of 16 ones? Or is the "signal" portion of a wav file encoded such that that wouldn't work, even if I could figure out the correct offset? Any other ideas? Thanks!
DG
DG
-
kozikowski
- Forum Staff
- Posts: 69357
- Joined: Thu Aug 02, 2007 5:57 pm
- Operating System: macOS 10.13 High Sierra
Re: (SOT) Programmatically detecting normalized wav files
Since you can't do that, you should probably tell us what you're really trying to do.
Audacity tracks can be normalized and amplified (cousin tools) to any number. You can easily have a natural track that looks like it's been normalized but hasn't. So there's no goal to code for.
Koz
Audacity tracks can be normalized and amplified (cousin tools) to any number. You can easily have a natural track that looks like it's been normalized but hasn't. So there's no goal to code for.
Koz
Re: (SOT) Programmatically detecting normalized wav files
If you normalized a track to 0dB in Audacity there will be at least one sample per track that is + or - 1.0. However, since Normalizing works to bring the highest peak up to the target level there may only be one sample that is at +/- 1.0 and it could be anywhere in the track.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
-
dgoldsmith
- Posts: 26
- Joined: Mon Apr 06, 2009 8:25 pm
- Operating System: Please select
Re: (SOT) Programmatically detecting normalized wav files
Precisely what I state: sort the tracks into normalized and not normalizedKoz: Since you can't do that, you should probably tell us what you're really trying to do.
I always normalize to the maximum level that won't clip any portion (leaving it to Audacity to figure out what that should be for the given track, which it appears to do quite well); in other words, I just select normalize, and Audacity makes the maximum amplitude 1dB - more than that, I do not know.Koz: Audacity tracks can be normalized and amplified (cousin tools) to any number. You can easily have a natural track that looks like it's been normalized but hasn't. So there's no goal to code for.
See above.stevethefiddle: If you normalized a track to 0dB in Audacity
The amplitudes are stored as floats between + and -1???there will be at least one sample per track that is + or - 1.0.
I know that, that's why I want to write a program to find it!However, since Normalizing works to bring the highest peak up to the target level there may only be one sample that is at +/- 1.0 and it could be anywhere in the track.
DG
-
kozikowski
- Forum Staff
- Posts: 69357
- Joined: Thu Aug 02, 2007 5:57 pm
- Operating System: macOS 10.13 High Sierra
Re: (SOT) Programmatically detecting normalized wav files
<<<Audacity makes the maximum amplitude 1dB - more than that, I do not know.>>>
I hope not. Undistorted audio goes from 0 dBFS and down. Not up. All negative numbers. Default Normalize and Amplify are both 0, not -1dB. You can change the value to anything including +1 by clicking on "Distortion is OK."
The difference between the two tools is Amplify applies one correction to both tracks (Left and Right) of the whole show and Normalize changes each track individually.
<<<Precisely what I state: sort the tracks into normalized and not normalized>>>
Because you intend to do something to one of the two sets? You're describing a poem that stops in the wrong place.
Koz
I hope not. Undistorted audio goes from 0 dBFS and down. Not up. All negative numbers. Default Normalize and Amplify are both 0, not -1dB. You can change the value to anything including +1 by clicking on "Distortion is OK."
The difference between the two tools is Amplify applies one correction to both tracks (Left and Right) of the whole show and Normalize changes each track individually.
<<<Precisely what I state: sort the tracks into normalized and not normalized>>>
Because you intend to do something to one of the two sets? You're describing a poem that stops in the wrong place.
Koz
Re: (SOT) Programmatically detecting normalized wav files
In Audacity, yes. After it has been exported as an audio file, then it depends on the file format.dgoldsmith wrote:The amplitudes are stored as floats between + and -1???
A quick way in Audacity to see if a file has been normalized: Select the "Amplify" effect and if the track has been normalised to 0dB the Amplify effect will indicate an amplification amount of 0.0dB.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
-
dgoldsmith
- Posts: 26
- Joined: Mon Apr 06, 2009 8:25 pm
- Operating System: Please select
Re: (SOT) Programmatically detecting normalized wav files
OK, I guess dB is the wrong unit; what is the unit of the ordinate (i.e., along the y-axis) when you load a track into the editing window, and the wave form is plotted between -1 and +1? What ever it is, that's what I'm referring to when I speak of normalize making the maximum amplitude + or -1.I hope not. Undistorted audio goes from 0 dBFS and down. Not up. All negative numbers. Default Normalize and Amplify are both 0, not -1dB. You can change the value to anything including +1 by clicking on "Distortion is OK."
Normalize the ones I haven't.Because you intend to do something to one of the two sets? You're describing a poem that stops in the wrong place.
That's why I marked my subject "SOT" (slightly off topic): I want to scan _wav_ files (not audacity files, and not using audacity, unless audacity can do that, which would be pleasant "news to me"; I thought I was pretty clear about what I wanted to do in my original post) to determine if they've been normalized.In Audacity, yes. After it has been exported as an audio file, then it depends on the file format.
Can that be done programatically, e.g., using a chain? (I know I can do that manually, but I have tens of thousands of files I want to check - there's no way I'm checking 'em all "by hand"; if it turns out there's just no way to programatically sort them as I want, I'll just have to re-apply my normalize chain to everything - I just don't want to have to waste the time reapplying it to ones I've already applied it to if I can find some way not to.)A quick way in Audacity to see if a file has been normalized: Select the "Amplify" effect and if the track has been normalised to 0dB the Amplify effect will indicate an amplification amount of 0.0dB.
Thanks!
DG
-
kozikowski
- Forum Staff
- Posts: 69357
- Joined: Thu Aug 02, 2007 5:57 pm
- Operating System: macOS 10.13 High Sierra
Re: (SOT) Programmatically detecting normalized wav files
<<<Normalize the ones I haven't.>>>
Normalize will have no effect on the ones already normalized. That's one of its talents. The Normalize available range of corrections includes zero.
Koz
Normalize will have no effect on the ones already normalized. That's one of its talents. The Normalize available range of corrections includes zero.
Koz
-
dgoldsmith
- Posts: 26
- Joined: Mon Apr 06, 2009 8:25 pm
- Operating System: Please select
Re: (SOT) Programmatically detecting normalized wav files
I know that (that's what I'll be taking advantage of if I have to just re-apply normalize to everything), but can it determine whether or not a file has been normalized w/out having to read it in to the editor, e.g., when used in a chain? For 10000 files, approx. 7000 of which have already been normalized, if it has to read the file in to the editor before it can determine whether or not it's pointless to continue, well, that's a lot of wasted CPU time.Normalize will have no effect on the ones already normalized. That's one of its talents. The Normalize available range of corrections includes zero.
DG
Re: (SOT) Programmatically detecting normalized wav files
This question has changed in emphasis quite considerably since the first post where we were looking at sorting "a bunch of wav files". I guess that 10000 files could still be described as "a bunch" but it's a darned big bunch. A bit more information could help to come up with the best solution, for example - could the "last modified" date tell you which have been normalised?dgoldsmith wrote:I know that (that's what I'll be taking advantage of if I have to just re-apply normalize to everything), but can it determine whether or not a file has been normalized w/out having to read it in to the editor, e.g., when used in a chain? For 10000 files, approx. 7000 of which have already been normalized,
If you need to batch process all of the files you will probably find "SOX" a lot more efficient than Audacity. http://sox.sourceforge.net/
The basic command for normalising with SOX is:
Code: Select all
sox --norm infile -b 16 outfile rate 44100 dither -s
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)