Eomys / MoSQITo

MoSQITo is a unified and modular development framework of key sound quality metrics favoring reproducible science and efficient shared scripting among engineers, teachers and researchers community.
Apache License 2.0
134 stars 44 forks source link

Zwicker's loudness calculation raises ValueError #70

Closed vyhyb closed 11 months ago

vyhyb commented 11 months ago

Hello, first of all, thanks for this great library. I am not experienced in the method implemented in loudness_zwtv, but I'd like to make it part of my listening test calibration. I should note that I am working with the version 1.0.8 of your library on Python 3.9.

The error trace ends with:

File ~/Dokumenty/Programming/venv/lib64/python3.9/site-packages/mosqito/sq_metrics/loudness/loudness_zwst/_main_loudness.py:229, in _main_loudness(spec_third, field_type)
    224 #
    225 # Correction of specific loudness in the lowest critical band
    226 # taking into account the dependance of absolute threshold
    227 # within this critical band
    228 korry = 0.4 + 0.32 * nm[0] ** 0.2
--> 229 nm[0, korry <= 1] *= korry
    230 # nm[:, -1] = 0
    231 # if spec_third.ndim == 1 or spec_third.shape[1] == 1:
    232 #     # This is only for test_loudness_zwicker_3oct because only one array of one col is given and this routine needs 2 or more
    233 #     # This line is only also for testing test_loudness_zwicker_wav(), only in case one col in spec third is given.
    234 #     nm = nm[:, 1]
    236 return np.squeeze(nm)

ValueError: operands could not be broadcast together with shapes (4402,) (4501,) (4402,) 

I tried to look into the code and I think the problem is that in your code, you have

nm[0, korry <= 1] *= korry

instead of

nm[0, korry <= 1] *= korry[korry <=1]

May that be the problem? Thanks in advance for any response/guidance.

wantysal commented 11 months ago

Hi,

Thanks for raising this issue ! It seems that no test signal belonged to the case where (korry>1).any() is True. Your suggestion is correct, it has been included into PR#71.

wantysal commented 11 months ago

New release including the correction : mosqito 1.1.0 available on pip