ggrecow / SQAT

SQAT is an open-source repository of MATLAB codes containing the implementation of key metrics for quantitative sound quality analysis.
Other
46 stars 14 forks source link

Problematic tone width calculation in Aures's tonality #4

Closed pallabs-emerychen closed 11 months ago

pallabs-emerychen commented 11 months ago

Hello,

I've been integrating Aures's tonality algorithm into my program and came across some issues in the current script.

  1. Upper Index Calculation in Tone Finding Algorithm: I noticed that the algorithm for determining a tone's upper index does not match the exact number. When running the example script, the tone index (idx) calculates as 161, but idxrng2 turns out to be 164, which seems to be one step higher. The correct value for idxrng2 should be 163, considering SPL(idx:idx+3) = [60.000, 53.981, -26.509, -35.030] and hafmax=42.420. A potential fix could be modifying SPL(idx:numel(Freq) to SPL(idx+1:numel(Freq) in the find function for the lower bound, changing it to SPL(1:idx-1).

  2. Interpolation Procedure for flow and fhigh: The current method for determining flow and fhigh seems to have an issue. For instance, the derived value flow=1003.6 is incorrect because flow should be lower than the center frequency, which is 1000 in this case. The issue might stem from the SPL array not being sorted, leading to inaccurate results from interp1. A simple solution might be to use two samples for linear interpolation: [idxrng1, idxrng1+1] for flow and [idxrng2-1, idxrng2] for fhigh.

ggrecow commented 11 months ago

Hi,

Many thanks for your detailed report. This part of the code was very challenging to implement because the original paper from Aures' never says anything about how the tones' bandwidth shall be computed. Therefore, I really appreciate the feedback and would be very open to try another approaches if you have any clever ideas. Now, specifically concerning your points:

  1. Indeed the value provided by idxrng2 was not correct. As you mentioned, this was due to the incorrect usage of the index on the find function. I have correct it using your approach and now it seems to work fine.

  2. Very good catch. The use of 6!!! samples around idxrng1 (as in SPL(idxrng1+(-3:3)), for example) was completelly unnecessary. I have corrected the code based on your suggestion and it works fine now.

As the bandwidth have a pretty relevant influence on the tonality calculation, these two small modifications lead to a slightly smaller tonality value in comparison to the original code. To correct for that, I had to increase the value of the calibration constant in Line 335 from C=1.11 to C=1.125

I have tested the Aures' tonality code with these modifications using the codes from the example and validations folders and have verified only a small (almost insignificant) change on the results. Nevertheless, I have not tested using more complex signals.

All the best,

Gil.