IPB

Welcome Guest ( Log In | Register )

2 Pages V   1 2 >  
Reply to this topicStart new topic
Program for dithering audio?
Firon
post Aug 21 2006, 08:22
Post #1





Group: Members
Posts: 830
Joined: 3-November 05
Member No.: 25526



Is there any program to dither and noise shape audio? I need something that applies it to the file and allows for truncation to arbitrary bit depths (ie 10-bit padded to 16 with dither + strong ATH noise shaping). foobar2000 only lets me do so for playback.
Go to the top of the page
+Quote Post
Egor
post Aug 21 2006, 08:45
Post #2





Group: Members
Posts: 826
Joined: 29-September 04
Member No.: 17374



Try the latest fb2k, it supports bit-depth conversion (see the Preferences -> Converter page).

This post has been edited by Egor: Aug 22 2006, 05:40
Go to the top of the page
+Quote Post
Klyith
post Aug 21 2006, 16:07
Post #3





Group: Members (Donating)
Posts: 352
Joined: 10-July 04
From: Albany NY USA
Member No.: 15259



QUOTE (Firon @ Aug 21 2006, 03:22) *
Is there any program to dither and noise shape audio? I need something that applies it to the file and allows for truncation to arbitrary bit depths (ie 10-bit padded to 16 with dither + strong ATH noise shaping). foobar2000 only lets me do so for playback.

Sox may be able to do that, but I don't know if it can do arbitrary bit depths. (I don't really use it that much...) It can dither, though the option is called "mask" and it doesn't have noise shaping. That's the only free tool besides foobar that I have in my holster that might do the job... Audacity has good dither and noise shaping options, but limited bit depth options.

Note: You don't need any dither or noise shaping when converting to a greater bit depth (ie 10bit to 16bit), only when decreasing depth.
Go to the top of the page
+Quote Post
Egor
post Aug 21 2006, 16:58
Post #4





Group: Members
Posts: 826
Joined: 29-September 04
Member No.: 17374



QUOTE (Klyith @ Aug 21 2006, 22:07) *
That's the only free tool besides foobar that I have in my holster that might do the job...

There is also a famous SSRC written by Naoki Shibata.
Shibatch Audio Tools
QUOTE (ssrc.txt)
<Features>
This program converts sampling rate of PCM wav file. Also, this program has
a function to apply dither to its output and extend perceived dynamic range.
Sampling rates of 44.1kHz and 48kHz are populary used, but ratio of these
two frequency is 147:160, and it's not a small numbers. Therefore, sampling
rate conversion without degradation of sound quality requires filter with very
large order, and it's difficult to achive both quality and speed. This program
achived relatively fast and high quality with two different kinds of filters
combined skillfully.

<Usage>

ssrc [<options>] <input wav file> <output wav file>

Usage of options are as follows :
--rate <sampling rate>
Specify sampling rate of output file.
--att <value(dB)>
Attenuate volume of output by specified value.
--twopass
Perform two pass processing so that clipping is avoided.
At the first pass, the program converts sampling rate of input file and
write to a temporary file in float numbers while scanning clippings. At
the second pass, the program attenuate the volume so that clipping is
prevented, and write to the output file.
--normalize
Normalize the wave file.
--dither [<type>]
Apply dithers to the output file.
type 0 : no dither
type 1 : no noise shaping
type 2 : triangular dither
type 3 : ATH based noise shaping
--bits
Specify quantization bit length. 8, 16 and 24bits are supported.
--quiet
Nothing is displayed except error.
--pdf <type> [<amp>]
Select probability distribution function and amplitude of noise.
type 0 : rectangular
type 1 : triangular
type 2 : Gaussian
--profile
Specify profile
"standard" profile : the default setting
"fast" profile : about x2 speed, not so bad quality

Only PCM coded wav files are used as input and output files.
Input and output sampling frequency must satisfy a certain condition, but
(probably) conversions between all populary used sampling frequencies are
supported.
If sampling frequencies of input and output are same, sampling rate
conversion is not performed and only conversion of quantization bit length
with optional dithering are done.
Go to the top of the page
+Quote Post
Firon
post Aug 23 2006, 04:51
Post #5





Group: Members
Posts: 830
Joined: 3-November 05
Member No.: 25526



Thanks for the help.

I'll look into the latest foobar (I'm still 0.8.3), as well as SSRC.

Sox might be useful for converting to 10-bit, but I really do need the noise shaping along with dithering.
Go to the top of the page
+Quote Post
Egor
post Aug 23 2006, 05:10
Post #6





Group: Members
Posts: 826
Joined: 29-September 04
Member No.: 17374



I ought to have mentioned that fb2k doesn't support conversion to arbitrary bit-depths.

Edit. Quick search revealed this software.

This post has been edited by Egor: Aug 23 2006, 05:39
Go to the top of the page
+Quote Post
SebastianG
post Aug 23 2006, 08:29
Post #7





Group: Developer
Posts: 1318
Joined: 20-March 04
From: Göttingen (DE)
Member No.: 12875



QUOTE (Firon @ Aug 23 2006, 05:51) *
(...) but I really do need the noise shaping along with dithering.

Why do you need to dither & noise-shape to 10 bit samples? ... if I may ask
Also, what sampling rates are you targeting? Only 44 kHz?

Doing 10 bits at 44 kHz will be pretty noisy I suppose -- even with dithering & noise shaping enabled.
10 bits for 88 kHz or above will be fine quality-wise (you can push most of the noise out of the audible band)

If anyone cares: I designed some neat "symmetric" (poles = -zeros) noise-shaping filters for rates around 96 kHz by hand. Here's a 6th order example with 20 dB attenuation below 0.43*nyquist_frequency:
CODE
       1 - a z^-1 + b z^-2 - c z^-3 + d z^-4 - e z^-5 + f z^-6
H(z) = -------------------------------------------------------
       1 + a z^-1 + b z^-2 + c z^-3 + d z^-4 + e z^-5 + f z^-6

with
a= 1.45619118675708
b= 2.24132454071640
c= 1.76666007562633
d= 1.14160366651250
e= 0.43188674232519
f= 0.09261200141284

(This thing at 16/96 will give you 20/44-like performance in the audible band (0-20 kHz) PLUS a flat response up to at least 40 kHz with an appropriate reconstruction filter)

This post has been edited by SebastianG: Aug 23 2006, 08:56
Go to the top of the page
+Quote Post
SebastianG
post Aug 23 2006, 08:58
Post #8





Group: Developer
Posts: 1318
Joined: 20-March 04
From: Göttingen (DE)
Member No.: 12875



QUOTE (Egor @ Aug 23 2006, 06:10) *
Edit. Quick search revealed this software.

...looks promising, but only supports FIR noise shaping filters (no IIR filters)
Go to the top of the page
+Quote Post
SebastianG
post Aug 23 2006, 17:05
Post #9





Group: Developer
Posts: 1318
Joined: 20-March 04
From: Göttingen (DE)
Member No.: 12875



QUOTE (ssrc)
--dither [<type>]
dithering
type 0 : no dither
type 1 : no noise shaping
type 2 : triangular dither
type 3 : ATH based noise shaping
type 4 : less dither amplitude than type 3
--pdf <type> [<amp>]
select p.d.f. of noise
type 0 : rectangular
type 1 : triangular
type 2 : Gaussian

Oh boy! Somebody's been mixing up dithering with noise shaping. It's not really obvious what all these "types" do. Does type 0 dither (called "no dither") imply that dithering is done for type 1,2,3 ? Does type 1 dither (called "no noise shaping") imply that noise shaping is done for type 0,2,3,4 ? If so what kind of noise shaping is used for type 0,2,3,4 and what kind of dithering is used for type 1-4 ?

Also, what does "--dither 2 --pdf 0" do ? tongue.gif
Go to the top of the page
+Quote Post
Firon
post Aug 25 2006, 04:46
Post #10





Group: Members
Posts: 830
Joined: 3-November 05
Member No.: 25526



I'm playing around with my Nintendo DS, and its DAC is only 10-bit (if only it was at least 12, it'd be much better!). The playback software doesn't really seem to dither much, if at all (probably due to lack of CPU power), so quiet sections don't sound very good. Non-quiet sections sound pretty decent though.
I wanted to truncate and pre-dither/noise-shape the file to see if it'd sound any better. The target sample rate is 44KHz.

As for that ssrc thing, it seems like the dither options are taken from foobar2000's playback preferences. Assuming it is, type 1 is dither without noise shaping, 2 is dithering with triangular noise shaping, and type 3 is dithering with ATH noise shaping. Type 4 is probably dither with "soft" ATH noise shaping. The --pdf things just confuse things though. I wonder which one would override the other. tongue.gif

This post has been edited by Firon: Aug 25 2006, 04:55
Go to the top of the page
+Quote Post
SebastianG
post Aug 25 2006, 15:42
Post #11





Group: Developer
Posts: 1318
Joined: 20-March 04
From: Göttingen (DE)
Member No.: 12875



10 bits at 44 kHz isn't that bad actually. 12 bits sound really good. I tested it with this java commandline tool I wrote today. It uses a 8th order IIR "ATH" noise shaping filter (for 44 kHz content) with the following response:


Try it for yourself. How many bits do you really need? biggrin.gif

java -jar requant.jar -d1.2 source.wav tobecomputed.wav 10

edit: current version is 0.17b

Cheers!

This post has been edited by SebastianG: Aug 25 2006, 21:35
Go to the top of the page
+Quote Post
Firon
post Aug 25 2006, 23:53
Post #12





Group: Members
Posts: 830
Joined: 3-November 05
Member No.: 25526



The hiss from the dithering is stronger than the noise from quantization error.

It may be possible to go up to 48KHz (though the source files are only 44, guess it'd need some resampling first), would that make a difference?

Edit: speak of the devil, it's nowhere near as strong when I hear it on headphones instead of my speakers.

This post has been edited by Firon: Aug 25 2006, 23:57
Go to the top of the page
+Quote Post
saratoga
post Aug 26 2006, 02:23
Post #13





Group: Members
Posts: 4925
Joined: 2-September 02
Member No.: 3264



QUOTE (SebastianG @ Aug 23 2006, 00:58) *
QUOTE (Egor @ Aug 23 2006, 06:10) *

Edit. Quick search revealed this software.

...looks promising, but only supports FIR noise shaping filters (no IIR filters)


Silly question: Why is that a problem?
Go to the top of the page
+Quote Post
crimsontide
post Aug 27 2006, 16:34
Post #14





Group: Members
Posts: 20
Joined: 13-March 06
Member No.: 28437



I have played around with Audacity before...it used to allow two or three different algorithms for resampling the bitrate, with/without dither, and a number of different types of dither as well, it was the most flexible beast available a while back, but strangely, I downlaoded it and cant find the option anymore.....

it was there, i once set up a whole college to use audacity to upsample from 16bit to 24 bit, and vice versa.........cant for the life of me remember how i did it though....muppet.


--------------------
Gone.
Go to the top of the page
+Quote Post
rutra80
post Aug 27 2006, 22:28
Post #15





Group: Members (Donating)
Posts: 810
Joined: 12-September 03
Member No.: 8821



In v1.2.4 it's still in Preferences (Quality tab).
Go to the top of the page
+Quote Post
SebastianG
post Aug 28 2006, 08:26
Post #16





Group: Developer
Posts: 1318
Joined: 20-March 04
From: Göttingen (DE)
Member No.: 12875



QUOTE (Firon @ Aug 26 2006, 00:53) *
The hiss from the dithering is stronger than the noise from quantization error.

Huh? What exactly did you compare?

QUOTE (Mike Giacomelli @ Aug 26 2006, 03:23) *
QUOTE (SebastianG @ Aug 23 2006, 00:58) *

...looks promising, but only supports FIR noise shaping filters (no IIR filters)

Silly question: Why is that a problem?

Silly? No. Well, you need minimum phase filters for noise shaping. So, there's no advantege of FIR filters over IIR filters. In fact, it's fairly easy to design low order IIR filters with desirable responses whereas FIR filters need to be "long" to match the desired response. It's not a problem but an unnecessary restriction which comes at the cost of reduced speed.

PS:
I may publish a graphical IIR filter design tool that let's you listen to shaped white noise while editing the filter. You could then design your own noise shaping filters.
Go to the top of the page
+Quote Post
Firon
post Sep 1 2006, 08:07
Post #17





Group: Members
Posts: 830
Joined: 3-November 05
Member No.: 25526



I compared the output from your program using one of my songs, and then compared to the same song truncated to 10 bits with foobar2000. The truncated version sounded less objectionable (to my ears), though the difference wasn't so great when I used my cheapo headphones instead of my speakers.

This post has been edited by Firon: Sep 1 2006, 08:07
Go to the top of the page
+Quote Post
kjoonlee
post Sep 1 2006, 08:27
Post #18





Group: Members
Posts: 2526
Joined: 25-July 02
From: South Korea
Member No.: 2782



Was the comparison double-blind? smile.gif


--------------------
http://blacksun.ivyro.net/vorbis/vorbisfaq.htm
Go to the top of the page
+Quote Post
2Bdecided
post Sep 1 2006, 11:47
Post #19


ReplayGain developer


Group: Developer
Posts: 5108
Joined: 5-November 01
From: Yorkshire, UK
Member No.: 409



Can I make a terrible suggestion (especially given the arguments raging in other threads)?

It's possible to noise shape without dithering.

What this means is that the quantisation distortion stays exactly that - distortion - but its spectrum is shaped to try to make it less audible.

It's how SACD works (with its one bit!).

It might just be worth a try at 10-bits.

The other trick you can try is to use sub-optimal dither - e.g. lower amplitude. By the time you get to half what you should have, distortion starts to be obvious (though not always objectionable). On many signals, the distortion is comparatively low (sometimes inaudible) at dither levels between half the correct amount, and "the correct amount".

So it might be worth reducing the dither amplitude, if possible.

(Yes, this is all terrible, and not optimal at all - but he's talking about 10 bits!!!)

Cheers,
David.

This post has been edited by 2Bdecided: Sep 1 2006, 11:49
Go to the top of the page
+Quote Post
SebastianG
post Sep 1 2006, 12:24
Post #20





Group: Developer
Posts: 1318
Joined: 20-March 04
From: Göttingen (DE)
Member No.: 12875



Actually that's what I tried. I was able to reduce the amount of dither when noise shaping was enabled. I tried it with 8 bits/sample + the ATH derived noise shaping filter. My test song started out silently so I could hear the difference between rectangular and triangular dithering wihouth noise shaping. With noise shaping enabled it sounded pretty good with a quite low dither less than +/- 1/2 LSB of rectangular dither. However dithering below a certain amplitude -- say +/-1/4 LSB -- doesn't really help reducing the noise power. But it does seem to be sufficient in most cases when strong noise shaping is in use.

Of course, to be on the safe side you can still use full triangular dithering

This post has been edited by SebastianG: Sep 1 2006, 12:31
Go to the top of the page
+Quote Post
2Bdecided
post Sep 1 2006, 13:17
Post #21


ReplayGain developer


Group: Developer
Posts: 5108
Joined: 5-November 01
From: Yorkshire, UK
Member No.: 409



That inspired me to play with the options in Cool Edit Pro.

In answer to "how many bits is enough", if you're listening to pop music in a noisy environment, I'd say between 6 and 7!

Attached File  6_bit_A_hard_day__s_night___The_Beatles.flac ( 1.29MB ) Number of downloads: 338

Attached File  7_bit_A_hard_day__s_night___The_Beatles.flac ( 1.13MB ) Number of downloads: 307


(CEP settings: 0.1 bit dither, triangular, 48kHz (!) noise shaping, 6 or 7 bits target padded to 8-bits)

Heavy noise shaping at 44.1kHz prevents you going much further because the high frequency noise is taking up ~ 4-bits!

With this kind of processing, where do you go with a portable device that is so quiet that you need more than 10-bits?! wink.gif

Cheers,
David.
Go to the top of the page
+Quote Post
SebastianG
post Sep 1 2006, 14:38
Post #22





Group: Developer
Posts: 1318
Joined: 20-March 04
From: Göttingen (DE)
Member No.: 12875



noise power relative to full rectangular dither (+/-0.5) under the assumption the noise is NOT correlated before shaping (ie no non-linear distortions):
CODE
rectangular dither: +/- 0.5   -0.00 dB (obviously)
rectangular dither: +/- 0.4   -0.86 dB
rectangular dither: +/- 0.3   -1.67 dB
rectangular dither: +/- 0.2   -2.37 dB
rectangular dither: +/- 0.15  -2.64 dB
rectangular dither: +/- 0.1   -2.84 dB
rectangular dither: +/- 0.05  -2.97 dB
rectangular dither: +/- 0.0   -3.01 dB

Decide for yourself whether a given dither level is worth the risk of harmonic distortions.
I'd probably try 0.2 next time because below that the noise power doesn't drop significantly.

Is there any interest in an interactive/live noise shaper design tool?
I could make the proggy a bit more user-friendly if anyone whishes to have a play ...

BTW: I'm totally fine with 12 bits at 44kHz with noise shaping enabled and moderate dithering.
I really can't distinguish it from the 16 bit version using ear buds. It may be due to my computer's fans.

2Bdecided: Could you post a file containing TPDF dithered silence using the same noise shaper you used to make the 6bit/7bit files? I'm interested in what the shaper actually does. I have no CE Pro smile.gif

Edit: I think it's possible to prove that a certain dither level (below the alredy known-to-be-safe levels) is secure given the impulse response of the noise shaper -- me needs to think more about it.

Edit2: The old Beatles song may already contain enough noise so one does not need a dither. It'd be nice to have a 16 bit reference.

This post has been edited by SebastianG: Sep 1 2006, 14:56
Go to the top of the page
+Quote Post
2Bdecided
post Sep 1 2006, 17:14
Post #23


ReplayGain developer


Group: Developer
Posts: 5108
Joined: 5-November 01
From: Yorkshire, UK
Member No.: 409



Hi Sebastian,

0.1 bits isn't enough to be clean on silent parts. To avoid distortion entirely with noise shaping you need 0.5 bits of dither (as CEP counts it, compared to 1-bit without noise shaping).

I'll try to remember to post the various CEP noise shaping curves next week. They're not that interesting really.

Cheers,
David.


QUOTE (SebastianG @ Sep 1 2006, 14:38) *
Edit: I think it's possible to prove that a certain dither level (below the alredy known-to-be-safe levels) is secure given the impulse response of the noise shaper -- me needs to think more about it.


Practical experience suggests you're on to something there.

I wonder if the Lipshitz and Vanderkooy vs James Angus arguments about DSD (1-bit systems) ever mentioned this? It could have been crucial if true, because it could demolish Lipshitz and Vanderkooy's argument against DSD (which, put simply, is that to avoid distortion, you have to fill the one bit you have with dither, thus leaving no room for a signal!).

I used to have some of the papers, but can't find them now.

Cheers,
David.
Go to the top of the page
+Quote Post
Woodinville
post Sep 1 2006, 18:18
Post #24





Group: Members
Posts: 1402
Joined: 9-January 05
From: JJ's office.
Member No.: 18957



QUOTE (2Bdecided @ Sep 1 2006, 09:14) *
I wonder if the Lipshitz and Vanderkooy vs James Angus arguments about DSD (1-bit systems) ever mentioned this? It could have been crucial if true, because it could demolish Lipshitz and Vanderkooy's argument against DSD (which, put simply, is that to avoid distortion, you have to fill the one bit you have with dither, thus leaving no room for a signal!).

I used to have some of the papers, but can't find them now.

Cheers,
David.


Err, no, you still have overload if you have half a bit of dither, and 1 bit of signal.


--------------------
-----
J. D. (jj) Johnston
Go to the top of the page
+Quote Post
SebastianG
post Sep 1 2006, 18:32
Post #25





Group: Developer
Posts: 1318
Joined: 20-March 04
From: Göttingen (DE)
Member No.: 12875



Actually -- from what I know -- you don't have "one bit of signal". Suppose the DSD's bits correspond to the levels -1 and 1 then the DSD encoder makes sure the signal is scaled to be within -0.5 ... 0.5 (I'm not sure about the exact range, it may also be -0.7 ... 0.7)

At least this is what I remember having read somewhere (sorry, no reference)

This post has been edited by SebastianG: Sep 1 2006, 18:33
Go to the top of the page
+Quote Post

2 Pages V   1 2 >
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 2nd September 2014 - 05:36