roughness_dw_freq#

roughness_dw_freq(spectrum, freqs)[source]#

Computes the roughness according to Daniel and Weber method from a fine band spectrum

This function computes the global and specific roughness values of a signal sampled at 48 kHz.

Parameters:
  • spectrum (array_like) – Input amplitude or complex frequency spectrum, dim (nperseg x nseg)

  • freqs (array) – Input frequency axis , dim (nperseg) if identical for all the blocks, else (nperseg x nseg).

Returns:

  • R (numpy.array) – Roughness value in [asper], dim (nseg).

  • R_spec (numpy.array) – Specific roughness over bark axis, dim (47 bark x nseg).

  • bark_axis (numpy.array) – Frequency axis in [bark], dim (nseg).

Warning

The input spectrum must be an amplitude spectrum (use abs() on complex spectrum).

See also

roughness_dw

roughness computation from a time signal

Notes

The model consists of a parallel processing structure made up of successive stages to calculate intermediate specific roughnesses \(R'\), which are summed up to determine the total roughness \(R\):

\[R=0.25\sum_{i=1}^{47}R'_{i}\]

References

[1]

P. Daniel and R. Weber. Psychoacoustical roughness: implementation of an optimized model. Acta Acustica, Vol. 83: 113-123, 1997. URL: https://www.ingentaconnect.com/contentone/dav/aaua/1997/00000083/00000001/art00020.

Examples

>>> from mosqito.sq_metrics import roughness_dw_freq
>>> from mosqito.sound_level_meter import comp_spectrum
>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> fc=1000
>>> fmod=70
>>> fs=44100
>>> d=0.2
>>> dB=60
>>> time = np.arange(0, d, 1/fs)
>>> stimulus = (
>>> 0.5
>>> * (1 + np.sin(2 * np.pi * fmod * time))
>>> * np.sin(2 * np.pi * fc * time))
>>> rms = np.sqrt(np.mean(np.power(stimulus, 2)))
>>> ampl = 0.00002 * np.power(10, dB / 20) / rms
>>> stimulus = stimulus * ampl
>>> n = len(stimulus)
>>> spec, freqs = comp_spectrum(stimulus, fs, db=False)
>>> R, R_specific, bark = roughness_dw_freq(spec, freqs)
>>> plt.plot(bark, R_specific)
>>> plt.xlabel("Bark axis [Bark]")
>>> plt.ylabel("Specific roughness, [Asper/Bark]")
>>> plt.title("Roughness = " + f"{R:.2f}" + " [Asper]")

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

../../_images/mosqito-sq_metrics-roughness-roughness_dw-roughness_dw_freq-1.png