So previously I asked about how to
Capturing & Blocking Close Caption. Now on the other hand I have come to where I would like to send out a close caption message. However the shifting of bits confuses me and I have never been good at binary. Perhaps someone could give a hand here and explain exactly how I would send a new message out?
psychonic was kind enough last time to show me how to block and read the close caption data. The usermessage breaks down in to the following:
Quote:
Originally Posted by psychonic
Neither. Int, 15-bit uint, 1-bit bool
Easiest way would probably be to read the last two together as a short, copy the least significant bit out as the last var and then shift the rest to the right. Multiply the duration by 10 to convert it to seconds.
Code:
new id = BfReadNum(bf);
new temp = BfReadShort(bf);
new bool:from_player = (temp & 1);
new signed = (temp >> 1) & 0x7FFF;
new unsigned = (signed < 0) ? signed + 0x10000 : signed;
new Float:duration = float(unsigned);
|
If I were to turn that around and send a message out with it, how would I exactly do that?
Code:
new id = 1327396910
new bool:from_player = false
new Float:duration = 15.0
new unsigned = RoundFloat(duration)
new signed = ?