In this repository you can find the MATLAB and Julia (not tested as well as the MATLAB version) code for a perceptual distortion measure based on auditory masking. Such a measure can predict if a human can notice the difference between two acoustic signals.
In particular, this code reflects my interpretation of the distortion measure proposed by Van de Par et al. in [1]. In the following I will refer to it as the Par-measure. The major strength of the Par-measure is that, once the masker is fixed, it can be expressed as a weighted
Concretely, consider an actual acoustic signal
If
This repository includes:
- A report
REPORT.pdfwhich explains the background of the Par-measure, the functionality of the code and the provided examples; - The MATLAB code
par_measure.mwhich can be used to compute the masking curves; - The Julia code
Julia_version/par_measure.jlandJulia_version/test_par_measure.jl. This code is tested less well than the MATLAB version. - The MATLAB code
example1_basics.m, which shows the functionality of the code; - The MATLAB code
example2a_loudness_increase.m, which uses the Par-measure to increase the loudness of acoustic signals while keeping the perceived distortion limited. This example is directly based on the work done by Jeannerot et al. in [2] and, in my opinion, is a nice example of how to use the Par-measure inside an optimization framework; - The MATLAB code
example2b_hard_clipping.m, which uses hard clipping to perform the loudness increase of acoustic signals; - The .wav files corresponding to
example_2a_loudness_increase.mandexample_2b_hard_clipping.mcan be found in theDatafolder. As reference files I used two different signals. The results of the first signal can be found inData/Example_audio_1and the results for the second signal are found inData/Example_audio_2. The filesloudness_hard_<>.wavcorrespond to hard clipping with parameter<>. The filesloudness_percep_<>.wavcorrespond to using the Par-measure with parameter$d$ equal to<>.- I do not know an easy way to compare the two types of parameters, so the best approach is to listen to a few audio files and try to compare the perceived distortion and the perceived loudness increase.
- Note that the maximum amplitude of the audio in each file is equal!
Feel free to leave a message in case you have questions, find mistakes, or have any other comments!
The code was tested on MATLAB R2023b and MATLAB R2024b on Ubuntu 23.10. I think the Par-measure can be used using default MATLAB functionality, but if I notice that certain packages are needed I will list them here. For Julia I used version 1.11.5.
To run Example 2, you need CVX. It should be straightforward to rewrite the examples to use other optimisation packages such as YALMIP or CVXPY, though the latter requires interfacing with Python.
Acoustic signal processing, perceptual distortion, distortion measure, Par-measure, psychoacoustical modelling, auditory masking
- There is also a Python implementation by Niels de Koeijer (Bang & Olufsen)!! See link. This implementation can be used in PyTorch as a loss function.
- We used this implementation of the Par-measure in "Loudspeaker Beamforming to Enhance Speech Recognition Performance of Voice Driven Applications", to appear at ICASSP 2025, see [3].
[1] van de Par, S., Kohlrausch, A., Heusdens, R. et al. A Perceptual Model for Sinusoidal Audio Coding Based on Spectral Integration. EURASIP J. Adv. Signal Process. 2005, 317529 (2005). DOI
[2] A. Jeannerot, N. de Koeijer, P. Martínez-Nuevo, M. B. Møller, J. Dyreby and P. Prandoni, "Increasing Loudness in Audio Signals: A Perceptually Motivated Approach to Preserve Audio Quality," ICASSP 2022 - 2022 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), Singapore, Singapore, 2022, pp. 1001-1005. https://doi.org/10.1109/ICASSP43922.2022.9747589. Alternative ARXIV link.
[3] Dimme de Groot, Baturalp Karslioglu, Odette Scharenborg and Jorge Martinez, "Loudspeaker Beamforming to Enhance Speech Recognition Performance of Voice Driven Applications", 2025. ARXIV preprint