First of all, by "22k" and "8K" I'm going to assume that you are
referring to the sampling rate, and not the file size.
To change the sampling rate, changing to a factor of the current rate
is much easier. To go from 22k to 11k, you just skip every other one.
22k->5.5k, skip 3 of every 4.
To go from 22k to 8k, you want to keep 4 out of every 11 samples. The
trick is that 3 of those four sample don't align with existing samples,
so you'll have to interpolate to find out what they should be.
Basically, you have to mathematically recreate the wave form that the
samples represent, and then resample the wave at the new rate.
For example, the first 8k sample is 2/3rds the way from the 2nd to
the 3rd sample. The second is half-way between the 5th & 6th. The
third is 1/3rd the way from the 8th to the 9th. And finally, the fourth
is exactly the 11th.
So, given 22k samples of :
10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110
The translated 8k samples would be:
26, 55, 83, 110
Changing for 16-bit to 8-bit is simpler. 16-bit samples describe the
height of the wave form using numbers in the range of -32767 to +32767.
8-bit samples do the same thing, using numbers in the range -127 to
+127. To convert 16bits to 8bit, you must convert the ranges, which is
basically dividing by 256, which comes down to simply taking the
high-order byte of the 16-bit sample.