def _stft_frames_to_samples(
        frames, size, shift, fading=None
):
    """
    Calculates samples in time domain from STFT frames
    :param frames: Number of STFT frames.
    :param size: window_length often equal to FFT size.
                 The name size should be marked as deprecated and replaced with
                 window_length.
    :param shift: Hop in samples.
    :return: Number of samples in time domain.

    >>> _stft_frames_to_samples(2, 16, 4)
    20
    """
    samples = frames * shift + size - shift

    assert fading in [None, True, False, 'full', 'half'], fading
    if fading not in [None, False]:
        pad_width = (size - shift)
        samples -= (1 + (fading != 'half')) * pad_width
    return samples