TonalityECMA418_2#

class ansys.sound.core.psychoacoustics.TonalityECMA418_2(signal=None, field_type=None, edition=None)#

Computes ECMA-418-2 tonality.

This class is used to compute the tonality according to the ECMA-418-2 standard (Sottek Hearing Model), formerly known as ECMA-74, annex G.

Note

The releases of DPF Sound 2026 R1 and PyAnsys Sound 0.2 introduce the 3rd edition of ECMA-418-2, in addition to the 1st edition implemented in previous versions. Theoretically, the 1st and 3rd editions of ECMA-418-2 are supposed to describe the same algorithm of psychoacoustic tonality calculation. However, the standard does not include any real verification data and its 1st edition noticeably included errors and unclear computation details open to interpretation. The 3rd edition was largely improved in that regard, and now allow producing consistent results throughout distinct implementations of the standard. As a consequence, this 3rd edition is strongly recommended in most cases, while the 1st edition should only be used when backward compatibility is required.

Note

Prior to release 0.2 of PyAnsys Sound, only the 1st edition of ECMA-418-2 was proposed. Similarly, the calculation was only available in free field. Release 0.2 includes the possibility to use the 3rd edition of ECMA-418-2, and perform the calculation in diffuse field (with either edition), using the two new attributes edition and field_type. This means that older code using this class needs be updated with values assigned to these two attributes. This can be done either when instantiating the class:my_tonality = TonalityECMA418_2(my_signal, my_field_type, my_edition), or later, by setting the attributes: my_tonality.field_type = my_field_type and my_tonality.edition = my_edition.

Class instantiation takes the following parameters.

Parameters:
signal: Field, default: None

Signal in Pa on which to calculate the tonality.

field_type: str, default: None

Sound field type. Available options are “Free” and “Diffuse”.

edition: str, default: None

Edition of the ECMA-418-2 standard to use. Available options are “1st” and “3rd”, which correspond to the 2020 and 2024 versions of the ECMA-418-2 standard, respectively.

Methods

TonalityECMA418_2.convert_fields_container_to_np_array(fc)

Convert a DPF fields container to a NumPy array.

TonalityECMA418_2.get_output()

Get the ECMA-418-2 tonality data, in a tuple containing data of various types.

TonalityECMA418_2.get_output_as_nparray()

Get the ECMA-418-2 tonality data, in a tuple of NumPy arrays.

TonalityECMA418_2.get_tonality()

Get the ECMA-418-2 tonality, in tuHMS.

TonalityECMA418_2.get_tonality_over_time()

Get the ECMA-418-2 tonality over time, in tuHMS.

TonalityECMA418_2.get_tonality_time_scale()

Get the ECMA-418-2 tonality time scale, in s.

TonalityECMA418_2.get_tone_frequency_over_time()

Get the ECMA-418-2 tone frequency over time, in Hz.

TonalityECMA418_2.get_tone_frequency_time_scale()

Get the ECMA-418-2 tone frequency time scale, in s.

TonalityECMA418_2.plot()

Plot the ECMA-418-2's tonality and tone frequency over time.

TonalityECMA418_2.process()

Compute the ECMA-418-2 tonality.

Attributes

TonalityECMA418_2.edition

Edition of the ECMA-418-2 standard to use.

TonalityECMA418_2.field_type

Sound field type.

TonalityECMA418_2.signal

Input signal in Pa.