char signal8bit[] = { ... };
short* signal16bit = new short[numsamples];
for(int i = 0; i < numsamples; i++)
signal16bit[i] = signal8bit[i] << 8;
Similarly, downsampling shouldn''t be much other than 8bitvalue = 16bitvalue >> 8, should it?
Maybe I''m an idiot, but what''s the catch here?
Bitrate conversion
I''m talking about writing a bitrate converter, not using some wave editor, which I am perfectly capable of doing myself, thank you very much .
Anyway, you''d think that 8 bit to 16 bit conversion should be lossless and work as simply as: 16bitvalue = 8bitvalue << 8, but it''s not - for some reason I''m getting heavy noise instead, which only very remotely resembles the original signal.
In other words, the following doesn''t work:
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
Nope - signedness doesn''t have anything to do with this. After a little bit of reverse engineering, this seems to be the solution:
16bitvalue = (8bitvalue + 128) << 8;
Or, in the generic form:
I think so at least... If anyone spots an error, let me know.
16bitvalue = (8bitvalue + 128) << 8;
Or, in the generic form:
//SBD - source bit depth//DBD - destination bit depth//val - sample to convertint RedefineBitDepth(int val, int SBD, int DBD){ //upgrade if(DBD > SBD) return ((val + (1 << SBD - 1)) << (DBD - SBD)); //downgrade else return ((val - (1 << SBD - 1)) >> (SBD - DBD));}
I think so at least... If anyone spots an error, let me know.
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
You''re programming could be absolutely correct, I really don''t know. But anything in 8 bit is gonna give you noise in the background, it''s one of those reasons why we have 16, and soon 32 bit :D
There is some audio theory (that I don''t know) that you have to take into consideration when changing bit rates in a file. The waveform is greatly affected by any changes made to it.
Doesn''t help, but maybe, i unno.
cheers!
There is some audio theory (that I don''t know) that you have to take into consideration when changing bit rates in a file. The waveform is greatly affected by any changes made to it.
Doesn''t help, but maybe, i unno.
cheers!
May 21, 2004 04:03 PM
the noise you get has to do with the SQNR (signal-to-quantization-noise-ratio /or something) the more bitrate you use the more range of values to quantize the signal you will have.
8 bit -> 256 values of amplitude
16 bit -> 65536 values
this amount of values manage the same signal you are using to record, so in 8 bit you have less positions to quantize.
i hope my english explain it well, if not, search for "sqnr".
8 bit -> 256 values of amplitude
16 bit -> 65536 values
this amount of values manage the same signal you are using to record, so in 8 bit you have less positions to quantize.
i hope my english explain it well, if not, search for "sqnr".
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement