To convert floating-point sample data to 16-bit, simply multiply each sample by 32768, and restrict the result to between -32768 and 32767. For example...
void float2short(float *src,short *dst,int count)
{
int a;
for (a=0;a<count;a++) {
int b=src[a]*32768;
if (b<-32768) b=-32768;
else if (b>32767) b=32767;
dst[a]=(short)b;
}
}
For 8-bit, multiply by 128, add 128 (because 8-bit PCM is unsigned), and restrict the result to between 0 and 255.