CSNG (File Format): Difference between revisions
Jump to navigation
Jump to search
→Continuous Pitch / Modulation Data
imported>Jackoalan No edit summary |
imported>Jackoalan |
||
Line 250: | Line 250: | ||
<syntaxhighlight lang="python" line="1"> | <syntaxhighlight lang="python" line="1"> | ||
def DecodeRLE(in): | def DecodeRLE(in): | ||
# high-bit shift-trigger RLE, limited to 2 bytes | |||
term = in.ReadU8() | term = in.ReadU8() | ||
total = term & 0x7f | total = term & 0x7f | ||
Line 256: | Line 257: | ||
return total | return total | ||
def DecodeContinuousRLE(in): | def DecodeContinuousRLE(in, isValue): | ||
total = 0 | total = 0 | ||
while True: | while True: | ||
# 1-2 byte RLE accumulated within continuable RLE | |||
term = DecodeRLE(in) | term = DecodeRLE(in) | ||
if term == 0x8000: | if term == 0x8000: | ||
Line 266: | Line 268: | ||
total += term | total += term | ||
if total >= 0x4000: | # values are signed deltas; | ||
# extending into the high-half of 15-bit precision | |||
if isValue: | |||
if total >= 0x4000: | |||
return total - 0xffff | |||
else: | |||
return total | |||
# times are always forward-deltas | |||
return total | |||
</syntaxhighlight> | </syntaxhighlight> | ||