def optimal_noverlap(win_name,win_len):
    """
    This function is intended to support scipy.signal.stft calls with noverlap parameter.
    :param win_name: (str) name of the window (has to follow scipy.signal.windows naming)
    :param win_len: (int) lenght of the FFT window
    :return : (int) optimal overlap in points for the given window type
    """

    window_to_overlap_coef = {'hann': 0.5,
                              'hamming': 0.75,
                              'blackmanharris': 0.75,
                              'blackman': 2/3,
                              'flattop': 0.75,
                              'boxcar': 0}
    try:
        noverlap = int(win_len*window_to_overlap_coef[win_name])
    except KeyError as exc:
        print(exc)
        print('The window you have selected is not recognized or does not have optimal overlap. Setting window overlap to default 75%.')
        noverlap = int(win_len*0.75)

    return noverlap