pya.astft

Module Contents

Classes

Astft

Audio spectrogram (STFT) class, attributes refers to scipy.signal.stft. With an addition

Attributes

_LOGGER

pya.astft._LOGGER
class pya.astft.Astft(x: pya.asig.Asig | numpy.ndarray, sr: int | None = None, label: str = 'STFT', window: str = 'hann', nperseg: int = 256, noverlap: int | None = None, nfft: int | None = None, detrend: bool = False, return_onesided: bool = True, boundary: str = 'zeros', padded: bool = True, cn: list | None = None)

Audio spectrogram (STFT) class, attributes refers to scipy.signal.stft. With an addition attribute cn being the list of channel names, and label being the name of the Asig

to_sig(**kwargs)

Create signal from stft, i.e. perform istft, kwargs overwrite Astft values for istft

Parameters:

**kwargs (str) –

optional keyboard arguments used in istft:

’sr’, ‘window’, ‘nperseg’, ‘noverlap’, ‘nfft’, ‘input_onesided’, ‘boundary’.

also convert ‘sr’ to ‘fs’ since scipy uses ‘fs’ as sampling frequency.

Returns:

_ – Asig

Return type:

Asig

plot(fn=lambda x: ..., ax=None, offset=0, scale=1.0, xlim=None, ylim=None, show_bar=True, **kwargs)

Plot spectrogram

Parameters:
  • fn (func) – a function, by default is bypass

  • ch (int or str or None) – By default it is None,

  • ax (matplotlib.axes) – you can assign your plot to specific axes (Default value = None)

  • xlim (tuple or list) – x_axis range (Default value = None)

  • ylim (tuple or list) – y_axis range (Default value = None)

  • **kwargs – keyward arguments of matplotlib’s pcolormesh

Returns:

_ – self

Return type:

Asig

__repr__()

Return repr(self).