ref: 5c42375e664ccf19b370ac90774ccc6a1ad58ed9
parent: 413d65e4bb9d9189792f6a86dadd87939a68890d
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Mar 3 09:45:14 EST 2014
pcmconv: revert previous change, fix dither clipping previous change had forgot how dithering works... m( we *really* add a random signal when *reducing* the number of bits. just make sure we do not overflow like in mixin().
--- a/sys/src/cmd/audio/pcmconv/pcmconv.c
+++ b/sys/src/cmd/audio/pcmconv/pcmconv.c
@@ -209,12 +209,13 @@
{static ulong prnd;
- if(ibits >= 32 || ibits >= obits)
+ if(ibits >= 32 || obits >= ibits)
return;
while(count--){prnd = (prnd*0x19660dL + 0x3c6ef35fL) & 0xffffffffL;
- *y++ += ((int)prnd) >> ibits;
+ *y = clip((vlong)*y + ((int)prnd >> ibits));
+ y++;
}
}
--
⑨