Skip to content

Commit 696520e

Browse files
authored
Merge pull request #15 from mglesser/master
Test architecture rework + update of doc + small bug fixes
2 parents 92a5d53 + 6100568 commit 696520e

File tree

212 files changed

+207
-158
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

212 files changed

+207
-158
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
__pycache__/
22
.pytest_cache/
33
.vscode/
4-
.ipynb_checkpoints/
4+
.ipynb_checkpoints/
5+
tests/output

documentation/architecture.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ For the users that would like to use MOSQITO independently, a scripting interfac
1717
Each function in the function library shall come with:
1818
- a documentation presenting the sources used for the implementation and showing how the implementation is validated (in the [documentation folder](.))
1919
- a tutorial (in the [tutorial folder](../tutorials))
20-
- a unit test (in the [tests folder](../mosqito/tests))
20+
- a unit test (in the [tests folder](../tests))
2121

2222
The scripting interface, relies upon an object oriented approach. All operations on audio signals are managed through the Audio class and its methods.

documentation/loudness-stationary.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,33 @@ In MOSQITO, the code is based on the BASIC program published in Zwicker and Fast
1010
### Validation of the implementation
1111
The ISO 532-1:2017 standard provides a set of synthetic and technical signals covering representative applications to be used to validate any of its implementation. The standards also provides the compliance requirements.
1212

13-
The test signal n°1 (annex B2 of the standard) provides third octave levels to be used as input for stationary loudness calculation. A step by step description of how to use MOSQITO to calculate the loudness and the specific loudness from this input is given in [tutorial n°1](../tutorials/tuto1_Loudness-zwicker-from-3oct.ipynb).
13+
The test signal n°1 (annex B2 of the standard) provides third octave levels to be used as input for stationary loudness calculation.
1414

15-
The test signals n°2 to 5 (annex B3 of the standard) provides .wav files to be used as input for stationary loudness calculation. A step by step description of how to use MOSQITO to calculate the loudness and the specific loudness from signal n°3 is given in [tutorial n°2](../tutorials/tuto2_Loudness-zwicker-from-wav.ipynb).
15+
The test signals n°2 to 5 (annex B3 of the standard) provides .wav files to be used as input for stationary loudness calculation. A step by step description of how to use MOSQITO to calculate the loudness and the specific loudness from signal n°3 is given in [this tutorial](../tutorials/tuto_loudness.ipynb).
1616

1717
The plots below compares the MOSQITO loudness calculations for all the tests signals to the compliance requirements of the standards.
1818

19-
![](../mosqito/validations/loudness_zwicker/output/validation_loudness_zwicker_stationary_Test_signal_1.png)
19+
![](../validations/loudness_zwicker/output/validation_loudness_zwicker_stationary_Test_signal_1.png)
2020

2121
*Loudness calculation for ISO 532-1 test signal n°1 (machinery noise in free field)*
2222

23-
![](../mosqito/validations/loudness_zwicker/output/validation_loudness_zwicker_stationary_Test_signal_2_(250_Hz_80_dB).png)
23+
![](../validations/loudness_zwicker/output/validation_loudness_zwicker_stationary_Test_signal_2_(250_Hz_80_dB).png)
2424

2525
*Loudness calculation for ISO 532-1 test signal n°2 (250 Hz tone in free field with a level of 80 dB)*
2626

27-
![](../mosqito/validations/loudness_zwicker/output/validation_loudness_zwicker_stationary_Test_signal_3_(1_kHz_60_dB).png)
27+
![](../validations/loudness_zwicker/output/validation_loudness_zwicker_stationary_Test_signal_3_(1_kHz_60_dB).png)
2828

2929
*Loudness calculation for ISO 532-1 test signal n°3 (1 kHz tone in free field with a level of 60 dB)*
3030

31-
![](../mosqito/validations/loudness_zwicker/output/validation_loudness_zwicker_stationary_Test_signal_4_(4_kHz_40_dB).png)
31+
![](../validations/loudness_zwicker/output/validation_loudness_zwicker_stationary_Test_signal_4_(4_kHz_40_dB).png)
3232

3333
*Loudness calculation for ISO 532-1 test signal n°4 (4 kHz tone in free field with a level of 40 dB)*
3434

35-
![](../mosqito/validations/loudness_zwicker/output/validation_loudness_zwicker_stationary_Test_signal_5_(pinknoise_60_dB).png)
35+
![](../validations/loudness_zwicker/output/validation_loudness_zwicker_stationary_Test_signal_5_(pinknoise_60_dB).png)
3636

3737
*Loudness calculation for ISO 532-1 test signal n°5 (pink noise in free field with an overall level of 60 dB)*
3838

39-
*All the validation plots and scripts can be found in [this folder](../mosqito/validations/loudness_zwicker).*
39+
*All the validation plots and scripts can be found in [this folder](../validations/loudness_zwicker).*
4040

4141
### References
4242

documentation/loudness-time-varying.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@ The acoustic loudness calculation according to Zwicker method was initially intr
77
In MOSQITO, the code is based on the C++ program published with ISO 532-1:2017.
88

99
### Validation of the implementation
10-
The ISO 532-1:2017 standard provides a set of synthetic and technical signals covering representative applications to be used to validate any of its implementation. The standards also provides the compliance requirements. A step by step description of how to use MOSQITO to calculate the loudness and the specific loudness from a .wav file is given in [tutorial n°3](./tuto3_Loudness-zwicker-time-varying.ipynb).
10+
The ISO 532-1:2017 standard provides a set of synthetic and technical signals covering representative applications to be used to validate any of its implementation. The standards also provides the compliance requirements. A step by step description of how to use MOSQITO to calculate the loudness and the specific loudness from a .wav file is given in [this tutorial](../tutorials/tuto_loudness.ipynb).
1111

12-
Annex B4 of the standard provides .wav files of synthetic signals to be used as input for time-varying loudness calculation. The plots below compare the MOSQITO loudness calculations for the test signal n°6 to the compliance requirements of the standards. MOSQITO implementation passes successfully the 8 tests from annex B4 (all compliance plots can be found in the [tests/loudness/output folder](../mosqito/tests/loudness/output)).
12+
Annex B4 of the standard provides .wav files of synthetic signals to be used as input for time-varying loudness calculation. The plots below compare the MOSQITO loudness calculations for the test signal n°6 to the compliance requirements of the standards. MOSQITO implementation passes successfully the 8 tests from annex B4 (all compliance plots can be found in [this folder](../tests/loudness/output)).
1313

14-
![](../mosqito/validations/loudness_zwicker/output/validation_loudness_zwicker_time_Test_signal_6_(tone_250_Hz_30_dB_-_80_dB)_Loudness.png)
15-
![](../mosqito/validations/loudness_zwicker/output/validation_loudness_zwicker_time_Test_signal_6_(tone_250_Hz_30_dB_-_80_dB)_Specific.png)
14+
![](../validations/loudness_zwicker/output/validation_loudness_zwicker_time_Test_signal_6_(tone_250_Hz_30_dB_-_80_dB)_Loudness.png)
15+
![](../validations/loudness_zwicker/output/validation_loudness_zwicker_time_Test_signal_6_(tone_250_Hz_30_dB_-_80_dB)_Specific.png)
1616

1717
*Loudness calculation for ISO 532-1 test signal n°6 (A 250 Hz tone with a time-varying sound pressure level starting with 30 dB and increasing linearly to 80 dB). Top: overall loudness, Bottom: specific loudness at 2.5 Barks*
1818

19-
Annex B5 of the standard provides .wav files of technical signals to be used as input for time-varying loudness calculation. The plot below compares the MOSQITO loudness calculations for the test signal n°14 to the compliance requirements of the standards. MOSQITO implementation passes successfully 11 tests over the 12 from annex B4 (all compliance plots can be found in [this folder](../mosqito/validations/loudness_zwicker/output)).
19+
Annex B5 of the standard provides .wav files of technical signals to be used as input for time-varying loudness calculation. The plot below compares the MOSQITO loudness calculations for the test signal n°14 to the compliance requirements of the standards. MOSQITO implementation passes successfully 11 tests over the 12 from annex B4 (all compliance plots can be found in [this folder](../tests/loudness/output)).
2020

21-
![](../mosqito/validations/loudness_zwicker/output/validation_loudness_zwicker_time_Test_signal_14_(propeller-driven_airplane)_Loudness.png)
21+
![](../validations/loudness_zwicker/output/validation_loudness_zwicker_time_Test_signal_14_(propeller-driven_airplane)_Loudness.png)
2222

2323
*Loudness calculation for ISO 532-1 test signal n°14 (Propeller-driven airplane noise)*
2424

2525
The test on signal 16 fails because the 5% tolerance limit is exceeded for more than 1% of the time at the end of the signal, during the decay from hairdryer noise to silence (see figure below). This issue is currently under investigation.
2626

27-
![](../mosqito/validations/loudness_zwicker/output/FAILED_validation_loudness_zwicker_time_Test_signal_16_(hairdryer)_Loudness.png)
27+
![](../validations/loudness_zwicker/output/FAILED_validation_loudness_zwicker_time_Test_signal_16_(hairdryer)_Loudness.png)
2828

2929
*Loudness calculation for ISO 532-1 test signal n°14 (Hairdryer noise)*
3030

documentation/readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ In this folder, you will find the documentation and validation of the different
66

77
## Generalities
88

9+
- [Scope of the project](./scope.md)
910
- [Architecture of the toolbox](./architecture.md)
1011

1112
## Sound Quality metrics

documentation/roughness.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
Several models have been developed to calculate the acoustic roughness, but there is no official standardization yet.
77

88
In MOSQITO, the code is based on the algorithm described in Daniel and Weber, 1997.
9-
A step by step description of how to use MOSQITO to calculate the roughness is given in [tutorial n°6](../tutorials/tuto6_Roughness-from-wav.ipynb)
9+
A step by step description of how to use MOSQITO to calculate the roughness is given in [this tutorial](../tutorials/tuto_roughness.ipynb)
1010

1111
### Validation of the implementation
1212

1313
H.Fastl and E.Zwicker proposed some reference values for the roughness of amplitude-modulated tones in figure 11.2 of Zwicker and Fastl, 2007.
1414

15-
In Mosqito the test AM tones are generated using the '[test_signal_generation](../mosqito/tests/roughness/test_signal_generation.py)' script, in accordance with the equation (1) from the Daniel and Weber article.
15+
In Mosqito the test AM tones are generated using the '[signals_test_generation](../tests/roughness/signals_test_generation.py)' script, in accordance with the equation (1) from the Daniel and Weber article.
1616

1717
The plot below compare different roughness implementations' results for amplitude-modulated tones (carrier frequency of 250, 1000, 4000 Hz and modulation frequency from 10 to 400 Hz):
1818
- Daniel and Weber implementation described in the 1997 article (results from figure 3)
@@ -21,10 +21,10 @@ The plot below compare different roughness implementations' results for amplitud
2121

2222
Mosqito implementation give similar results as other implementations. Zwicker and Fastl recommand that any roughness calculation should give results within a +/- 17% range around their reference values. Note that none of the 3 implementations respect this criteria. However, Daniel and Weber algorithm is considered as a reference. Any improvement of the roughness assessment is welcome to be implemented in Mosqito.
2323

24-
![](../mosqito/validations/roughness_danielweber/roughness_implementations_comparison.png)
24+
![](../validations/roughness_danielweber/roughness_implementations_comparison.png)
2525

2626

27-
*All the plots and scripts for more detailed validation can be found in [this folder](../mosqito/validations/roughness_danielweber).*
27+
*All the plots and scripts for more detailed validation can be found in [this folder](../validations/roughness_danielweber).*
2828

2929

3030
### References

documentation/scope.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Scope of the project
2+
3+
## Sound quality metrics
4+
The scope of the project is to implement the following first set of
5+
metrics:
6+
7+
| | Reference | Validated | Available | Under dev. | To do |
8+
|:-------------------------------------------------- |:---------------------------------------------------- |:--------------------------------------------------:|:---------------------------------------------:|:----------:|:-----:|
9+
| Loudness for<br>steady signals<br>(Zwicker method) | ISO 532B:1975<br>DIN 45631:1991<br>ISO 532-1:2017 §5 | [x](./mosqito/validations/loudness_zwicker/output) | [x](./documentation/loudness-stationary.md) | | |
10+
| Loudness for non-stationary<br>(Zwicker method) | DIN 45631/A1:2010<br>ISO 532-1:2017 §6 | [x](./mosqito/validations/loudness_zwicker/output) | [x](./documentation/loudness-time-varying.md) | | |
11+
| Loudness for non-stationary<br>(ECMA-74 method) | ECMA-74:2019, annex F<br>Sottek, 2016 | | | x | |
12+
| Roughness | Daniel and Weber, 1997 | [x](./mosqito/validations/roughness_danielweber) | [x](./documentation/roughness.md) | | |
13+
| Roughness | ECMA-418-2:2020 | | | | x |
14+
| Fluctuation Strength | To be defined | | | | x |
15+
| Sharpness | DIN 45692:2009 | [x](./mosqito/validations/sharpness/output) | [x](./documentation/sharpness.md) | | |
16+
| Tonality (Hearing model) | ECMA-74:2019 annex G | | | x | |
17+
18+
As a second priority, the project could address the following metrics:
19+
20+
| | Reference | Validated | Available | Under dev. | To do |
21+
|:----------------------------------------------------------------------------------- |:------------------------------------- |:---------:|:---------:|:----------:|:-----:|
22+
| Loudness for steady signals<br>(Moore/Glasberg method) | ISO 532-2:2017 | | | | x |
23+
| Loudness for non-stationary<br>(Moore/Glasberg method) | Moore, 2014 | | | | x |
24+
| Sharpness (using <br>Moore/Glasberg loudness) | Hales-Swift<br>and Gee, 2017 | | | | x |
25+
| Tone-to-noise ratio / Prominence <br> ratio (occupational noise,<br>discrete tones) | ECMA-74:2019 annex D<br>ISO 7719:2018 | | x | | |
26+
| Tone-to-noise ratio<br>(environmental noise,<br>automatic tone detection) | DIN 45681 | | | | x |
27+
| Tone-to-noise ratio<br>(environmental noise) | ISO 1996-2 | | | | x |
28+
| Tone-to-noise ratio<br>(environmental noise) | ANSI S1.13:2005 | | | | x |
29+
30+
31+
## Other SQ tools
32+
In parallel, tools for signal listening and manipulation will be
33+
developed. The objective is to be able to apply some modification to a
34+
signal (filtering, tone removal, etc.) and assess the impact on
35+
different SQ metrics. The integration of tools to define jury tests and
36+
analyze the results is also planned.
37+
38+
Of course, any other sound quality related implementation by anyone who
39+
wants to contribute is welcome.
40+
41+
## References
42+
43+
Daniel, P., and Weber, R. (1997). “Psychoacoustical Roughness: Implementation
44+
of an Optimized Model”, Acta Acustica, Vol. 83: 113-123
45+
46+
Hales Swift, S., and Gee, K. L. (2017). “Extending sharpness calculation
47+
for an alternative loudness metric input,” J. Acoust. Soc. Am.142,
48+
EL549.
49+
50+
Moore, B. C. J. et al. (2016) ‘A Loudness Model for Time-Varying Sounds Incorporating Binaural Inhibition’, Trends in Hearing. [doi: 10.1177/2331216516682698](https://doi.org/10.1177/2331216516682698).
51+
52+
Sottek, R. (2016) A Hearing Model Approach to Time-Varying Loudness, Acta Acustica united with Acustica, vol. 102, no. 4, pp. 725-744.

documentation/sharpness.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ The code is based on the version of the standard published in 2009 and the loudn
1111

1212
The DIN 45692:2009 standard provides a set of synthetic and technical signals covering representative applications to be used to validate any of its implementation. The standards also provides the compliance requirements for a set of broad-band noises and narrow-band noises. The sharpness is calculated by mosqito for the 20 broad-band signals and for the 21 narrow-band signals filtered with different center frequencies provided with the standard. The results are compared to the requirements in the figures below.
1313

14-
![](../mosqito/validations/sharpness/output/validation_sharpness_Broad-band_noise.png)
14+
![](../validations/sharpness/output/validation_sharpness_Broad-band_noise.png)
1515

16-
![](../mosqito/validations/sharpness/output/validation_sharpness_Narrow-band_noise.png)
16+
![](../validations/sharpness/output/validation_sharpness_Narrow-band_noise.png)
1717

18-
*The validation plots and scripts can be found in [this folder](../mosqito/validations/sharpness).*
18+
*The validation plots and scripts can be found in [this folder](../validations/sharpness).*
1919

2020
## Sharpness of stationary and time-varying signals (other methods)
2121

mosqito/functions/oct3filter/oct3spec.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from mosqito.functions.oct3filter.oct3level import oct3level
1212

1313

14-
def oct3spec(sig, fs, fc_min=20, fc_max=20000, sig_type="stationary", dec_factor=24):
14+
def oct3spec(sig, fs, fc_min=25, fc_max=12500, sig_type="stationary", dec_factor=24):
1515
"""Calculate third-octave band spectrum
1616

1717
Calculate the rms level of the signal "sig" sampled at freqency "fs"
@@ -55,6 +55,8 @@ def oct3spec(sig, fs, fc_min=20, fc_max=20000, sig_type="stationary", dec_factor
5555
# Définition of the range of preferred filter center frequency
5656
fpref = np.array(
5757
[
58+
16,
59+
20,
5860
25,
5961
31.5,
6062
40,
@@ -83,11 +85,15 @@ def oct3spec(sig, fs, fc_min=20, fc_max=20000, sig_type="stationary", dec_factor
8385
8000,
8486
10000,
8587
12500,
88+
16000,
89+
20000,
8690
]
8791
)
8892

8993
fexact = np.array(
9094
[
95+
15.849,
96+
19.953,
9197
25.119,
9298
31.623,
9399
39.811,
@@ -116,6 +122,8 @@ def oct3spec(sig, fs, fc_min=20, fc_max=20000, sig_type="stationary", dec_factor
116122
7943,
117123
10000,
118124
12589,
125+
15849,
126+
19953,
119127
]
120128
)
121129

mosqito/functions/shared/load.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,11 @@ def load(is_stationary, file, calib=1, mat_signal="", mat_fs=""):
5050
signal = calib * signal / (2 ** 15 - 1)
5151
elif isinstance(signal[0], np.int32):
5252
signal = calib * signal / (2 ** 31 - 1)
53+
elif isinstance(signal[0], np.float):
54+
signal = calib * signal
5355

5456
# load the .uff file content
55-
elif file[-3:] == "uff" or file[-3:] == "UFF":
57+
elif file[-3:].lower() == "uff" or file[-3:].lower() == "unv":
5658
uff_file = pyuff.UFF(file)
5759
data = uff_file.read_sets()
5860
data.keys()

0 commit comments

Comments
 (0)