In this repository you can find the MATLAB 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]. I 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 which explains the background of the Par-measure, the functionality of the code and the provided examples;
- The MATLAB code
par_measure.m
which can be used to compute the masking curves; - 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 optimisation framework; - The MATLAB code
example2b_hard_clipping.m
, which uses hard clipping to perform the loudness icnrease of acoustic signals; - The .wav files corresponding to
example_2a_loudness_increase.m
andexample_2b_hard_clipping.m
can be found in theData
folder. As reference files I used two different signals. The results of the first signal can be found inData/Example_audio_1
and the results for the second signal are found inData/Example_audio_2
. The filesloudness_hard_<>.wav
correspond to hard clipping with parameter<>
. The filesloudness_percep_<>.wav
correspond 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.
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.
[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). https://doi.org/10.1155/ASP.2005.1292
[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.