Re: Converting 16/8-bit samples to 4-bit

From: Marko Mäkelä (msmakela_at_cc.hut.fi)
Date: 1999-10-01 14:51:02

On Fri, 1 Oct 1999, Robin Harbron wrote:

> Is the best way to convert a 16 or 8 bit sample to 4-bit (to play
> on the SID) just to take the most significant (nibble?) nybble?

It depends.  If the conversion has to be done on-the-fly, in one pass,
then it probably is.  Otherwise, you could make a histogram of the sample*
and make the quantification to 16 values based on the histogram.  A cheap
approximation would be to determine the minimum and maximum sample and use
a formula like

	quant = 16 * (value - min) / (max - min)

for the quantification.  For instance, when quantifying 8-bit samples
having min=50 and max=170 (which is equivalent to min=50 and max=120) the
simple quantification of taking the most significant bits would waste one
bit of accuracy.

Probably someone will follow up to this and tell what kind of digital
signal processing algorithms you could apply, and whether the histogram
idea is feasible at all.  Doesn't dithering imply increasing the sampling
frequency?

	Marko

* "sample" actually means just one sample (e.g. one 8-bit value), but the
word is often used for referring to a sequence of samples.

-
This message was sent through the cbm-hackers mailing list.
To unsubscribe: echo unsubscribe | mail cbm-hackers-request@dot.tcm.hut.fi.

Archive generated by hypermail 2.1.1.