shithub: sox

Download patch

ref: 9814ae85dddad6f43e47ae6d5b8aa2faaab784a0
parent: d9f802125f1be5d003406645d995c9d7a36684f7
author: Ulrich Klauer <ulrich@chirlu.de>
date: Tue Dec 27 16:17:08 EST 2011

Warn when trying to dither to 1 bit

Dithering to 1 bit resolution doesn't work with the general-purpose
routines since, for signed integer, only the sign bit is available
at 1 bit. The dither effect will clip on each sample. So, for now,
issue a warning and give up.

--- a/src/dither.c
+++ b/src/dither.c
@@ -359,6 +359,16 @@
 
   if (effp->in_signal.precision <= p->prec || p->prec > 24)
     return SOX_EFF_NULL;   /* Dithering not needed at this resolution */
+
+  if (p->prec == 1) {
+    /* The general dither routines don't work in this case, so notify
+       user and leave it at that for now.
+       TODO: Some special-case treatment of 1-bit noise shaping will be
+         needed for meaningful DSD write support. */
+    lsx_warn("Dithering/noise-shaping to 1 bit is currently not supported.");
+    return SOX_EFF_NULL;
+  }
+
   effp->out_signal.precision = p->prec;
 
   p->flow = flow_no_shape;