HydrogenAudio

Hydrogenaudio Forum => General Audio => Topic started by: KikeG on 2003-03-05 10:21:27

Title: Be careful with SSRC usage on critical tasks
Post by: KikeG on 2003-03-05 10:21:27
I just want to comment that SSRC 1.28 and 1.29 (don't know about previous ones) versions use a default amount of dither that is insufficient for critical tasks. Quite probably just listening under regular conditions is not one of them, but taking it into account won't harm.

With SSRC 1.29 you can specify the amount of dither to use (num. of bits of dither amplitude).

Using triangular pdf (recommended for regular usage), these things happen on default:

- dither type 1, no noise shaping (flat dither): 0.5 bits on default are used, low-level quantization distortion still remains, noise modulation too. A value of 0.9 bits is needed to avoid appreciable distortion and achieve slightly appreciable noise modulation. A value of 1 is needed to avoid it totally.

- dither types 3 and 4( ATH noise shaped dither): 0.5 bits on default, this time no quantization distortion is appreciable, but noise modulation happens. A value of 0.7 bits is needed to make it unappreciable.

Update:

- dither type 2 (triangular noise shaped dither): 0.5 bits on default, quantization distortion and noise modulation remain. 0.9 bits are needed to avoid audible noise modulation. IIRC, 0.7 bits are needed to avoid appreciable distortion, but noise modulation remains in this case.
Title: Be careful with SSRC usage on critical tasks
Post by: KikeG on 2003-03-05 12:00:47
This may have some relevance just in case of 16 and 8 bit output files. For 24 and 32 bit output files, even if you don't use any dither, it will probably be fine for most tasks (for just listening, it will be for sure).
Title: Be careful with SSRC usage on critical tasks
Post by: _Shorty on 2003-03-05 20:57:17
should ssrc's dither be used when you're only changing sample rate, and not bit depth?  I've just been using "ssrc --rate 44100 whatever48.wav whatever44.wav" and didn't bother with either the --dither or the --pdf options because I simply didn't know if they actually did anything when bit depth wasn't being changed.  Should I have been using "ssrc --dither 2 --pdf 1 whatever48.wav whatever44.wav" or something else?
Title: Be careful with SSRC usage on critical tasks
Post by: KikeG on 2003-03-05 21:20:09
Dither is needed even when doing just resampling, as long as the output format is 16 bit. Internally, SSRC uses higher precision, and dither is advisable co convert to this higher internal precision to 16 bit at the final stage.

Same as with decoder output at MAD or FB2k.
Title: Be careful with SSRC usage on critical tasks
Post by: rjamorim on 2003-03-05 21:44:45
Quote
Dither is needed even when doing just resampling, as long as the output format is 16 bit. Internally, SSRC uses higher precision, and dither is advisable co convert to this higher internal precision to 16 bit at the final stage.

Same as with decoder output at MAD or FB2k.

So, what would be an optimal command line?
Title: Be careful with SSRC usage on critical tasks
Post by: tigre on 2003-03-05 22:40:17
@KikeG
I have an idea how to detect if there's quantization distortion, but how do you test/find out if there's noise modulation?
Title: Be careful with SSRC usage on critical tasks
Post by: NickSD on 2003-03-06 00:04:42
Anyone know if there's a version of SSRC that supports 32-bit ?

Often I work in Cool Edit Pro in 48kHz / 32-bit and then downsample to 44.1kHz / 16-bit.  I'd like to do this last step in SSRC, though, since SSRC seems to be faster and from what I heard might be better than Cool Edit Pro's resampling.

Thoughts?

I have been wondering, though.  What are the optimal settings in both Cool Edit Pro and SSRC for downsampling from 48kHz / 32 (or 24) bit to 44.1kHz / 16bit?

Also, when editing in Cool Edit Pro, the manual advises that you should convert 16-bit audio to 32-bit audio, do all the editing, and then convert back to 16-bit.  Is this optimal?  If so, does the 16-bit to 32-bit change require any special settings?

Nick
Title: Be careful with SSRC usage on critical tasks
Post by: KikeG on 2003-03-06 16:40:30
SSRC optimal command line:

Use '--rate' for the output sample rate you want, '--bits' for the number of output bits, for default I think uses same bits as the input file.

So, it would be, to convert a 48 KHz 16 bit file to 44.1 KHz with flat dither:

ssrc --rate 44100 --bits 16 --dither 1 --pdf 1 1  infile.wav outfile.wav

With a 0.9 bit amplitude I'd say it would enough for converting 16 bit sources:

ssrc --rate 44100 --bits 16 --dither 1 --pdf 1 0.9  infile.wav outfile.wav

However, 1 bit, as opposed to 0.9 bit, guarantees mathematically perfect dithering and the noise increase is not significant.

Dither 4 and specially 3 squeeze at maximum dynamics of 16 bit, but are recommended just as a final stage.

With type 3:

ssrc --rate 44100 --bits 16 --dither 3 --pdf 1 0.7  infile.wav outfile.wav

As I said, I think the '--bits 16' is not needed if the original file is already 16 bit.
I don't have time right now to answer rest of questions, I'll do later.

Edit: added 1-bit flat dither commandline and explanation.
Title: Be careful with SSRC usage on critical tasks
Post by: tigre on 2003-03-06 18:47:32
Quote
Anyone know if there's a version of SSRC that supports 32-bit ?

I don't know. I've only worked with 24bit resolution so far in SSRC.

Quote
Often I work in Cool Edit Pro in 48kHz / 32-bit and then downsample to 44.1kHz / 16-bit.  I'd like to do this last step in SSRC, though, since SSRC seems to be faster and from what I heard might be better than Cool Edit Pro's resampling.

It's not better. On 16bit resolution quality 600 is enough, more is overkill - maybe this helps to increase speed a bit. KikeG said that in another thread one or to months ago. I've got no link ATM.

Quote
I have been wondering, though.   What are the optimal settings in both Cool Edit Pro and SSRC for downsampling from 48kHz / 32 (or 24) bit to 44.1kHz / 16bit?
About SSRC KikeG already answered, you can use the same settings in CEP (at least for flat dither): Pre-/Postfilter enabled, quality 600, Dither Depth 0.9, p.d.f. Triangular, No Noise Shaping. If you use other noise shaping types (e.g. 44.1 kHz shaped), you'll get even less audible noise added. All settings should be the same except Dither Depth which will be different for each noise shaping type and needs to be tested (until KikeG answers I don't know how to test "noise modulation".

Quote
Also, when editing in Cool Edit Pro, the manual advises that you should convert 16-bit audio to 32-bit audio, do all the editing, and then convert back to 16-bit.  Is this optimal?
Yes - the higher the resolution the lower the quantization noise added in each "editing" step.
Quote
If so, does the 16-bit to 32-bit change require any special settings?
If you don't change sampling rate at the same time - No. It's just like e.g. 241 becoming 241.000.
Title: Be careful with SSRC usage on critical tasks
Post by: KikeG on 2003-03-07 12:02:00
Quote
I have an idea how to detect if there's quantization distortion, but how do you test/find out if there's noise modulation?

Generate a 32 bit -90 dB very slow sinewave, for example 0.3 Hz, then dither to 16 bit. Convert again to 32 bit, amplify it up to audible levels, and play. If you notice how the background noise changes in level or in tone, then there's noise modulation. Most obvious case is when noise dissapears when the waves is near crossing the 0 point.

Quote
About SSRC KikeG already answered, you can use the same settings in CEP (at least for flat dither): Pre-/Postfilter enabled, quality 600, Dither Depth 0.9, p.d.f. Triangular, No Noise Shaping. If you use other noise shaping types (e.g. 44.1 kHz shaped), you'll get even less audible noise added. All settings should be the same except Dither Depth which will be different for each noise shaping type and needs to be tested.


After doing some more tests with CEP, quality values over 600 don't give any higher quality for 48->44.1 KHz 16 bit, and quality values over 400 don't give any higher quality for 44.1->48 16 bit. For just music, even values haf the proposed won't have any audible consequences.

For CEP 44.1 KHz noise shaping, a value of 0.6 bits is required to avoid noise modulation.

As for the rest of your explanations, they are OK 
Title: Be careful with SSRC usage on critical tasks
Post by: tigre on 2003-03-07 12:31:04
Quote
Quote
I have an idea how to detect if there's quantization distortion, but how do you test/find out if there's noise modulation?

Generate a 32 bit -90 dB very slow sinewave, for example 0.3 Hz, then dither to 16 bit. Convert again to 32 bit, amplify it up to audible levels, and play. If you notice how the background noise changes in level or in tone, then there's noise modulation. Most obvious case is when noise dissapears when the waves is near crossing the 0 point.

In this example noise modulation obviously causes that you hear something (besides noise) that isn't audible before applying dither.

For real music - is this really important / does it make a difference? Could you please explain and/or point me to some more information about this?

What about applying a ~10Hz highpass before 32->16bit+dither: Would this avoid/decrease noise modulation on lower dither depth?

[EDIT]Thanks for your answer BTW  [/EDIT]
Title: Be careful with SSRC usage on critical tasks
Post by: KikeG on 2003-03-07 13:27:39
Quote
For real music - is this really important / does it make a difference? Could you please explain and/or point me to some more information about this?

What about applying a ~10Hz highpass before 32->16bit+dither: Would this avoid/decrease noise modulation on lower dither depth?

Noise modulation doesn't appear for the low frequencies used, but for the low levels used.

For dithering already dithered 16 bit data (for example when resampling a 16 bit file), I'd say this noise modulation issue is not important, won't happen. It may happen when dithering 24 bit files with very soft passages, that have many data samples below the 16th bit level.

Quote
[EDIT]Thanks for your answer BTW  [/EDIT]

Happy to help
Title: Be careful with SSRC usage on critical tasks
Post by: 2Bdecided on 2003-03-07 13:43:04
You should use 1-bit of dither, not 0.9 bits of dither, when converting without noise-shaping.

2-bits peak to peak (which equals 1-bit RMS - which is what these programs take as input) triangular dither is mathematically proven to remove 100% of the distortion and noise modulation.

Other values aren't.


I don't claim you'll hear a difference  but I don't think the (probably inaudible) decrease in noise due to 0.9-bits compared to 1-bit is worth risking the (probably inaudible) increase in distortion or noise modulation.


It's certainly not worth going back and re-processing anything you've done previously - the effects are an order of magnitude smaller than the smallest problems you find in lossy audio codecs. But, for once, there is an objectively "as-near-to-perfect-as-possible" way of doing things, so you might as well use it.


Cheers,
David.
Title: Be careful with SSRC usage on critical tasks
Post by: tigre on 2003-03-07 15:15:13
Quote
You should use 1-bit of dither, not 0.9 bits of dither, when converting without noise-shaping.

2-bits peak to peak (which equals 1-bit RMS - which is what these programs take as input) triangular dither is mathematically proven to remove 100% of the distortion and noise modulation.

I need to gather some experience about noise modulation, but about distortion I'd say it's a tradeoff. If dither depth is lowered starting from 1 there'll be increasing distortion, on the other hand dither noise will decrease. If dither depth is near 1 (e.g. 0.99) the distortion will be masked by dither noise, so it's there but audible. On the tests I did (low volume sine tones, low volume real music, ...) at 0.9 there was still no distortion noticable (= not audible, no extra peaks out of the noise floor in fequency analysis, nothing to seen in spectral view), just dither noise that was lower than at 1.0.

Quote
... I don't claim you'll hear a difference  but I don't think the (probably inaudible) decrease in noise due to 0.9-bits compared to 1-bit is worth risking the (probably inaudible) increase in distortion or noise modulation.

About distortion I'd say the risk at 0.9 is so small that it is worth it - about noise modulation I can't tell.

Quote
It's certainly not worth going back and re-processing anything you've done previously - the effects are an order of magnitude smaller than the smallest problems you find in lossy audio codecs. But, for once, there is an objectively "as-near-to-perfect-as-possible" way of doing things, so you might as well use it.

I'd say the best trade-off (actually I can't tell what it is but I'm sure it's below 1.0) is the  "as-near-to-perfect-as-possible" way.

Cheers tigre
Title: Be careful with SSRC usage on critical tasks
Post by: KikeG on 2003-03-07 15:45:52
Quote
You should use 1-bit of dither, not 0.9 bits of dither, when converting without noise-shaping.

This is same as with SSRC recommendations. 0.9 bit avoids distortion, but keeps slight noise modulation. For 16 bit already dithered sources, however, this is negligible. Anyway, the noise introduced with 1 bit as opposed to 0.9 bit is negligible too.
Title: Be careful with SSRC usage on critical tasks
Post by: 2Bdecided on 2003-03-07 16:16:58
For 16-bit sources which were correctly dithered to start with, there's an argument that they are already self dithering when resampled or re-coded. However, I don't buy this argument from a mathematical view-point. From a practical view point, there may be many cases where it sounds better not to dither at all, but that's a largely subjective issue, and depends on material, ears, equipment etc etc so I always use correct dither, since I don't usually have equipment or a listening environment available that I completely trust.

Quote
If dither depth is near 1 (e.g. 0.99) the distortion will be masked by dither noise, so it's there but audible.


Did you mean "inaudible"? In that case, using exactly 1-bit, it isn't there at all. It's not that it's masked, it's that it isn't there. But, as you suggest, if it's perfect with 1-bit of dither, and it's a disaster with 0 dither, then there must be a sliding scale in between. If there's a compromise between (inaudible) noise and (inaudible) distortion, I'll take the noise. Mainly because digital distortion (rather than analogue distortion) is hated by the human ear, whereas noise is easily ignored.

This may or may not convince you:

http://mp3decoders.mp3-tech.org/24bit2.html#dither (http://mp3decoders.mp3-tech.org/24bit2.html#dither)

Cheers,
David.
Title: Be careful with SSRC usage on critical tasks
Post by: KikeG on 2003-03-07 16:37:31
Quote
However, I don't buy this argument from a mathematical view-point. From a practical view point, there may be many cases where it sounds better not to dither at all, but that's a largely subjective issue...

I meant from an objective analysis point of view. However, I guess that to be sure 100% in any possible situation you can use 1 bit dither.

No dithering does add measurable distortion, for example when resampling, even with already dithered 16-bit source signals.
Title: Be careful with SSRC usage on critical tasks
Post by: tigre on 2003-03-07 17:17:06
Quote
Quote

If dither depth is near 1 (e.g. 0.99) the distortion will be masked by dither noise, so it's there but audible.


Did you mean "inaudible"?

Yes. Thanks.

I'll answer to the rest when I'm convinced  - or not.
Title: Be careful with SSRC usage on critical tasks
Post by: tigre on 2003-03-08 23:54:49
Quote
For 16-bit sources which were correctly dithered to start with, there's an argument that they are already self dithering when resampled or re-coded. However, I don't buy this argument from a mathematical view-point.

IMO the message of this argument was a bit different. It doesn't say that there's no dither needed when the signal has been dithered before. It rather says that dither slightly below 1bit depht is enough because both - noise modulation/bumbping and distortion disapears in dither noise that is already there + that is added by (1-x)bit dither.

Quote
... In that case, using exactly 1-bit, it isn't there at all. It's not that it's masked, it's that it isn't there.

The word "masked" used by me is maybe a bit misleading. I should rather say the distortion sinks into dither noise when dither depht increases from 0 to 1 and it shoud be an indistinguisable part of the noise in every case before reaching 1.

Quote
But, as you suggest, if it's perfect with 1-bit of dither, and it's a disaster with 0 dither, then there must be a sliding scale in between. If there's a compromise between (inaudible) noise and (inaudible) distortion, I'll take the noise. Mainly because digital distortion (rather than analogue distortion) is hated by the human ear, whereas noise is easily ignored.

You wrote "compromise" but it seems like you're talking about a decision ("digitally") 0=distortion vs. 1=noise. As explained above my "compromise dither depth" is proably a bit below 1.

About "distortion sinking into noise I've got an idea for a test:

Take some music, amlify it by -80...-90dB without dither introducing distortion (That's audible for sure if you'd amplify back to original level afterwards). Now add faded in white noise (-96dB -> -60dB). If you amlify now (max. amplification without clipping) and listen, you'll hear this: At the beginning there's clearly audible distortion, but as noise gets louder at some point you still hear that there's music, but you can't spot the distortion anymore as it's "sunken" into the noise (or the noise raised and swallowed it).

Quote
This may or may not convince you:

http://mp3decoders.mp3-tech.org/24bit2.html#dither (http://mp3decoders.mp3-tech.org/24bit2.html#dither)


I don't need to be convinced of the facts that are explained there anymore (thanks to KikeG's help some time ago). - You might not exspect this after my long reply, but I'll use 1bit dither (if it's flat/white noise triangular) in future because a test based on KikeG's suggestion showed me that even at 0.9bit there can be noticable noise modulation/bumping.

About noise shaped dither it's different: Trying the same with CEP's 44.1kHz noise shaped dither I found that I could not cause noise modulation even at 0.3bit dither depth but there were randomly distributed blocks of 0 samples once in a while that completely disappeared at ~0.6bit dither depth. Distortion disappeared at 0.4bit completely BTW.


Another thing I found quite interesting: here (http://www.hydrogenaudio.org/forums/index.php?act=ST&f=1&t=2941&hl=noise+shap) Frank Klemm wrote
Quote
ATH shaped is only the best for a noise free recording, which is practically not possible.
For noisy recodings you must calculate the noise shaping floor from the ATH and the noise floor of the recording. For very high noise floors the optimum is the shape of the noise floor.

The question that came to my mind reading this is: Would it be possible to create a dynamically noise shaped dither? I mean it shoud be noiseshaped in a way that in every moment as much of the dither noise as possible is masked by the signal. One problem I see here is that changing the "noise colour" dynamically could cause something similar to noise modulation/bumping, but maybe there's a way ... ?

Cheers tigre
Title: Be careful with SSRC usage on critical tasks
Post by: KikeG on 2003-03-22 11:23:27
Updated first post of the thread, adding needed values for triangular noise shaped dither (type 2).
Title: Be careful with SSRC usage on critical tasks
Post by: M on 2003-04-23 06:01:08
Someone named Tyler Knott posted a GUI for SSRC (http://webpages.charter.net/tknott/other/SSRC-Frontend.zip) on the Vorbis User and Discussion List (http://www.xiph.org/archives/vorbis/200302/0149.html). Has anyone tested this frontend? KikeG, any comments on useage?

    - M.
Title: Be careful with SSRC usage on critical tasks
Post by: rjamorim on 2003-04-23 06:13:27
You can also try the "semi-official" SSRC frontend. That's the one Naoki used to recommend at his old web page.

http://www.lantlab.org/software/archive/ss...ssrcg05600b.zip (http://www.lantlab.org/software/archive/ssrcg05600b.zip)
Title: Be careful with SSRC usage on critical tasks
Post by: KikeG on 2003-04-23 08:06:51
M, I haven't used any SSRC frontend. I have just used straight command-line options.
Title: Be careful with SSRC usage on critical tasks
Post by: plonk420 on 2003-04-23 08:19:20
'scuse my cluelessness, but is this more for 48khz to 44.1khz downsampling or can it include 44.1khz to 48khz upsampling (for creating DVDs, for example)?
Title: Be careful with SSRC usage on critical tasks
Post by: _Shorty on 2003-04-23 09:26:35
either direction
Title: Be careful with SSRC usage on critical tasks
Post by: KikeG on 2003-04-23 11:30:29
Here's a procedure suitable to check if dither applied works well and is enough:

1 - Download the 24-bit flac file at http://www.kikeg.arrakis.es/various/dith_test.flac (http://www.kikeg.arrakis.es/various/dith_test.flac)

2 - Decode the 24-bit flac file to a 24-bit wav, and convert this 24-bit wav to 16-bit using dither, using the procedure or program you want.

3 - Open the resulting 16-bit wav file into an audio editor, and normalize or amplify it so that dither noise is clearly audible. I guess you could also use things such as wavegain for this.

4 - Listen to this noise. If the noise you hear is constant throughout all the file, the dither is ok. If the volume or the "color", or the type of noise changes along the file, or there are strange weird changing noises, or anything but a constant noise, then the dither is not enough to avoid noise modulation.

This procedure also works if you encode the 24-bit file to lossy and then decode to 16 bit with dither. This way, I've for example verified that the Winamp MAD plugin 0.13b doesn't use an enough amount of dither to avoid noise modulation.