toolbox/nt/transform/module_stft.py
def _samples_to_stft_frames(
        samples,
        size,
        shift,
        *,
        fading=False,
):
    """
    Calculates STFT frames from samples in time domain.
    :param samples: Number of samples in time domain.
    :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.
    :param fading: See stft. Note to keep old behavior, default value is False.
    :return: Number of STFT frames.

    >>> _samples_to_stft_frames(19, 16, 4)
    2
    >>> _samples_to_stft_frames(20, 16, 4)
    2
    >>> _samples_to_stft_frames(21, 16, 4)
    3

    >>> stft(np.zeros(19), 16, 4, fading=False).shape
    (2, 9)
    >>> stft(np.zeros(20), 16, 4, fading=False).shape
    (2, 9)
    >>> stft(np.zeros(21), 16, 4, fading=False).shape
    (3, 9)

    >>> _samples_to_stft_frames(19, 16, 4, fading=True)
    8
    >>> _samples_to_stft_frames(20, 16, 4, fading=True)
    8
    >>> _samples_to_stft_frames(21, 16, 4, fading=True)
    9

    >>> stft(np.zeros(19), 16, 4).shape
    (8, 9)
    >>> stft(np.zeros(20), 16, 4).shape
    (8, 9)
    >>> stft(np.zeros(21), 16, 4).shape
    (9, 9)

    >>> _samples_to_stft_frames(21, 16, 3, fading=True)
    12
    >>> stft(np.zeros(21), 16, 3).shape
    (12, 9)
    >>> _samples_to_stft_frames(21, 16, 3)
    3
    >>> stft(np.zeros(21), 16, 3, fading=False).shape
    (3, 9)
    """
    if fading:
        samples = samples + 2 * (size - shift)

    # I changed this from np.ceil to math.ceil, to yield an integer result.
    return ceil((samples - size + shift) / shift)

    Calculates STFT frames from samples in time domain.
    :param samples: Number of samples in time domain.
    :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.
    :param fading: See stft. Note to keep old behavior, default value is False.
    :return: Number of STFT frames.

    >>> _samples_to_stft_frames(19, 16, 4)
    2
    >>> _samples_to_stft_frames(20, 16, 4)
    2
    >>> _samples_to_stft_frames(21, 16, 4)
    3

    >>> stft(np.zeros(19), 16, 4, fading=False).shape
    (2, 9)
    >>> stft(np.zeros(20), 16, 4, fading=False).shape
    (2, 9)
    >>> stft(np.zeros(21), 16, 4, fading=False).shape
    (3, 9)

    >>> _samples_to_stft_frames(19, 16, 4, fading=True)
    8
    >>> _samples_to_stft_frames(20, 16, 4, fading=True)
    8
    >>> _samples_to_stft_frames(21, 16, 4, fading=True)
    9

    >>> stft(np.zeros(19), 16, 4).shape
    (8, 9)
    >>> stft(np.zeros(20), 16, 4).shape
    (8, 9)
    >>> stft(np.zeros(21), 16, 4).shape
    (9, 9)

    >>> _samples_to_stft_frames(21, 16, 3, fading=True)
    12
    >>> stft(np.zeros(21), 16, 3).shape
    (12, 9)
    >>> _samples_to_stft_frames(21, 16, 3)
    3
    >>> stft(np.zeros(21), 16, 3, fading=False).shape
    (3, 9)
    
Calculates STFT frames from samples in time domain.
Calculates STFT frames from samples in time domain .
def _samples_to_stft_frames(
        samples,
        size,
        shift,
        *,
        fading=False,
):
    if fading:
        samples = samples + 2 * (size - shift)
    return ceil((samples - size + shift) / shift)
def _samples_to_stft_frames ( samples , size , shift , * , fading = False , ) : if fading : samples = samples + 2 * ( size - shift ) return ceil ( ( samples - size + shift ) / shift )
Calculates STFT frames from samples in time domain.
Calculates STFT frames from samples in time domain .
"""
    Calculates STFT frames from samples in time domain.
    :param samples: Number of samples in time domain.
    :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.
    :param fading: See stft. Note to keep old behavior, default value is False.
    :return: Number of STFT frames.

    >>> _samples_to_stft_frames(19, 16, 4)
    2
    >>> _samples_to_stft_frames(20, 16, 4)
    2
    >>> _samples_to_stft_frames(21, 16, 4)
    3

    >>> stft(np.zeros(19), 16, 4, fading=False).shape
    (2, 9)
    >>> stft(np.zeros(20), 16, 4, fading=False).shape
    (2, 9)
    >>> stft(np.zeros(21), 16, 4, fading=False).shape
    (3, 9)

    >>> _samples_to_stft_frames(19, 16, 4, fading=True)
    8
    >>> _samples_to_stft_frames(20, 16, 4, fading=True)
    8
    >>> _samples_to_stft_frames(21, 16, 4, fading=True)
    9

    >>> stft(np.zeros(19), 16, 4).shape
    (8, 9)
    >>> stft(np.zeros(20), 16, 4).shape
    (8, 9)
    >>> stft(np.zeros(21), 16, 4).shape
    (9, 9)

    >>> _samples_to_stft_frames(21, 16, 3, fading=True)
    12
    >>> stft(np.zeros(21), 16, 3).shape
    (12, 9)
    >>> _samples_to_stft_frames(21, 16, 3)
    3
    >>> stft(np.zeros(21), 16, 3, fading=False).shape
    (3, 9)
    """ # I changed this from np.ceil to math.ceil, to yield an integer result.
Number of STFT frames.








Number of STFT frames .
samples
Number of samples in time domain.
Number of samples in time domain .
size
window_length often equal to FFT size.
The name size should be marked as deprecated and replaced with
window_length.
window_length often equal to FFT size . The name size should be marked as deprecated and replaced with window_length .
shift
Hop in samples.
Hop in samples .
fading
See stft. Note to keep old behavior, default value is False.
See stft . Note to keep old behavior default value is False .