LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-07-2012, 10:22 PM   #1
replica9000
Senior Member
 
Registered: Jul 2006
Distribution: Debian Unstable
Posts: 1,129
Blog Entries: 2

Rep: Reputation: 260Reputation: 260Reputation: 260
CLI tool to detect amount of clipping in audio file


http://ompldr.org/vZzZyZw

The above image is the same song from two different sources. The red shows the audio that is being clipped, which doesn't sound very nice.

What I'm looking for is a command line too that could output some numbers showing how much clipping a song has, or how compressed the dynamic range is.
 
Old 11-09-2012, 08:22 AM   #2
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Member Response

Hi,

You might look at WavPack 4.60 beta available, Windows and Linux versions older version, not sure if project is still active.

I think you can use 'CLI' or 'GUI'.

HTH!
 
Old 11-09-2012, 08:40 AM   #3
replica9000
Senior Member
 
Registered: Jul 2006
Distribution: Debian Unstable
Posts: 1,129

Original Poster
Blog Entries: 2

Rep: Reputation: 260Reputation: 260Reputation: 260
Thanks for the suggestion, but I'm not sure how this helps me...
 
Old 11-09-2012, 10:23 AM   #4
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
The 'sox' 'stat' and 'stats' commands can be used to determine clipping. See the man page.
 
1 members found this post helpful.
Old 11-09-2012, 04:05 PM   #5
replica9000
Senior Member
 
Registered: Jul 2006
Distribution: Debian Unstable
Posts: 1,129

Original Poster
Blog Entries: 2

Rep: Reputation: 260Reputation: 260Reputation: 260
Thanks, this is what I was looking for.

So this is the output for the files from the image shown in the OP.

From a compilation CD: [Pictured first]
Code:
             Overall     Left      Right
DC offset   0.000253  0.000253  0.000107
Min level  -1.000000 -1.000000 -1.000000
Max level   0.999969  0.999969  0.999969
Pk lev dB       0.00      0.00      0.00
RMS lev dB    -10.56    -10.51    -10.61
RMS Pk dB      -4.38     -4.83     -4.38
RMS Tr dB     -78.57    -78.28    -78.57
Crest factor       -      3.35      3.39
Flat factor    17.75     17.25     18.17
Pk count       8.68k     8.18k     9.19k
Bit-depth      16/16     16/16     16/16
Num samples    14.1M
Length s     319.805
Scale max   1.000000
Window s       0.050
From another compilation CD: [Pictured second]
Code:
             Overall     Left      Right
DC offset   0.000287  0.000167  0.000287
Min level  -1.000000 -1.000000 -1.000000
Max level   0.999969  0.999969  0.999969
Pk lev dB       0.00      0.00      0.00
RMS lev dB     -8.44     -8.36     -8.52
RMS Pk dB      -4.09     -4.09     -4.17
RMS Tr dB    -257.19   -256.63   -257.19
Crest factor       -      2.62      2.67
Flat factor     9.55      9.21     10.03
Pk count       5.82k     6.90k     4.75k
Bit-depth      16/16     16/16     16/16
Num samples    14.2M
Length s     322.213
Scale max   1.000000
Window s       0.050
So looking at "Pk lev dB" for both files, it would indicate there would be some clipping going on. Looking at "RMS lev dB" and "RMS Pk dB", the first file isn't as loud and should have less clipping going on. Sound right?
 
Old 11-10-2012, 04:06 AM   #6
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Yes, if the "Pk lev dB" is 0, then there is clipping.

For example try:

Code:
play danosongs.com-sunspark.mp3 stats
play danosongs.com-sunspark.mp3 gain -3 stats
Clipping will say:
Code:
In:2.21% 00:00:05.39 [00:03:58.78] Out:254k  [!=====|=====!] Hd:0.0 Clip:173  
             Overall     Left      Right
DC offset  -0.004690 -0.004614 -0.004690
Min level  -1.000000 -1.000000 -1.000000
Max level   1.000000  1.000000  1.000000
Pk lev dB       0.00      0.00      0.00
RMS lev dB     -9.13     -9.20     -9.06
RMS Pk dB      -6.43     -6.54     -6.43
RMS Tr dB     -13.61    -13.22    -13.61
Crest factor       -      2.88      2.84
Flat factor     1.35      1.68      1.02
Pk count        47.5        47        48
Bit-depth      29/29     29/29     29/29
Num samples     238k
Length s       5.387
Scale max   1.000000
Window s       0.050
play WARN rate: rate clipped 90 samples; decrease volume?
play WARN dither: dither clipped 83 samples; decrease volume?
Note the exclamation marks, the 0.00 "Pk lev dB", and WARN.

With gain adjustment it says:
Code:
In:1.75% 00:00:04.27 [00:03:59.90] Out:200k  [-=====|=====-] Hd:2.5 Clip:0    
             Overall     Left      Right
DC offset  -0.003329 -0.003232 -0.003329
Min level  -0.707946 -0.707946 -0.707946
Max level   0.707946  0.707946  0.707946
Pk lev dB      -3.00     -3.00     -3.00
RMS lev dB    -12.26    -12.31    -12.22
RMS Pk dB      -9.43     -9.54     -9.43
RMS Tr dB     -16.61    -16.22    -16.61
Crest factor       -      2.92      2.89
Flat factor     1.57      1.82      1.27
Pk count        40.5        43        38
Bit-depth      32/32     32/32     32/32
Num samples     188k
Length s       4.272
Scale max   1.000000
Window s       0.050
The sox man page recommends a gain -3 to -6 or in rare cases up to -9 dB.
 
Old 11-10-2012, 01:35 PM   #7
replica9000
Senior Member
 
Registered: Jul 2006
Distribution: Debian Unstable
Posts: 1,129

Original Poster
Blog Entries: 2

Rep: Reputation: 260Reputation: 260Reputation: 260
I don't plan on modifying any of the audio files I have, only to gather info on them. If I have a the same song across multiple CDs, I can look at the info and decide which one would probably sound better.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Using the CLI tool arecord to capture streaming audio rmcellig Linux - Software 1 12-20-2011 07:39 PM
CLI tool to determine processor type? wanderingmind Linux - Software 3 09-11-2007 06:47 PM
Audio on DVD's is clipping (QDVDAUTHOR) ECACE Linux - Software 2 08-22-2007 07:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration