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() or ctfr.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_type is “stft” and this parameter is not provided, the default window lengths are [top_length // 4, top_length // 2, top_length], where top_length is either 100ms in samples, rounded to the nearest power of 2, or n_fft (if provided), whichever is the lowest. If representation_type is “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_type is “stft”, defaults to half of the smallest window length. If not provided when representation_type is “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_type is “stft”, defaults to the largest window length. If both n_fft and win_lengths are provided, n_fft must be greater than or equal to the largest window length. If representation_type is “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_type is “cqt” and this parameter is not provided, the default filter scales are [1/3, 2/3, 1]. If representation_type is “stft”, this parameter is ignored.

  • bins_per_octave (int > 0, optional) – number of bins per octave to use for the CQTs. If representation_type is “cqt” and this parameter is not provided, the default number of bins per octave is 36. If representation_type is “stft”, this parameter is ignored.

  • fmin (float > 0, optional) – minimum frequency to use for the CQTs. If representation_type is “cqt” and this parameter is not provided, the default minimum frequency is 32.7 Hz. If representation_type is “stft”, this parameter is ignored.

  • n_bins (int > 0, optional) – number of frequency bins to use for the CQTs. If representation_type is “cqt” and this parameter is not provided, the default number of bins is bins_per_octave * 8. If representation_type is “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 * M containing a squared-magnitude CTFR of the input signal, where K is the number of frequency bins and M is the number of time frames.

Return type:

np.ndarray [shape=(K, M)]

Raises:
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).