# Thread: 16bit samples stored in shorts how i can reduce bits ?

1. ## 16bit samples stored in shorts how i can reduce bits ?

16bit samples stored in shorts how i can reduce bits ? i meann idea
not sources. i try learn code itself (i not school but i still dont want premade solutions for this)... i mean way make 16bit sample sound for example 4bit/8bit... and these are are audiosamples. 2. Divide the 16-bit number by 2 (for 8 bit)?? 3. but same algorithm i think works for pics....(what i means something i have book which have image processing algorithms)
and i want flexible code this code what i have makes fixed amount steps which means is still better than nothing. 4. Dividing by 2 is incorrect, dunno why I said that. Divide by 256.

Edit: if you want something more accurate you'll have to convert the input to a double, get the number as a percentage of the entire range (for 16-bits) and multiply this percentage by the range of the 8-bit type. For results even more accurate you'll need some fancy mathematics. 5. hodor but when i want still use whole range which is main problem. fi sample data goes originally in 4bit for this way:
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
after code i get (and i algorithm what i can adjust not fixed ones which are so easy do)
0,0,0,0,4,4,4,4,8,8,8,8,12,12,12,12
my idea diving for example for example 2 and after this multiplying 2 dont work i think... 6. An 8 bit number
10011100

The same 8 bit number reduced to a 4-bit range
00001001
This you get by doing something like
var = var >> 4;

The same 8 bit number reduced to a 4 bit range, but still stored in an 8 bit range.
10010000
This you get by doing something like
var = var & 0xf0;

> i mean way make 16bit sample sound for example 4bit/8bit... and these are are audiosamples.
You can't just chop off bits and preserve any sense of audio quality.
If you want meaningful compression (which has only a minor effect on quality, but saves a lot of space), then you need to read up on the theory of audio compression, and look at how MP3, OGG etc achieve their results. 7. It's easy to reduce bits if you don't need to recover the original data, or can accept a non-zero error rate (i.e. loss of data).

If you need to recover the original data, you need to look for patterns in the bits (or in sets of ints) and do some form of encoding. Compression algorithms do this all the time. There are trade-offs, naturally. No encoding scheme can compress all possible sets of input data - and in the worst case, may increase the size. 8. I know reducing bits affect sound quality and is what i want. this effect is common and gives "oldschool" falvour. i maybe found solutiong based what different people wrote here... 9. If you're just trying to distort the sound a bit, try masking off (set to zero) the lower order bits, like x = x & ((short)0 - (short)16). Popular pages Recent additions 