Skip to main content

Topic: Sox question - going from 192k to 96 and avoid clipping (Read 4629 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • vinylman
  • [*]
Sox question - going from 192k to 96 and avoid clipping
Hi.

I'm fairly green about this, so bear with me.

I'm using sox to convert some vinyl rips from 192 to 96, as 192 just takes up too much space. The problem is that I'm getting a lot of clipped samples. Well around 11, depends if that's a lot or not.

Anyway, the cmd I'm using is

d:
cd %~dp0
mkdir converted
FOR %%A IN (%*) DO sox %%A -b 24 "converted/%%~nxA" rate -v -L 96000
pause

Is there anything I can put in here to avoid clipping? I tried to edit it myself but the program never started then. Was wondering what I have to add to the cmd line to automate the process, or maybe I have to enter a specific value every time?
So how do I reduce the volume or add -G norm or something to it?

Any help would be greatly appreciated.

  • Brazil2
  • [*][*][*]
Sox question - going from 192k to 96 and avoid clipping
Reply #1
add -G norm

Yes, that's the purpose of the -G switch.

  • KozmoNaut
  • [*][*][*][*][*]
Sox question - going from 192k to 96 and avoid clipping
Reply #2
Hi.

I'm fairly green about this, so bear with me.

I'm using sox to convert some vinyl rips from 192 to 96, as 192 just takes up too much space. The problem is that I'm getting a lot of clipped samples. Well around 11, depends if that's a lot or not.

Anyway, the cmd I'm using is

d:
cd %~dp0
mkdir converted
FOR %%A IN (%*) DO sox %%A -b 24 "converted/%%~nxA" rate -v -L 96000
pause

Is there anything I can put in here to avoid clipping? I tried to edit it myself but the program never started then. Was wondering what I have to add to the cmd line to automate the process, or maybe I have to enter a specific value every time?
So how do I reduce the volume or add -G norm or something to it?

Any help would be greatly appreciated.


Add "-G" to your SoX command line, and it should prevent it from clipping by reducing gain on any files that would clip.

And honestly, just downsample to 16bit 44.1kHz with "dither -s" to use noise-shaping dither, instead of 24bit 96kHz. If you're really paranoid about losing playback quality, do an ABX test with both versions. I'm sure the results will be surprising.
  • Last Edit: 19 February, 2014, 07:31:54 AM by KozmoNaut

  • vinylman
  • [*]
Sox question - going from 192k to 96 and avoid clipping
Reply #3
Does it matter where I put it? I tried several places, and it just lists a lot of settings then, and options, it doesn't convert. It also says "Sox fail sox: not enough input filenames specified".


And yeah, I can't tell the difference between redbook and "hires", but it doesn't really matter. I got space, but 192 is just too much. But while we're on the subject, if you believe noone can hear the difference between 24 and 16, is clipping easier to hear?

I know it's a lot to ask, but could anyone tell me exactly where to put -G?

And what does the -s do after dithering?
  • Last Edit: 19 February, 2014, 07:59:26 AM by vinylman

  • KozmoNaut
  • [*][*][*][*][*]
Sox question - going from 192k to 96 and avoid clipping
Reply #4
But while we're on the subject, if you believe noone can hear the difference between 24 and 16, is clipping easier to hear?

I know it's a lot to ask, but could anyone tell me exactly where to put -G?

And what does the -s do after dithering?


Clipping can be heard if it gets bad enough. A single clipped sample or 10 distributed over a track isn't that bad, I certainly can't pinpoint clipped samples that precisely, and lots of commercial releases have been made containing significantly more clipping than that.

Just put "-G" as the very first parameter to sox, it should work then.

"Dither -s" applies noise-shaping dither to the signal, which pushes quantization noise into frequencies where the human ear is less sensitive. The effect is a subjective reduction of the noise floor and increase of dynamic range from the calculated 96dB of normal CD audio to upwards of 110-120dB, bringing it close to the real world dynamic range of 24-bit audio.
  • Last Edit: 19 February, 2014, 08:17:32 AM by KozmoNaut

  • Porcus
  • [*][*][*][*][*]
Sox question - going from 192k to 96 and avoid clipping
Reply #5
And honestly, just downsample to 16bit 44.1kHz


Maybe one would want to choose 48 kHz instead, although there shouldn't be many soundcards around anymore that have to resample to 48 and make issues out of it ... or?

Myself I have a DAC that makes a scratch sound every time it has to switch back and forth between 44.1 and 48, so I could have considered 48 if I were sufficiently annoyed over it (naaah) AND my collection were vastly 48 files (which it certainly ain't).
  • Last Edit: 19 February, 2014, 08:38:14 AM by Porcus

  • vinylman
  • [*]
Sox question - going from 192k to 96 and avoid clipping
Reply #6
Well, the reason I went for 24/96 is that some of these rips are hard to come by, and thought what the hell, might as well keep it hires.

I can't hear the difference, and I'm quite sure 99% of the population can't either, even the ones who call you idiot and buy cables for big bucks. But I was also thinking it could help with listening fatigueness. That's how I started with vinyl in the first place. The wallbricked crap they release seriously hurts if you use headphones over long periods. And it sounds bad. I did try with an ABX plug-in in foobar, couldn't tell at all.

Thanks, adding that line fixed it. Did -G just do adjustments to the volume or? Is this a cmd I should keep permanent or only when I get clipping?

About dither -s. I used dither but I never had that -s at the end of it, no difference?
  • Last Edit: 19 February, 2014, 09:08:41 AM by vinylman

  • 2Bdecided
  • [*][*][*][*][*]
  • Developer
Sox question - going from 192k to 96 and avoid clipping
Reply #7
It's interesting that a vinyl rip would end up with 10 clipped samples just by resampling from 192kHz to 96kHz.

1. You wouldn't expect a vinyl rip to get very close to digital full scale - except on one single digital sample, and only if it was peak normalised to 0dB FS.
2. You wouldn't expect that removing all the energy above 48kHz would make any difference to a vinyl rip.

10 clipped samples? I bet the source is already clipped.

Cheers,
David.

  • vinylman
  • [*]
Sox question - going from 192k to 96 and avoid clipping
Reply #8


Some ripper go for 24/192. most do 24/96, and I see some have started with 24/48. 24/48 doesn't take THAT much more space than 16/48, so maybe that should be my goal..
  • Last Edit: 19 February, 2014, 10:03:57 AM by vinylman

  • Apesbrain
  • [*][*][*][*][*]
Sox question - going from 192k to 96 and avoid clipping
Reply #9
I could PM you a link to the rip if you want. His rips sound very good though, in most cases.

Careful: TOS#9.

  • ktf
  • [*][*][*][*][*]
Sox question - going from 192k to 96 and avoid clipping
Reply #10
24/48 doesn't take THAT much more space than 16/48, so maybe that should be my goal..

Maybe it doesn't, but it is still a waste. I doubt there are much vinyl recordings exceeding 12 bits of dynamic range.

FWIW, I'd store my vinyl rips as 44.1kHz, 14-bit FLAC files (or 16-bit with 2 empty bits). Currently I have some recordings with a rather high noisefloor (-60dB), storing them as 16-bit FLAC with 3 empty bits (so effectively 13-bits) halves the filesize while I can be certain there will be no audible difference at all.
  • Last Edit: 19 February, 2014, 10:05:39 AM by ktf
Music: sounds arranged such that they construct feelings.

  • 2Bdecided
  • [*][*][*][*][*]
  • Developer
Sox question - going from 192k to 96 and avoid clipping
Reply #11
Lossless coding of 24-bits is surprisingly inefficient when/because the bottom 8 bits are noise.

You should see what lossyWAV makes of it, if you're interested in ignoring the parts below the noise floor. I'm not telling you to archive in lossyWAV (though you can if you want) - but it's amazing what a difference simply zero-ing the noisy LSBs makes to FLAC coding efficiency.


I don't want the rips, thanks, but you can upload 30 seconds here if you want. But by the time you've found the clipped part, you'll have answered the question for yourself anyway.

Cheers,
David.

  • vinylman
  • [*]
Sox question - going from 192k to 96 and avoid clipping
Reply #12
Jesus. For so long I've been nagged by others because I only store music as redbook. OK, you guys have convinced me, I'm back on the RB boat.

Thanks for all the help though. i got a lot of converting ahead of me.

  • 2Bdecided
  • [*][*][*][*][*]
  • Developer
Sox question - going from 192k to 96 and avoid clipping
Reply #13
FWIW, though I know I can't hear a difference, the very few things I've bought in hi-res I do keep in hi-res (Why? Well, why not?), though it's 44.1/16 2.0 FLAC downconversions I have in my regular library.

Cheers,
David.

  • mjb2006
  • [*][*][*][*][*]
Sox question - going from 192k to 96 and avoid clipping
Reply #14
The dither is only if you are converting the bit depth; if you're only changing the sample rate, you don't need it, right?

But is it really necessary to dither when converting from 24 to 16? For a vinyl rip?!
  • Last Edit: 19 February, 2014, 11:54:58 AM by mjb2006

  • pdq
  • [*][*][*][*][*]
Sox question - going from 192k to 96 and avoid clipping
Reply #15
The dither is only if you are converting the bit depth; if you're only changing the sample rate, you don't need it, right?

Sample rate conversion is performed at higher bit depth, after which the bit depth is probably restored to that of the source. Dither should be used at this point unless a further reduction in bit depth will be performed later.

  • DVDdoug
  • [*][*][*][*][*]
Sox question - going from 192k to 96 and avoid clipping
Reply #16
I don't see how adding dither (noise) at around -90dB can possibly make any measurable or audible difference to digitized vinyl, which already has a noise floor much higher than that.

  • KozmoNaut
  • [*][*][*][*][*]
Sox question - going from 192k to 96 and avoid clipping
Reply #17
I don't see how adding dither (noise) at around -90dB can possibly make any measurable or audible difference to digitized vinyl, which already has a noise floor much higher than that.


My point with the bit about dither was that 24bit audio for playback is pointless, since even the best DACs only reach maybe 20-22 bits of resolution in reality, due to thermal noise in the circuits among other factors.

Properly dithered 16 bit with noise shaping can reach pretty much the same resolution subjectively to the human ear, by pushing the quantization noise to less apparent frequencies.

It doesn't really matter with vinyl rips, you are perfectly right about that :-)
  • Last Edit: 19 February, 2014, 03:56:45 PM by KozmoNaut

  • vinylman
  • [*]
Sox question - going from 192k to 96 and avoid clipping
Reply #18
I don't see how adding dither (noise) at around -90dB can possibly make any measurable or audible difference to digitized vinyl, which already has a noise floor much higher than that.


My point with the bit about dither was that 24bit audio for playback is pointless, since even the best DACs only reach maybe 20-22 bits of resolution in reality, due to thermal noise in the circuits among other factors.

Properly dithered 16 bit with noise shaping can reach pretty much the same resolution subjectively to the human ear, by pushing the quantization noise to less apparent frequencies.

It doesn't really matter with vinyl rips, you are perfectly right about that :-)


So it doesn't really matter at all if you dither with vinyl?  So the audible differences are so subtle, if any, that it doesn't really matter what settigns I use?

Guess it's pretty easy to believe all the people who say the can hear the difference in everything..


  • bandpass
  • [*][*][*][*]
Sox question - going from 192k to 96 and avoid clipping
Reply #19
Certainly for vinyl, just let it use the default TPDF.

Only use shaped dither if you're really sure you need it, which (unless you go 8-bit or something) is probably never.

  • vinylman
  • [*]
Sox question - going from 192k to 96 and avoid clipping
Reply #20
Certainly for vinyl, just let it use the default TPDF.

Only use shaped dither if you're really sure you need it, which (unless you go 8-bit or something) is probably never.



I read your post recently. I removed -s for noise shaping, but now I get a warning that dither is clipping samples sometimes.

Should I add -a after dither? EDIT, this didn't help.



    c:
    cd %~dp0
    mkdir converted
    FOR %%A IN (%*) DO sox %%A -G -b 16 "converted/%%~nxA" rate -v -L 44100 dither
    pause

That's the cmd I use now, do I keep it and ignore the warnings that dither clips? Or add -s again?
  • Last Edit: 18 June, 2014, 11:51:47 AM by vinylman

  • DVDdoug
  • [*][*][*][*][*]
Sox question - going from 192k to 96 and avoid clipping
Reply #21
Do whatever SOUNDS best!!!

But, I don't think you are going to hear dither (or the effects of dither) either way.  That includes the tiny fraction of a dB of clipping that dithering might add.   

If it makes you feel better, try a tiny amount of gain reduction to prevent clipping.  I'd guess that 1/10th of a dB would do it.  (I don't use SOX, so I can't tell you exactly how to do that.)

Sox question - going from 192k to 96 and avoid clipping
Reply #22
Certainly for vinyl, just let it use the default TPDF.

Only use shaped dither if you're really sure you need it, which (unless you go 8-bit or something) is probably never.



I read your post recently. I removed -s for noise shaping, but now I get a warning that dither is clipping samples sometimes.

Should I add -a after dither? EDIT, this didn't help.



    c:
    cd %~dp0
    mkdir converted
    FOR %%A IN (%*) DO sox %%A -G -b 16 "converted/%%~nxA" rate -v -L 44100 dither
    pause

That's the cmd I use now, do I keep it and ignore the warnings that dither clips? Or add -s again?


The -s command with SoX invokes a specific type of noise shaping algorithm called shibata, and you should always have that in your command line whenever you dither to 16bit. It takes any noise and pushes it to the part of the hearing spectrum where humans can't hear it. Without it, all you get is a standard TPDF dither.

I'd also take the -G command out of the command line. It's the wrong way to go about clipping prevention anyway. If I were doing it, I'd take my 192/24 or 96/24 rip and put it into an audio program (i.e. like Audacity) and normalize the entire rip anywhere from -0.3 to -0.7 dB, because the downsampling process can tend to cause some sort of clipping if normalization isn't in play, and it also helps with vinyl noise. The amount you chose to normalize will depend, of course, on how much you think the rip needs, so YMMV.

BTW: If downsampling from 192/24 to 44/16, I'd set up SoX to do it with the VHQ setting using intermediate phase (25%) with a passband setting of 95%. If it's 192/24 to 96/24, use the VHQ setting with linear phase (50%) and the same passband setting.
  • Last Edit: 18 June, 2014, 04:14:28 PM by themanintheshadows_2451
ghostman

  • vinylman
  • [*]
Sox question - going from 192k to 96 and avoid clipping
Reply #23
Certainly for vinyl, just let it use the default TPDF.

Only use shaped dither if you're really sure you need it, which (unless you go 8-bit or something) is probably never.



I read your post recently. I removed -s for noise shaping, but now I get a warning that dither is clipping samples sometimes.

Should I add -a after dither? EDIT, this didn't help.



    c:
    cd %~dp0
    mkdir converted
    FOR %%A IN (%*) DO sox %%A -G -b 16 "converted/%%~nxA" rate -v -L 44100 dither
    pause

That's the cmd I use now, do I keep it and ignore the warnings that dither clips? Or add -s again?


The -s command with SoX invokes a specific type of noise shaping algorithm called shibata, and you should always have that in your command line whenever you dither to 16bit. It takes any noise and pushes it to the part of the hearing spectrum where humans can't hear it. Without it, all you get is a standard TPDF dither.

I'd also take the -G command out of the command line. It's the wrong way to go about clipping prevention anyway. If I were doing it, I'd take my 192/24 or 96/24 rip and put it into an audio program (i.e. like Audacity) and normalize the entire rip anywhere from -0.3 to -0.7 dB, because the downsampling process can tend to cause some sort of clipping if normalization isn't in play, and it also helps with vinyl noise. The amount you chose to normalize will depend, of course, on how much you think the rip needs, so YMMV.

BTW: If downsampling from 192/24 to 44/16, I'd set up SoX to do it with the VHQ setting using intermediate phase (25%) with a passband setting of 95%. If it's 192/24 to 96/24, use the VHQ setting with linear phase (50%) and the same passband setting.



I seriously appreciate your answer!

Sad to say I'm not to savvy with any of this, I just want my rips to be in good condition. I'll add the -s back again.

The rest however, I don't know what is, and I don't think I'll dabble in those programs as it sounds even more complicated than sox.

I'll keep the -G though, as I guess it's better to avoid clipping at all, right?

Sox question - going from 192k to 96 and avoid clipping
Reply #24
Certainly for vinyl, just let it use the default TPDF.

Only use shaped dither if you're really sure you need it, which (unless you go 8-bit or something) is probably never.



I read your post recently. I removed -s for noise shaping, but now I get a warning that dither is clipping samples sometimes.

Should I add -a after dither? EDIT, this didn't help.



    c:
    cd %~dp0
    mkdir converted
    FOR %%A IN (%*) DO sox %%A -G -b 16 "converted/%%~nxA" rate -v -L 44100 dither
    pause

That's the cmd I use now, do I keep it and ignore the warnings that dither clips? Or add -s again?


The -s command with SoX invokes a specific type of noise shaping algorithm called shibata, and you should always have that in your command line whenever you dither to 16bit. It takes any noise and pushes it to the part of the hearing spectrum where humans can't hear it. Without it, all you get is a standard TPDF dither.

I'd also take the -G command out of the command line. It's the wrong way to go about clipping prevention anyway. If I were doing it, I'd take my 192/24 or 96/24 rip and put it into an audio program (i.e. like Audacity) and normalize the entire rip anywhere from -0.3 to -0.7 dB, because the downsampling process can tend to cause some sort of clipping if normalization isn't in play, and it also helps with vinyl noise. The amount you chose to normalize will depend, of course, on how much you think the rip needs, so YMMV.

BTW: If downsampling from 192/24 to 44/16, I'd set up SoX to do it with the VHQ setting using intermediate phase (25%) with a passband setting of 95%. If it's 192/24 to 96/24, use the VHQ setting with linear phase (50%) and the same passband setting.



I seriously appreciate your answer!

Sad to say I'm not to savvy with any of this, I just want my rips to be in good condition. I'll add the -s back again.

The rest however, I don't know what is, and I don't think I'll dabble in those programs as it sounds even more complicated than sox.

I'll keep the -G though, as I guess it's better to avoid clipping at all, right?


It's, pretty much, the equivalent of Sound Check on an iPod: a "solution" that never really worked. The only real way to deal with clipping is the way I described. Keep in mind that, even if you don't have any clipping in your vinyl rips before you downsample, the process has a tendency to put it there depending on what options you chose (i.e. the type of noise shaping you choose, phase setting). As for Audacity, it ain't hard at all. Just open the program, import the tracks, use Ctrl+A to do a global select, then go to Effects/Normalize and chose these options:

Remove DC Offset
Normalize maximum amplitude to (insert db level here) [-0.3db to -0.7db]

Click OK, and everything will be normalized automatically.

IMO, if it was me, and vinyl noise wasn't an issue, I'd probably just go for a -0.3db reduction and leave it at that.


BTW: If your not using the SoX plugin in foobar2000, you should. Using Sox that way makes it a hell of a lot easier to use.
ghostman