def make_mask(marks, wave_length, mask_range=16):
    """
    Make mask based on mask range & marks.
    :param marks:
        a numpy array containing index(time * sampling rate) of marks.
    :param wave_length:
        wav file length.
    :param mask_range:
        a range around marks index should be masked.
    :return:
        a list of mask tuples, like:
        [
        (1, 99),
        (105, 118),
        ...,
        (177, 192),
        ]
    """
    tuples = list()
    # create mask tuples
    for index in marks:
        if index == wave_length:
            break
        begin = index - mask_range
        begin = begin if begin >= 0 else 0
        end = index + mask_range
        end = end if end < wave_length else wave_length - 1
        tuples.append((begin, end))
    # merge adjacent mask tuples
    mask = list()
    i = 0
    while i < len(tuples):
        begin = tuples[i][0]
        end = tuples[i][1]
        j = i+1
        while j < len(tuples):
            if tuples[j][0] <= end:
                end = tuples[j][1]
                j += 1
            else:
                break
        mask.append((begin, end))
        i = j
    return mask