Variable bit depth
Posted: Sat Jan 02, 2010 3:17 pm
As part of a digital audio degradation effect, I want to simultaneously reduce sample rate, bit depth and dynamic range. The sample rate reduction (faked with a square wave ring modulator) and dynamics I have figured out, at least conceptually.
But I'm not sure how to have a pot-variable bit depth. I know it's possible to use AND to mask off bits, but can't yet think of a way to make this variable from max down to... maybe 1 or 2 bits. Anybody have any ideas?
I found this by Frank:
But I'm not sure how to have a pot-variable bit depth. I know it's possible to use AND to mask off bits, but can't yet think of a way to make this variable from max down to... maybe 1 or 2 bits. Anybody have any ideas?
I found this by Frank:
Seems like maybe a MULX in there somewhere could do the job?frank wrote:Here's a simple example, simply ANDing off the lower bits:You could get fancier (use a POT input to determine mask, etc.)Code: Select all
crush equ 0xfc0000 ;define the bit mask - 6 bits here clr rdax adcl,0.5 rdax adcr,0.5 skp neg,invit; working with 2's comp numbers, if negative skip down and crush skp gez,outter invit: sof -1.0,0 ; for negative samples, invert them, and crush ; mask the data sof -1.0,0 ; invert it back outter: wrax dacl,1.0 wrax dacr,1.0