def get_gt_orderlist_length(orderlist):
    """
    Calculates the length of the orderlist in the GoatTracker .sng file.
    A simple pattern with no transposition played once requires 1 entry
    If there is a transposition change, that adds another entry
    Multiple repeats add one entry unless there are more than 16, in which case
    2 bytes are added per 16 repeats; one for the repeat number and another for the
    pattern number (none is needed for transposition and it cannot change for repeats).
    :param orderlist: An orderlist from a voice
    :type orderlist: rchirp.RChirpOrderlist
    :return: Number of entries required for the GoatTracker orderlist
    :rtype: int
    """
    retval = 2  # Start and end commands
    prev_transposition = 0
    for entry in orderlist:
        if entry.transposition != prev_transposition:
            retval += 1
            prev_transposition = entry.transposition
        if entry.repeats > 16:
            retval += (2 * (entry.repeats // 16))  # 2 bytes for each repeat
        if entry.repeats % 16 != 0:
            retval += 1
            if entry.repeats % 16 != 1:
                retval += 1
    return retval