Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stream_sample_t rolandpcm_device::decode_sample(int8_t data)
- {
- int16_t val;
- int16_t sign;
- uint8_t shift;
- stream_sample_t result;
- if (data < 0)
- {
- sign = -1;
- val = -data;
- }
- else
- {
- sign = +1;
- val = data;
- }
- // thanks to Sarayan for figuring out the decoding formula
- shift = val >> 4;
- val &= 0x0F;
- if (! shift)
- result = val;
- else
- result = (0x10 + val) << (shift - 1);
- return result * sign;
- }
Add Comment
Please, Sign In to add comment