CTFRs from a waveform signal
- ctfr.ctfr(signal: ndarray, sr: float, method: str, *, representation_type: str = 'stft', win_lengths: Iterable[int] | None = None, hop_length: int | None = None, n_fft: int | None = None, filter_scales: Iterable[float] | None = None, bins_per_octave: int | None = None, fmin: float | None = None, n_bins: int | None = None, **kwargs: Any) ndarray
Computes a combined time-frequency representation (CTFR) of a waveform signal.
A CTFR represents a signal in the time-frequency domain by computing an average (in a generalized sense) of multiple magnitude-squared time-frequency representations (TFRs) of the signal.
- Parameters:
signal (np.ndarray [shape=(n)], real-valued) – input signal.
sr (float) – sampling rate of the input signal.
method (str) – combination method to use, as specified by their id string. See Combination methods. User-defined methods are also supported if they are properly installed (see Adding methods). A list of all available methods can also be obtained with
ctfr.show_methods()orctfr.get_methods_list().representation_type ({"stft", "cqt"}) – type of time-frequency representation to use, by default “stft”.
win_lengths (Iterable[int], optional) – iterable of window lengths in samples to use for the STFTs. If
representation_typeis “stft” and this parameter is not provided, the default window lengths are[top_length // 4, top_length // 2, top_length], wheretop_lengthis either 100ms in samples, rounded to the nearest power of 2, orn_fft(if provided), whichever is the lowest. Ifrepresentation_typeis “cqt”, this parameter is ignored.hop_length (int > 0, optional) – the hop length in samples to use for the TFRs. If not provided when
representation_typeis “stft”, defaults to half of the smallest window length. If not provided whenrepresentation_typeis “cqt”, defaults to 12.5ms in samples, rounded to the nearest power of 2.n_fft (int > 0, optional) – number of FFT points to use for the STFTs. If not provided when
representation_typeis “stft”, defaults to the largest window length. If bothn_fftandwin_lengthsare provided,n_fftmust be greater than or equal to the largest window length. Ifrepresentation_typeis “cqt”, this parameter is ignored.filter_scales (Iterable[float], values in range: (0, 1], optional) – iterable of filter scales to use for the CQTs. If
representation_typeis “cqt” and this parameter is not provided, the default filter scales are[1/3, 2/3, 1]. Ifrepresentation_typeis “stft”, this parameter is ignored.bins_per_octave (int > 0, optional) – number of bins per octave to use for the CQTs. If
representation_typeis “cqt” and this parameter is not provided, the default number of bins per octave is 36. Ifrepresentation_typeis “stft”, this parameter is ignored.fmin (float > 0, optional) – minimum frequency to use for the CQTs. If
representation_typeis “cqt” and this parameter is not provided, the default minimum frequency is 32.7 Hz. Ifrepresentation_typeis “stft”, this parameter is ignored.n_bins (int > 0, optional) – number of frequency bins to use for the CQTs. If
representation_typeis “cqt” and this parameter is not provided, the default number of bins isbins_per_octave * 8. Ifrepresentation_typeis “stft”, this parameter is ignored.**kwargs – additional keyword arguments to pass to the combination method function. These are specified in their respective pages in Combination methods.
- Returns:
matrix of dimensions
K * Mcontaining a squared-magnitude CTFR of the input signal, whereKis the number of frequency bins andMis the number of time frames.- Return type:
np.ndarray [shape=(K, M)]
- Raises:
InvalidRepresentationTypeError – If the value of provided for
representation_typeis invalid.InvalidCombinationMethodError – If the value provided for
methodis not the id of an installed combination method.ValueError – If
n_fftis less than the largest window length.
See also
- ctfr.methods.mean(signal, sr, **kwargs)
Alias for
ctfr.ctfr(signal, method=mean, sr=sr, **kwargs).
- ctfr.methods.hmean(signal, sr, **kwargs)
Alias for
ctfr.ctfr(signal, method=hmean, sr=sr, **kwargs).
- ctfr.methods.gmean(signal, sr, **kwargs)
Alias for
ctfr.ctfr(signal, method=gmean, sr=sr, **kwargs).
- ctfr.methods.min(signal, sr, **kwargs)
Alias for
ctfr.ctfr(signal, method=min, sr=sr, **kwargs).
- ctfr.methods.swgm(signal, sr, **kwargs)
Alias for
ctfr.ctfr(signal, method=swgm, sr=sr, **kwargs).
- ctfr.methods.lt(signal, sr, **kwargs)
Alias for
ctfr.ctfr(signal, method=lt, sr=sr, **kwargs).
- ctfr.methods.sls_h(signal, sr, **kwargs)
Alias for
ctfr.ctfr(signal, method=sls_h, sr=sr, **kwargs).
- ctfr.methods.sls_i(signal, sr, **kwargs)
Alias for
ctfr.ctfr(signal, method=sls_i, sr=sr, **kwargs).
- ctfr.methods.fls(signal, sr, **kwargs)
Alias for
ctfr.ctfr(signal, method=fls, sr=sr, **kwargs).