def deltaify_traces(traces, final_byte_duration=9999):
  """Convert absolute start times in traces to durations.

  Traces returned by `read_traces_csv` pair bytes with start times. This
  function computes how long each byte remains on the bus and replaces the
  start time with this value in its output. Note that the final duration can't
  be calculated and will be given the duration `final_byte_duration`.

  Args:
    traces: Traces to "deltaify" as described.
    final_byte_duration: Duration to assign to the final byte.

  Returns:
    "Deltaified" traces as described.
  """
  deltaified_traces = []
  for i in range(len(traces) - 1):
    dt = traces[i+1][0] - traces[i][0]
    deltaified_traces.append((dt, traces[i][1]))
  deltaified_traces.append((final_byte_duration, traces[-1][1]))
  return deltaified_traces