noct_synthesis#

noct_synthesis(spectrum, freqs, fmin, fmax, n=3, G=10, fr=1000)[source]#

Adapt input spectrum to nth-octave band spectrum

This function the input spectrum to n-th octave band levels.

Parameters:
  • spectrum (array_like) – RMS amplitude one-sided spectrum, size (nperseg, nseg).

  • freqs (list) – List of input frequency , size (nperseg) or (nperseg, nseg).

  • fmin (float) – Minimum frequency band [Hz].

  • fmax (float) – Maximum frequency band [Hz].

  • n (int) – Number of bands per octave.

  • G (int) – System for specifying the exact geometric mean frequencies. Can be base 2 or base 10.

  • fr (int) – Reference frequency. Shall be set to 1 kHz for audible frequency range, to 1 Hz for infrasonic range (f < 20 Hz) and to 1 MHz for ultrasonic range (f > 31.5 kHz).

Returns:

  • spec (numpy.ndarray) – nth-octave octave band spectrum of signal sig [dB re.2e-5 Pa], size (nbands, nseg).

  • fpref (numpy.ndarray) – Corresponding preferred nth-octave octave band center frequencies, size (nbands).

See also

comp_spectrum

Spectrum computation from a time signal

noct_spectrum

N-th octave band spectrum computation from a time signal

Examples

>>> from mosqito.sound_level_meter import comp_spectrum, noct_synthesis
>>> from mosqito.utils import amp2db
>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> f=1000
>>> fs=48000
>>> d=0.2
>>> dB=60
>>> time = np.arange(0, d, 1/fs)
>>> stimulus = np.sin(2 * np.pi * f * time) + 0.5 * np.sin(6 * np.pi * f * time)
>>> rms = np.sqrt(np.mean(np.power(stimulus, 2)))
>>> ampl = 0.00002 * np.power(10, dB / 20) / rms
>>> stimulus = stimulus * ampl
>>> spec, freqs = comp_spectrum(stimulus, fs, db=False)
>>> spec_3, freq_axis = noct_synthesis(spec, freqs, fmin=90, fmax=14000)
>>> spec_3db = amp2db(spec_3, ref=2e-5)
>>> plt.step(freq_axis, spec_3db)
>>> plt.xlabel("Center frequency [Hz]")
>>> plt.ylabel("Amplitude [dB]")

(Source code, png, hires.png, pdf)

../../_images/mosqito-sound_level_meter-noct_spectrum-noct_synthesis-1.png