Opps, right - 8-bit sample typically are unsigned. But 16-bits are signed. So simply prepending 0 bits won't work. You'll need to do a bit of math.
| int16_t sample16 = (sample8 - 128) << 8;
|
It will change volume a bit, in 16-bits it will be a bit quieter. Max volume with sample8 is 255. In 16-bit's it would be (255-128)<<8 = 32512, but max volume in 16-bit is 32767.
For max volume stay max volume you could go through float:
| int8_t sample8s = sample8 - 128;
int16_t sample16 = sample8s < 0 ? (int16_t)((sample8/128.f) * 32768.f) : (int16_t)((sample8/127.f) * 32767.f);
|
Or figure out something smarter (not sure if this works, have not tested):
| int8_t sample8s = sample8 - 128;
int16_t sample16 = sample8s < 0 ? ((sample8s << 8) & ~0xff) : ((sample8s << 8) | 0xff);
|