CSNG (File Format): Difference between revisions
Jump to navigation
Jump to search
Clarify nature of delta time encoding
imported>Jackoalan |
imported>Jackoalan (Clarify nature of delta time encoding) |
||
Line 150: | Line 150: | ||
Just like MIDI, each command starts with a '''delta time''' value telling the sequencer | Just like MIDI, each command starts with a '''delta time''' value telling the sequencer | ||
how many ticks to wait after the previous command. Unlike MIDI, Factor5 uses a | how many ticks to wait after the previous command. Unlike MIDI, Factor5 uses a fixed 16-bit | ||
value to store the delta times. In case of a delta time greater than 65535, no-op commands | |||
with a 65535 delta time are inserted into the command stream until the target time is attained. | |||
In a theoretical Python streaming API, the delta time can be decoded with no-ops automatically consumed like so: | |||
<syntaxhighlight lang="python" line="1"> | <syntaxhighlight lang="python" line="1"> | ||
def | def DecodeDeltaTime(streamIn): | ||
total = 0 | total = 0 | ||
while True: | while True: | ||
term = streamIn.ReadU16() | term = streamIn.ReadU16() | ||
if | next = streamIn.PeekU16() | ||
if next == 0: | |||
total += 0xffff | total += 0xffff | ||
streamIn.seekAhead(2) | |||
continue | continue | ||
total += term | total += term |