maad.sound.linear_to_octave

maad.sound.linear_to_octave(X, fn, thirdOctave=True, display=False, **kwargs)[source]

Transform a linear spectrum (1d) or Spectrogram (2d into octave or 1/3 octave spectrum (1d) or Spectrogram (2d).

Our advice is to work with PSD (amplitude²) for energy conservation.

Parameters:
Xndarray of floats

Linear spectrum (1d) or Spectrogram (2d). Work with PSD to be consistent with energy conservation

fn1d ndarray of floats

Frequency vector of the linear spectrum/spectrogram

thirdOctaveBoolean, default is True

choose between Octave or thirdOctave frequency resolution

displayboolean, default is False

Display the octave spectrum/spectrogram

** kwargsoptional. This parameter is used by plt.plot
Returns:
X_octavendarray of floats

Octave or 1/3 octave Spectrum (1d) or Spectrogram (2d)

bin_octavevector of floats

New frequency vector (octave or 1/3 octave frequency repartition)

Examples

>>> w, fs = maad.sound.load('../data/rock_savanna.wav') 
>>> Sxx_power,tn,fn, ext = maad.sound.spectrogram (w, fs, nperseg=8192)
>>> maad.sound.linear_to_octave(Sxx_power, fn, display=True, extent=ext, vmin=-50)