New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add precomputations to HAAQI #363
Comments
Yes. This is all true. The solution is probably to make an OOP version of these metrics. If you look at the MSBG code you will see that there is an Ear class which has a Cochlea object. A set_audiogram method will build a new Cochlea for the Ear. This allows all the precomputation to be done in the object constructors so that the Ear's process() method doesn't repeat the parts that are signal independent. It would be great if the Kates' models were all rewritten in this style. Note, also that the MSBG code has its own implementation of a gammatone filterbank. See gammatome_filterbank in cochlea.py. This looks like the cascaded filter implementation. Here it is just a loop of lfilter commands, so no use of any njit code. This would probably be much faster if we could show that it gave similar results. But I haven't benchmarked it. |
I checked the periodicity and found that some are not "perfect" I mean, you can find the period (no more than 300 samples) However, the values for some bands are the same in each period with variation in the 15th decimal place but, for other bands, the variations are in the 3rd or 4th decimal place. repeating the first period resulted in a reduction of 0.02 HAAQI in the example I was running from 0.12 to 0.10. Regarding refactoring HAAQI, there are many computations that can be done in the constructor and others that could be saved:
|
HAAQI's Ear model is hard to separate as the MSGB does. clarity/clarity/evaluator/haspi/eb.py Lines 240 to 248 in 6b98a25
In this part of the Ear model, the As we can't really make the ear model independent of the signals we could have the following structure. EarModel Class:
To me, it is not an ideal structure but I can't think in another right now. @jonbarker68, any suggestions? |
There are two banches working with HAAQI to improve the metric. However, after several analysis, I realised that many of the slowest parts can be improved by precomputing values. These values correspond computations that are not related to the signals. Additionally, as HAAQI works at 24000 Hz, many of the computations that depend on the sample rate can also be precomputed:
Filter coefficients in
eb.env_compress_basilar_membrane
:Depends on a constant (flp = 800) and sample rate
Filter coefficients in
eb.middle_ear
Depends on sample rate
Group delay vector in
eb.group_delay_compensate
These are constant
Sin
andCos
ineb.gammatone_bandwidth_demodulation
This is a recursive function (every 300 samples) that depends on the length of the audio signal (i.e., 24000 samples per second of audio) and the sample rate. However, considering values to the 10th decimal place, the function is periodic.
The text was updated successfully, but these errors were encountered: