Repository navigation
Conversation
…atio New module with the prominent discrete tone procedures of ECMA-418-1:2024 (also in ECMA-74, Annex D), written in the mean-square form of Annexes A and B. tone_to_noise_ratio and prominence_ratio take a one-channel SignalObj and an optional tone frequency. Without a frequency, the spectrum between 89.1 Hz and 11 200 Hz is searched for tone candidates. Each result gives the frequency, the ratio in dB, the criterion in dB and whether the criterion is met. The spectrum is a Welch average with a Hann window, with line spacing below 0.25 % of the tone frequency for TNR and 1 % for PR (Clause 7). Covered: critical band and its edges (Clause 10), tone band between minima within 15 % of the critical band and tone power above the line joining them (A.2), masking noise (A.3), primary and secondary tones with the proximity spacing (A.6), lower and upper band edges from Tables 2 and 3, the 100 Hz referral of the truncated lower band, and the criteria of 11.5 and 12.6. Tests check the standard's examples for bandwidth, band edges and proximity spacing, the criterion formulae, analytic TNR and PR of tones in white noise, two tones in one critical band, the spectrum search on noise, and invalid input. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
pytta.ecma418with the two methods of ECMA-418-1:2024 for prominent discrete tones, the same methods as in ECMA-74 Annex D:tone_to_noise_ratio(signal, tone_frequency=None, resolution=None): tone-to-noise ratio (TNR), Clause 11 and Annex A.prominence_ratio(signal, tone_frequency=None, resolution=None): prominence ratio (PR), Clause 12 and Annex B.critical_band(frequency): the edges of the critical band, Clause 10, used by both.With a tone frequency, each method returns a dict with the frequency, the ratio in dB, the criterion in dB and whether the tone is prominent (11.5 and 12.6). Without one, it searches the spectrum and returns one such dict per candidate. The spectrum is a Welch average with a Hann window, with a line spacing below 0.25 % of the tone frequency for TNR and below 1 % for PR (Clause 7). The implementation covers the bandwidth of Formula (2), the tone band of A.1, the masking noise of A.2, the primary and secondary tones within the proximity spacing of Formula (14), and the outer bands of Tables 2 and 3, with the lower band referred to 100 Hz below 171.4 Hz (B.8).
The standard leaves the identification of tones to the operator (8.2 c). In the search mode, a line is a candidate when it is the highest within 15 % of its critical band and at least 10 dB above the median of that band. The audibility checks of 11.8 and 12.8 are left out, since they need a calibrated level and a listener.
Regarding the text of the standard, four points are worth checking in review:
The tests in
tests/test_ecma418.pyprint the measured differences:No external implementation was found to compare with: SQAT and the ITA-Toolbox have no TNR or PR.
Checked with Python 3.12, numpy 1.26 and scipy 1.17. The 7 failures of
development(3 intest_h5io.py, 4 intest_pyttasave.py) are the same with and without this change.Co-Authored-By: Claude Fable 5.1 noreply@anthropic.com