Yup. Also, there are some with different program content on the different layers.Lots. Tend to be the older SACDs, or Japanese ones.
Yup. Also, there are some with different program content on the different layers.Lots. Tend to be the older SACDs, or Japanese ones.
rate -ub74 88200 gain 6 sinc -25k
.soxdsd -V3 sample.dsf --bits 24 sample.flac rate -ub74 88200 gain 6 sinc -25k
It tells how many samples there are but not the peak. There must be a way to find the peak though, but this script is not about performance. For example when it finds a peak at track 5 it'll always re-transcode 1,2,3,4 even thought they are not problematic.Here's my unsolicited code review
Looking at the script, I wonder if there is any text in the output of the 'soxdsd' command that gives the resulting peak amplitude. If so, instead of looking for the text 'decrease volume', you could use the peak value to compute a new gain value that will give a specific peak value, and set it to something like -1 dB to help prevent intersample overs. In this case, always start with a low gain value like -15 dB to avoid clipping. For example if it said the resulting peak value was -3.4 dB, you add 2.4 dB to the original value of -15 for a gain of -12.6 dB, knowing the resulting will have exactly -1.0 dB peak value. Then it would always convert to PCM having a specific peak amplitude (instead of any amplitude short of 0 dB), and always run exactly twice, never more.
There is if you stick a "stats" at the end of the effects chain.I wonder if there is any text in the output of the 'soxdsd' command that gives the resulting peak amplitude.
There is if you stick a "stats" at the end of the effects chain.
You can do that automatically by adding "gain -n" as the last effect.Thanks for that (and thanks for @hyperknot for the script!) - twiddled it a bit for my purposes and changed it so that it uses `stats` to scan every file once to calculate optimum gain, and then does the actual conversion with that gain.
You can do that automatically by adding "gain -n" as the last effect.
Interesting, I'll have to try that, it's not documented in the SoX man page as far as I can see.
gain [-e|-B|-b|-r] [-n] [-l|-h] [gain-dB]
The -n option normalises the audio to 0dB FSD; it is often used in conjunction with a negative gain-dB to the effect that the audio is normalised to a given level below 0dB. For example,
sox infile outfile gain -n
normalises to 0dB, and
sox infile outfile gain -n -3
normalises to -3dB.
I would have thought so, but the posted script does it per file.But don't you want an album gain per folder instead of single track gain?
Code:gain [-e|-B|-b|-r] [-n] [-l|-h] [gain-dB] The -n option normalises the audio to 0dB FSD; it is often used in conjunction with a negative gain-dB to the effect that the audio is normalised to a given level below 0dB. For example, sox infile outfile gain -n normalises to 0dB, and sox infile outfile gain -n -3 normalises to -3dB.
But don't you want an album gain per folder instead of single track gain?
"gain" without additional switches does that.I'll look at that - but I want to maintain the level of the output PCM relative to the level of the source file, not relative to 0db.
Why would you think that? One track could be quieter than other track, because that was an artistic intention, and only by chance it would get more than 6 dB headroom.You would think that if one track in the album was normalized to Scarlet Book spec (such that we can apply the normal +6db gain on PCM conversion), all the tracks in the album would be.
DSD, as per the spec, as I understand it, mandates 6db of headroom at a minimum, regardless of content dynamic range."gain" without additional switches does that.
Why would you think that? One track could be quieter than other track, because that was an artistic intention, and only by chance it would get more than 6 dB headroom.
You should analyze the whole album first, to decide if it is safe to apply +6dB boost and only then do the conversion of all tracks with or without the boost.
Yes, and if we know that such content may exist, then there is no reason to expect, that if one track on an album is mastered to the spec then all tracks will be mastered to the spec.Some DSD content is incorrectly mastered and violates this spec