BAMQ.m 1.65 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
function binQ = BAMQ(mRef, mTest, fs)
%BAMQ calculate perceptual binaural difference between mRef and mTest
% -------------------------------------------------------------------------
% 
% Usage: binQ = BAMQ(mRef, mTest, fs)
%
%   Input:   mRef            ... reference signal matrix (Nx2)
%            mTest           ... aligned test signal matrix (Nx2)
%            fs              ... sampling frequency  (files are resampled to 44.1 kHz)
%
%            0 dB FS should correspond to 115 dB SPL
%
%  Output:   binQ            ... binaural perceptual quality value
%
%  Values:   100 ... no difference
%            0   ... obvious difference
%            -X  ... even bigger difference
%            
%
% Copyright (C) University of Oldenburg and HrTech 2012-2015
% Author :  flja
% Date   :  12-02-2019

funcFile = mfilename('fullpath');
pathstr = fileparts(funcFile);
addpath([pathstr filesep 'functions'])

if nargin < 3,
    error('Not enough input arguments.');
end

if fs ~= 44100
    mRef = resample(mRef,44100,fs);
    mTest = resample(mTest,44100,fs);
    fs = 44100;
end

if size(mRef,1) < fs*0.4,
    error('signals need to be at least 0.4 s long')
end

% avoid NaNs in IVS calculation:
mRef = [0.00001,0.00001;mRef(1:end-1,:)];
mTest = [0.00001,0.00001;mTest(1:end-1,:)];

%% FRONT END: modified Dietz model

[mITDref,  mIVSref, mILDref, mPowRef1,  mPowRef2] = BAMQFrontEnd(mRef,fs);

[mITDtest, mIVStest, mILDtest, mPowTest1, mPowTest2, fc, fsNew] = BAMQFrontEnd(mTest,fs);

%% BACK END

binQ = BAMQBackEnd(mITDref,  mIVSref, mILDref, mPowRef1,  mPowRef2, ...
                   mITDtest, mIVStest, mILDtest, mPowTest1, mPowTest2, fc, fsNew);
binQ = ceil(binQ);