shithub: sox

Download patch

ref: e7181aa390f66a33a8fcac93ac82c2a2ffc3811f
parent: 61a6f4ef4710da68fc1331622196a2c6d6f881ad
author: rrt <rrt>
date: Mon Jan 15 19:47:21 EST 2007

Put output precision adjustment back into mask

--- a/src/mask.c
+++ b/src/mask.c
@@ -48,6 +48,32 @@
   return ST_SUCCESS;
 }
 
+static int st_mask_start(eff_t effp)
+{
+  mask_t mask = (mask_t) effp->priv;
+
+  if (effp->outinfo.encoding == ST_ENCODING_ULAW ||
+      effp->outinfo.encoding == ST_ENCODING_ALAW) {
+    mask->amount *= 16;
+    return ST_SUCCESS;
+  } else if (effp->outinfo.size == ST_SIZE_BYTE) {
+    mask->amount *= 256;
+    return ST_SUCCESS;
+  } else if (effp->outinfo.size == ST_SIZE_WORD)
+    return ST_SUCCESS;
+  else if (effp->outinfo.size == ST_SIZE_24BIT) {
+    mask->amount /= 256;
+    return ST_SUCCESS;
+  } else if (effp->outinfo.size == ST_SIZE_DDWORD) {
+    mask->amount /= 16384;
+    return ST_SUCCESS;
+  }
+
+  st_fail("Invalid size %d", effp->outinfo.size);
+  return ST_EOF;
+}
+
+/* FIXME: Scale noise more sensibly for sizes >= 24 bits */
 static int st_mask_flow(eff_t effp, const st_sample_t * ibuf,
     st_sample_t * obuf, st_size_t * isamp, st_size_t * osamp)
 {
@@ -85,7 +111,7 @@
   "Usage: dither [amount]",
   ST_EFF_MCHAN,
   st_mask_getopts,
-  st_effect_nothing,
+  st_mask_start,
   st_mask_flow,
   st_effect_nothing_drain,
   st_effect_nothing,