Which format does arts need in order to play the samples correctly?

Jorge j.windmeisser at elogix.info
Wed Sep 17 14:33:58 BST 2003


I'm still stuck with my arts problem. I have a muLaw sample that I need to playback on arts.
If I play the uLaw sample with a test program I've written, I get the same crappy sound as
if played by artscat.

Arnold suggested that the format should be WAV, and there comes the next problem, has
someone a function that converts a uLaw to WAV? I've looked throught the internet and
have found the following:

static int ulaw_to_linear(unsigned char byte)
{
	static int exp[8] = { 0, 132, 396, 924, 1980, 4092, 8316, 16764 };

	int	sign;
	int	exponent;
	int	mantissa;
	int	sample;

	byte = ~byte;
	sign		= (byte & 0x80);
	exponent = (byte >> 4) & 0x07;
	mantissa = byte & 0x0F;
	sample	= exp[exponent] + (mantissa << (exponent + 3));

	if (sign != 0) sample = -sample;

	return(sample);
}

AND

static int ulaw_to_s16(unsigned char byte)
{
	int t;

	/* Complement to obtain normal u-law value. */
	byte = ~byte;

	/*
	 * Extract and bias the quantization bits. Then
	 * shift up by the segment number and subtract out the bias.
	 */
	t = ((byte & 0x0f) << 3) + 0x84;
	t <<= (byte & 0x70) >> 4;

	return ((byte & 0x80) ? (0x84 - t) : (t - 0x84));
}

But if I use them the sound is worse than being played without conversion. I've
still not found any uLaw to WAV conversion function.

Any functions? Any links? Suggestions?

Thank you.



More information about the kde-multimedia mailing list