docs: def valid_beat_duration(duration):
      """Return True when log2(duration) is an integer."""
      if duration == 0:
          return False
      elif duration == 1:
          return True
      else:
          r = duration
          while r != 1:
              if r % 2 == 1:
                  return False
              r /= 2
          return True