Jump to content
IGNORED

Analyzing files for clipping


joelha

Recommended Posts

I've been wanting to analyze a bunch of files (SACD rips) for clipping but have been unable to find a good software option.

 

Saracon is about $1,000, Audacity is time consuming (one track at a time) and the results are not easy to read (at least not for me). Foobar's dynamic range plug-in doesn't seem to reveal any peaks above 0.0, so it's not possible to know how much to reduce gain.

 

Ideally, I'd love to find a piece of software which could analyze flac files for clipping, in batch mode (maybe an album at a time), for free.

 

If not all of those features, I'd be happy to find a piece of software with at least a couple of the features I'm looking for.

 

Suggestions?

 

Thanks,

 

Joel

 

 

 

Link to comment

I think the reason the plug-in does not go above 0.0 is that 0.0 dB is the highest number for amplitude in the audio data stream. Someone can correct me if this is wrong.

 

That's the case for integer samples. Frequently clipping is detected by searching for three or more successive 0 dB values in the data.

 

It is pretty trivial to write a small utility to do this.

 

Sometimes level has been adjusted or some other processing employed after the clipping which may render this ineffective way. Then it needs something more complex.

 

 

Signalyst - Developer of HQPlayer

Pulse & Fidelity - Software Defined Amplifiers

Link to comment

Using the Foobar DR plug in, you reduce the gain by the album's peak value in DR (assuming you converted the files to PCM and then had DR look at the entire album). You can then go back to Audiogate or whatever you are using and use the peak value (if it said -4.32 then use +4.32 in any conversion tool that uses 6.0db normally, like Saracon). In Audiogate I'd use -1.68db cuz Audiogate uses 0.0db as gain normal (i.e assumes 6db added).

 

However, as per our email conversation you didn't want to have to convert twice (once to find DR, once again to do new gain).

 

Link to comment

Miska,

If it is really trivial to write a small utility (and I am not sure that it is), could you please write this small utility (in maybe C++) and make it available to CA participants. I would do this, but I have no idea of the file structure of a PCM WAV file.

Thanks,

Mike

 

 

Link to comment

I don't get why Audacity would be hard to use. If you have multiple tracks (say WAV files) that you need analyzed just place them in a folder and run the following SoX command in that folder:

 

sox '*.wav' tracks.wav

 

Now just load the file tracks.wav into Audacity and run the "Detect Clipping" command (or whatever it's called) from the Analyze menu and use the default settings. An additional "track" will be created in Audacity containing either nothing (i.e. the whole track is just one grey bar) or a bunch of cryptic lines. If there's nothing you have no clipping and if there's cryptic lines it means you have clipping at the positions corresponding to the lines (which I assume you are not interested in). If you indeed want to know the precise position of the mentioned clipping spots then use google to find out how.

 

Listening Room: ALIX.2D2 (Voyage MPD) --> Arcam rDAC --> Marantz PM-15S2 --> Quadral Wotan Mk V

Drinking Room: ALIX.2D2 --> M2Tech hiFace 2 --> Cambridge Audio Azur 740C --> Rotel RC-06/RB-06 --> B&W XT4

Home head-fi: Grado SR80i, Sennheiser HD 650

On the go head-fi: Sennheiser IE 8

Link to comment

First and most of all, a public "thank you" to ted_b for his endless patience, and knowledge of all things SACD.

 

Second, to Sik_Lescinovid, while I appreciate your suggestion, I'm not sure how it will get me to a db number in which to reduce the gain of a track, where necessary.

 

Joel

 

 

 

Link to comment

Simple gain reduction doesn't really solve the problem in a way that I would deem useful or audiophile. If there is clipping it's a problem that arose somewhere way before the playback of the file. In my case I have to check how much gain I can add so that there is no clipping when converting from DSD to PCM, I thought that was your goal as well (and maybe to simply see if there is any clipping in conjunction with a decision related to file deletion). As far as I understood (and as has been mentioned before) a PCM WAV can't contain anything beyond 0 dBFS. Hence by reducing the gain even by 0.1 dB (i.e. applying Amplify filter in Audacity with a value of -0.1) would already get rid of all clipping spots. This is usually what happened whenever I did try this, but it might be just coincidence and me being misinformed. Anyone else care to tell us if I'm thinking right?

 

Listening Room: ALIX.2D2 (Voyage MPD) --> Arcam rDAC --> Marantz PM-15S2 --> Quadral Wotan Mk V

Drinking Room: ALIX.2D2 --> M2Tech hiFace 2 --> Cambridge Audio Azur 740C --> Rotel RC-06/RB-06 --> B&W XT4

Home head-fi: Grado SR80i, Sennheiser HD 650

On the go head-fi: Sennheiser IE 8

Link to comment

PCM and therefore the gain (BEFORE converting to PCM) may need to be reduced by Saracon/Audiogate/ etc to make sure the resultant PCm file is not clipped. So the workaround was to do the DR thing, then go abck to the native diff files and reconvert with the measurements taken. A real PITA.

 

We are not talking about reducing clipping after the PCM file is created. Too late.

 

Link to comment

We are not talking about reducing clipping after the PCM file is created. Too late.

 

That's precisely what I'm saying, it's too late. I am well aware that in most cases the "standard" 6 dB are too hot on DSD2PCM conversion which is exactly what I was referring to. If it's DSD to PCM conversion you're interested in I don't see why the procedure I described doesn't work? Also OP didn't specify that he wanted to know how much headroom he has (which is easily visible by just applying the Amplify filter in Audacity, the "default" value given is the maximum possible without clipping) but just if there was clipping or not, or at least that's what I understood from the original post. Anyways, apart from retrieving headroom using Audacity as described in parentheses you could just run

 

sox filetobeanalyzed.wav -n stats

 

and obtain a bunch of useful information, among them the peak level in dBFS. From what I gather his original problem was that he essentially needed a way to analyze multiple files at once, I gave the possibility of concatenating with SoX. Apart from that I was under the impression that the OP knew how to determine peak dBFS levels from a given file...

 

So just to summarize what the easiest way is of accomplishing what you want:

 

1. Convert the DSD files to PCM using all the setting you intend to use except for the gain set at 0dB regardless.

 

2. Run the following in the folder containing all the resulting PCM WAV files:

 

sox '*.wav' -n stats

 

and note the peak level in dBFS (denoted "Pk lev dB")

 

3. Repeat the DSD2PCM conversion but this time with the gain set appropriately (i.e. -1 times the value obtained from SoX).

 

I hope this helps

 

Listening Room: ALIX.2D2 (Voyage MPD) --> Arcam rDAC --> Marantz PM-15S2 --> Quadral Wotan Mk V

Drinking Room: ALIX.2D2 --> M2Tech hiFace 2 --> Cambridge Audio Azur 740C --> Rotel RC-06/RB-06 --> B&W XT4

Home head-fi: Grado SR80i, Sennheiser HD 650

On the go head-fi: Sennheiser IE 8

Link to comment

*Hence by reducing the gain even by 0.1 dB (i.e. applying Amplify filter in Audacity with a value of -0.1) would already get rid of all clipping spots.*

 

If you reduce the level by 0.1 dB, then Audacity will not see the clipping. But the effect will still be there. The effect of clipping is caused by the discontinuity of the wave form. The artificial flat-top, where the amplitude number is constant. Reducing the amplitude by 0.1 dB will move this constant value from 0.0 dB to -0.1 dB, but will not eliminate the clip. The discontinuity at the beginning and end of the flat-top is interpreted by the DAC as a burst of high frequency noise.

 

 

Link to comment

Thank you for the detailed info Mike. I was pretty sure that having anything above 0 dBFS is impossible and that simply reducing gain would get rid of clipping in the analysis but that it wouldn't help much since the original already clipped. I should've made more clear that with "clipping spots" I meant the spots where there's supposed to be clipping in the analysis.

 

Listening Room: ALIX.2D2 (Voyage MPD) --> Arcam rDAC --> Marantz PM-15S2 --> Quadral Wotan Mk V

Drinking Room: ALIX.2D2 --> M2Tech hiFace 2 --> Cambridge Audio Azur 740C --> Rotel RC-06/RB-06 --> B&W XT4

Home head-fi: Grado SR80i, Sennheiser HD 650

On the go head-fi: Sennheiser IE 8

Link to comment

So is the consensus here that as a result of the file being converted from DSD to FLAC that the clipping will be a part of the file and that even after the file's gain is reduced, all I'll end up with is a file which still has clipping and lower gain?

 

Joel

 

Link to comment

about fixing clipping in PCM files, but it's irrelevant to your questions. Getting back to your issue, and the topic of this thread, if you analyze the DIFF to PCM conversion peaks in DR, then you can reconvert DIFF to PCM to a safe level that should keep the dynamics, as per my word document to you (from another source)or per Sid's SOX approach. Sid's approach requires SOX tech knowledge, but it works at an album level (as does DR).

 

Link to comment

Thanks Kevin.

 

Just to be clear, I'm talking about files ripped from SACD's which become clipped as a result of the DSD to FLAC conversion.

 

I'm not talking about SACD's which are actually already "clipped on the disc" so to speak.

 

Is that what you're talking about also?

 

If so, than would I also be right in assuming that the best way to avoid clipping would be to have both a software player and a dac which could natively manage DSD files?

 

Joel

 

Link to comment

and that is the bad SACD source that is already clipped. Yikes! How do we test for that? Joel (and my) dilema is making sure "good" SACD's don't get too much gain (Saracon, etc like to do 6db as default) during DIFF-to-PCM so the PCM result can be dynamic but not crushed.

 

Link to comment

We have had to rewrite the EPROMS in some of the converters when we're doing a hardware sample rate change. "Ususally", 3dB works for most SACD's. There have been a few that 3dB wasn't enough. If the DSD layer wasn't clipped, we would do a gain reduction in either Sonoma or Pyramix and then SRC into PCM.

 

 

 

Link to comment

Thanks for the reply, Kevin.

 

For those of us using PS3's for SACD ripping and Audiogate for file conversion, how would we:

 

1. Determine whether our converted file (FLAC) is clipping at all?

 

2. For the files which do have "clipping" portions, how would we eliminate the clipping?

 

a. Is it even possible to eliminate the clipping?

 

Joel

 

Link to comment

Thanks Cyclo,

 

Aside from the fact this software is $349, it appears to be a patch to fixing the clipping rather than a method for undoing it (but I'd be happy to proven wrong about this).

 

If someone is able to answer the questions on my previous post, I'd be grateful.

 

Joel

 

Link to comment

If that's the case, then it seems the PS3 method only leaves three options for SACD rippers:

 

1. Hope that there's no clipping after the rip and conversion is completed.

 

2. Use something like Adobe Audition to mitigate the clipping.

 

3. Play DFF files in a player which will handle them natively and then through a DAC which will also handle them.

 

Did I miss any other options?

 

Joel

 

 

 

Link to comment

here. Joel, the OP, is NOT asking whether you can fix or undo clipping once it's done, he's asking about PREVENTING clipping from happening when "recording" the PCM file from the DSD file. And YES, is the answer, it can be prevented. If the DSD file is converted to PCM with the normal 6DB of gain added (just like recording any signal too hot) then you can clip the resultant file. NO ONE is asking whether, at that point, any fixing can be done. No one!

 

The process to do this is, of course, dependent on, as Kevin points out making sure you don't have a source (SACD) that is crushed already! But if you don't, then do a test conversion of the album, run one of the programs we mention (SOx, Foobar DR plugin) and get the average peak for the album (as Kevin says, 3 DB is a good swag) and then go back and re-run the conversion with that gain setting.

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...