0-How ST3 mixes:

1) volumetable is created in the following way:

> volumetable[volume][sampledata]=volume*(sampledata-128)/64;

NOTE: sampledata in memory is unsigned in ST3, so the -128 in the
	  formula converts it so that the volumetable output is signed.

2) postprocessing table is created with this pseudocode:

> z=mastervol&127;
> if(z<0x10) z=0x10;
> c=2048*16/z;                  WIDTH
> a=(2048-c)/2;					LOWER BOUND
> b=a+c;						UPPER BOUND
>                     { 0                , if x < a
> posttable[x+1024] = { (x-a)*256/(b-a)  , if a <= x < b
>                     { 255              , if x > b

3) mixing the samples

output=1024
for i=0 to number of channels
		output+=volumetable[volume*globalvolume/64][sampledata];
next
realoutput=posttable[output]


This is how the mixing is done in theory. In practice it's a bit
different for speed reasons, but the result is the same.





> z=mastervol&127;
> if(z<0x10) z=0x10;
> c=2048*16/z;                  WIDTH
> a=(2048-c)/2;					LOWER BOUND
> b=a+c;						UPPER BOUND
>                     { 0                , if x < a
> posttable[x+1024] = { (x-a)*256/(c)    , if a <= x < b
>                     { 255              , if x > b


z = masterVol & 0xFF;
if (z < 0x10) z = 0x10;
c = 2048*16/z; 			// width
a = (2048-c)/2;			// lower bound
b = a + c;				// upper bound

postTable = malloc(8192*sizeof(unsigned char));

for (x = 0; x < 8192; x++)
{
	if (x < a)
		postTable[x] = 0;
	else if (x > b)
		postTable[x] = 0xFF;
	else // a <= x < b
		postTable[x] = (x-a)*256/c;
}


output = 4096;
globalVol = 64; // max volume
scaledVol = globalVol >> 6; // globalVol/64
volume = 64;

for (i = 0; i < kEnsoniqNumOscs; i++)
{
//	output += volume*(sampledata-128)/64;
	output += (char) curOscSoundByte-128;
}

	curMixSoundByte = postTable[output];