def _wpad(l, windowsize, stepsize):
    """
    Parameters
        l - The length of the input array
        windowsize - the size of each window of samples
        stepsize - the number of samples to move the window each step

    Returns
        The length the input array should be so that no samples are leftover
    """
    if l <= windowsize:
        return windowsize

    nsteps = ((l // stepsize) * stepsize)
    overlap = (windowsize - stepsize)
    if overlap:
        return nsteps + overlap

    diff = (l - nsteps)
    left = max(0, windowsize - diff)
    return l + left if diff else l