MC3418 CVSD Encoding (Was: Re: Looking for IBM PS/2 or PCjr SpeechAdapter Tech Ref

Julian Skidmore julianskidmore at yahoo.com
Thu May 7 14:55:00 CDT 2009


Michael B. Brutman wrote:

> I understand the 
> principle behind CVSD encoding and decoding, but not enough to start 
> writing code.  I want to write some code takes CVSD encoded data and 
> displays the waveform on a screen, for a sound editor.

CVSD decoding is a simple algorithm, here's a version which works one bit at a time:

typedef unsigned short ushort;
typedef unsigned short bit;	// should be a range 0..1.

#define kCvsdMaxGain 8
#define kCvsdIntegrator 15

ushort gCvsdDecGain=1, gCvsdDecRefSample=32768;
ushort gCvsdDecRecentBits=0xaaaa;

ushort CvsdDec(bit aBit)
{
	gCvsdDecRecentBits=(gCvsdDecRecentBits<<1)|aBit;
	gCvsdDecRefSample+= (aBit==1)? gCvsdDecGain:-gCvsdDecGain;
	if(((gCvsdDecRecentBits&kCvsdIntegrator)==kCvsdIntegrator) ||
	     ((gCvsdDecRecentBits&7)==0) ) {
		if(gCvsdDecGain<kCvsdMaxGain)
			gCvsdDecGain<<=1;
	}
	else
		kCvsdMaxGain=(kCvsdMaxGain+1)>>1;
	return gCvsdDecRefSample;
}

All you have to do is pick the right maximum gain and integrator. Somewhat wrong values will still produce something recognisable.

-cheers from julz @P



      



More information about the cctalk mailing list