ToneToNoiseRatio#

class ansys.sound.core.psychoacoustics.ToneToNoiseRatio(psd=None, frequency_list=None)#

Computes the ECMA 418-1/ISO 7779 tone-to-noise ratio (TNR).

This class computes the TNR from a power spectral density (PSD), according to the ECMA 418-1 and ISO 7779 standards.

Examples

Compute and display the tone-to-noise ratio of all identified peaks in a given power spectral density.

>>> from ansys.sound.core.psychoacoustics import ToneToNoiseRatio
>>> tone_to_noise_ratio = ToneToNoiseRatio(psd=my_psd)
>>> tone_to_noise_ratio.process()
>>> tnr_values = tone_to_noise_ratio.get_TNR_values()
>>> frequencies = tone_to_noise_ratio.get_peaks_frequencies()
>>> max_tnr = tone_to_noise_ratio.get_max_TNR_value()
>>> tone_to_noise_ratio.plot()

Compute the tone-to-noise ratio at specific frequencies.

>>> from ansys.sound.core.psychoacoustics import ToneToNoiseRatio
>>> tone_to_noise_ratio = ToneToNoiseRatio(psd=my_psd, frequency_list=[500, 1000, 2000])
>>> tone_to_noise_ratio.process()
>>> tnr_values = tone_to_noise_ratio.get_TNR_values()

See also

Calculate TNR and PR

Example demonstrating how to compute tone-to-noise ratio and prominence ratio.

Class instantiation takes the following parameters.

Parameters:
psdField

PSD of the signal on which to compute TNR. The PSD field has the following characteristics:

  • num_entities = 1

  • location = “TimeFreq_sets”

  • data: Vector of amplitude values in unit^2/Hz

  • time_freq_support: Vector of regularly spaced frequencies in Hz associated with amplitude values (from 0 Hz to the maximum frequency)

  • unit = “<unit>^2/Hz” (where <unit> is Pa for example).

You can use the function create_scalar_field() to create the field.

frequency_listlist, default: None

List of the frequencies in Hz of the tones (peaks in the spectrum) for which to calculate the TNR. The default is None, in which case a peak detection method is applied to automatically find the tones in the input spectrum. Then, the TNR is calculated for each detected tone.

Methods

ToneToNoiseRatio.get_TNR_values()

Get the vector of the peaks' TNR values in dB.

ToneToNoiseRatio.get_max_TNR_value()

Get the maximum TNR value in dB.

ToneToNoiseRatio.get_nb_tones()

Get the number of tones.

ToneToNoiseRatio.get_output()

Get TNR data as a generic data container.

ToneToNoiseRatio.get_output_as_nparray()

Get TNR data in a tuple as a NumPy array.

ToneToNoiseRatio.get_peaks_frequencies()

Get the vector of the peaks' frequencies in Hz.

ToneToNoiseRatio.get_peaks_high_frequencies()

Get the vector of the peaks' higher-frequency limits in Hz.

ToneToNoiseRatio.get_peaks_levels()

Get the vector of the peaks' level values in dB SPL.

ToneToNoiseRatio.get_peaks_low_frequencies()

Get the vector of the peaks' lower-frequency limits in Hz.

ToneToNoiseRatio.get_reference_curve()

Get the reference threshold curve, above which a tone is considered as prominent.

ToneToNoiseRatio.get_single_tone_info(tone_index)

Get the TNR information for a tone.

ToneToNoiseRatio.plot()

Plot the TNR for all identified peaks, along with the threshold curve.

ToneToNoiseRatio.process()

Compute the TNR.

Attributes

ToneToNoiseRatio.frequency_list

Tone frequency list in Hz.

ToneToNoiseRatio.psd

Input power spectral density (PSD).