Chill. We're not trying to make him feel like an idiot. There was obviously a breakdown in communication (I won't do any blaming on this one; I don't care who's to blame), we've tried to clarify things, I corrected a technical flaw in something that was said, xoxos had attitude about the correction, Hodgman warned him about his attitude, you posted, and now I'm here making another post (but I had fun doing the below experiment).
Changing audio from 8 bits to 16 bits is not a resampling operation
Yes it is... If you have sampled at 8 bits, and need new samples at 16 bits, you have to resample (regardless of how you do it, even if it's just shifting left 8 bits). That's exactly what resampling is.
and can indeed be done with a bitshift.
Not if you really care about your waveform's quality. There are different ways to do it too, like linearly scaling your samples to 16 bits. Which is best depends on various factors, like what kind of noise reduction algorithm you use after resampling (but I'd say neither is best without the noise reduction step).
So all of you arguing about how difficult an operation resampling is and how he's asking the wrong question are completely off the mark here.
We were off the mark, yes, but because we misunderstood what he wanted (I believe... I'm still not 100% sure). It sounds to me (in retrospect) that he has 16 bit audio data and he just wanted to know how to proper pass a byte pointer to this data, which yes, is not a resampling question (it's just a casting question). BUT, honestly, properly resampling is
not a trivial task (assuming you want good audio, which I've always stated when I say this; if you don't care so much, yes, you can do it trivially). You have to do things like
dither, and your dithering algorithm can make a big difference. Just rescaling your audio samples will kind of work, but it's not the "proper" way to do it.
When you quantize your waveform to 8 bits, and then resample it to 16 bits, you've got 8 extra bits to play with. Good resampling libraries will try to use those bits to minimize the noise you introduced when you first quantized to 8 bits.
I got bored and made a simple sample program that makes a sine wave, samples it to 8 bits, and then resamples it to 16 bits (either by shifting or linearly scaling) and optionally adding a trivial dither (note I haven't fine tuned it--at all). Listen to the 4 samples attached and decide what you think are best, and see how each one was made in the spoiler tag. Note that I didn't use any fancy noise reduction algorithm, and I have no doubt that if these were properly processed the quality would be much greater (but would only further prove that shifting/scaling your samples isn't enough). All samples are mono, 44100Hz.
[attachment=10705:A.wav][attachment=10706:B.wav][attachment=10707:C.wav][attachment=10708:D.wav]
[spoiler]
Seriously, don't just look at this info without giving the test an honest effort!
[spoiler]
You sure you're ready?
[spoiler]
A = Resampled with shift left 8 bits, dither added
B = Resampled with multiply (linear scaling), no dither
C = Resampled with multiply (linear scaling), dither added
D = Resampled with shift left 8 bits, no dither
The one I thought was best was (don't peak unless you've made your decision!):
[spoiler]
A, though C was close (I think A's lack of using the low bits helped make the dither more effective)
B and D have a higher frequency noise that I think sounds worse.
[/spoiler]
[/spoiler]
[/spoiler]
[/spoiler]
Anyway, now I'm getting off track.