Home > SUpDEq-v5.0.0 > evaluation > supdeq_testHPlocalization.m

supdeq_testHPlocalization

PURPOSE ^

% SUpDEq - Spatial Upsampling by Directional Equalization

SYNOPSIS ^

function results = supdeq_testHPlocalization( testHRTFdataset, referenceHRTFdataset, samplingGrid, fs, printResults)

DESCRIPTION ^

% SUpDEq - Spatial Upsampling by Directional Equalization

 function results = supdeq_testHPlocalization( testHRTFdataset, referenceHRTFdataset, samplingGrid, fs, printResults)

 This function models horizontal plane localization for the testHRTFdataset
 and the referenceHRTFdataset on a pre-defined or given sampling grid. 
 The function uses the GMM-based estimation of azimuth direction 
 according to May2011 (see references), which is part of the 
 Auditory Modeling Toolbox (AMT). The result is a struct with the azimuthal 
 errors in degree.

 Output:
 results               - Output struct with errors and mean absolute
                         errors of the test/referenceHRTFdataset

 Input:        
 testHRTFdataset       - Struct with SH-coefficients of the test 
                         HRTF dataset (for example the de-equalized HRTF set
                         or any other HRTF set based on the referenceHRTFdataset) 
                         for the left (Hl_nm) and right (Hr_nm) channel/ear, 
                         absolute frequency scale f, transform order N, and FFToversize
 referenceHRTFdataset  - Struct with SH-coefficients of the reference 
                         HRTF dataset for the left (Hl_nm) and right (Hr_nm) channel/ear, 
                         absolute frequency scale f, transform order N, and FFToversize
 samplingGrid          - Spatial sampling grid. Must be a Qx2 matrix where 
                         the first column holds the azimuth and the second 
                         the elevation.
                         If no samplingGrid (or []) is passed, the default
                         sampling grid is used with equidistant values
                         (steps of 5° in azimuth, elevation = 90° (sound source in the front), 
                         azimuth range +-90°)
 fs                    - Sampling Rate
                         Default: 48000
 printResults          - Print results true/false
                         Default:false

 Dependencies: Auditory Modeling Toolbox (AMT)

 References:
 T. May, S. van de Par, and A. Kohlrausch. A probabilistic model for
 robust localization based on a binaural auditory front-end. IEEE Trans
 Audio Speech Lang Proc, 19:1-13, 2011.

 (C) 2018 by JMA, Johannes M. Arend
             TH Köln - University of Applied Sciences
             Institute of Communications Engineering
             Department of Acoustics and Audio Signal Processing

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% SUpDEq - Spatial Upsampling by Directional Equalization
0002 %
0003 % function results = supdeq_testHPlocalization( testHRTFdataset, referenceHRTFdataset, samplingGrid, fs, printResults)
0004 %
0005 % This function models horizontal plane localization for the testHRTFdataset
0006 % and the referenceHRTFdataset on a pre-defined or given sampling grid.
0007 % The function uses the GMM-based estimation of azimuth direction
0008 % according to May2011 (see references), which is part of the
0009 % Auditory Modeling Toolbox (AMT). The result is a struct with the azimuthal
0010 % errors in degree.
0011 %
0012 % Output:
0013 % results               - Output struct with errors and mean absolute
0014 %                         errors of the test/referenceHRTFdataset
0015 %
0016 % Input:
0017 % testHRTFdataset       - Struct with SH-coefficients of the test
0018 %                         HRTF dataset (for example the de-equalized HRTF set
0019 %                         or any other HRTF set based on the referenceHRTFdataset)
0020 %                         for the left (Hl_nm) and right (Hr_nm) channel/ear,
0021 %                         absolute frequency scale f, transform order N, and FFToversize
0022 % referenceHRTFdataset  - Struct with SH-coefficients of the reference
0023 %                         HRTF dataset for the left (Hl_nm) and right (Hr_nm) channel/ear,
0024 %                         absolute frequency scale f, transform order N, and FFToversize
0025 % samplingGrid          - Spatial sampling grid. Must be a Qx2 matrix where
0026 %                         the first column holds the azimuth and the second
0027 %                         the elevation.
0028 %                         If no samplingGrid (or []) is passed, the default
0029 %                         sampling grid is used with equidistant values
0030 %                         (steps of 5° in azimuth, elevation = 90° (sound source in the front),
0031 %                         azimuth range +-90°)
0032 % fs                    - Sampling Rate
0033 %                         Default: 48000
0034 % printResults          - Print results true/false
0035 %                         Default:false
0036 %
0037 % Dependencies: Auditory Modeling Toolbox (AMT)
0038 %
0039 % References:
0040 % T. May, S. van de Par, and A. Kohlrausch. A probabilistic model for
0041 % robust localization based on a binaural auditory front-end. IEEE Trans
0042 % Audio Speech Lang Proc, 19:1-13, 2011.
0043 %
0044 % (C) 2018 by JMA, Johannes M. Arend
0045 %             TH Köln - University of Applied Sciences
0046 %             Institute of Communications Engineering
0047 %             Department of Acoustics and Audio Signal Processing
0048 
0049 function results = supdeq_testHPlocalization( testHRTFdataset, referenceHRTFdataset, samplingGrid, fs, printResults)
0050 
0051 %Sampling grid on horizontal plane with +-90 degree in steps of 5 degree
0052 if nargin < 3 || isempty(samplingGrid)
0053     [~, samplingGrid] = AKsubGrid(5, 'transverse', 0);
0054     %Transform elevation to required range
0055     samplingGrid(:,2) = 90-samplingGrid(:,2);
0056     %Set az to range between -90 and 90 degree
0057     ids = [find(samplingGrid(:,1)<=90);find(samplingGrid(:,1)>=270)];
0058     samplingGrid = samplingGrid(ids,:);    
0059 end
0060 
0061 if nargin < 4 || isempty(fs)
0062     fs = 48000;
0063 end
0064 
0065 if nargin < 5
0066     printResults = false;
0067 end
0068 
0069 %% Run model may2011
0070 
0071 %Generate noise with a length of 1 second
0072 noise = randn(fs,1);
0073 %Set to -6dB peak level
0074 noise = noise*((10^(-6/20))/(max(abs(noise))));
0075 
0076 % Get HRIRs according to sampling grid
0077 fprintf('Extracting 2 x %d HRIRs. This may take some time...\n',size(samplingGrid,1));
0078 [HRIRs_Test_L,HRIRs_Test_R] = supdeq_getArbHRIR(testHRTFdataset,samplingGrid,[],[],'ak');
0079 [HRIRs_Ref_L,HRIRs_Ref_R]   = supdeq_getArbHRIR(referenceHRTFdataset,samplingGrid,[],[],'ak');
0080 fprintf('2 x %d HRIRs extracted...\n',size(samplingGrid,1))
0081 
0082 disp('Running model according to May2011...');
0083 az_Test = zeros(1,size(samplingGrid,1));
0084 az_Ref  = zeros(1,size(samplingGrid,1));
0085 for i = 1:size(samplingGrid,1)
0086 
0087     %Create binaural noise signal
0088     binNoise_Test(:,1) = conv(noise,HRIRs_Test_L(:,i));
0089     binNoise_Test(:,2) = conv(noise,HRIRs_Test_R(:,i));
0090     binNoise_Ref(:,1)  = conv(noise,HRIRs_Ref_L(:,i));
0091     binNoise_Ref(:,2)  = conv(noise,HRIRs_Ref_R(:,i));
0092     
0093     %Test azimuthal position with may2011
0094     azStruct_Test   = may2011(binNoise_Test,fs);
0095     azStruct_Ref    = may2011(binNoise_Ref,fs);
0096     %Histogram analysis of frame-based localization estimates
0097     az_Test(:,i)    = may2011_estAzimuthGMM(azStruct_Test,'HIST',1,0);
0098     az_Ref(:,i)     = may2011_estAzimuthGMM(azStruct_Ref,'HIST',1,0);
0099     
0100     if ~mod(i,5)
0101         fprintf('%d of %d azimuthal positions evaluated...\n',i,size(samplingGrid,1))
0102     end
0103     
0104 end
0105     
0106 %% (2) - Prepare az values of samplingGrid for output format of may2011
0107 
0108 azSamplingGrid                      = samplingGrid(:,1);
0109 azSamplingGrid(azSamplingGrid<=90)  = -1*azSamplingGrid(azSamplingGrid<=90);
0110 azSamplingGrid(azSamplingGrid>90)   = 360-azSamplingGrid(azSamplingGrid>90);
0111 
0112 %% (3) - Calculate errors and write results struct
0113 
0114 results.azError_Test                = az_Test' - azSamplingGrid;
0115 results.azAbsError_Test             = abs(results.azError_Test );
0116 results.azError_Ref                 = az_Ref'  - azSamplingGrid;
0117 results.azAbsError_Ref              = abs(results.azError_Ref  );
0118 results.azMeanAbsError_Test         = mean(results.azAbsError_Test);
0119 results.azMeanAbsError_Ref          = mean(results.azAbsError_Ref);
0120 results.diff_azMeanAbsError         = results.azMeanAbsError_Ref - results.azMeanAbsError_Test;
0121 results.azNonZeroMeanAbsError_Test  = mean(nonzeros(results.azAbsError_Test));
0122 results.azNonZeroMeanAbsError_Ref   = mean(nonzeros(results.azAbsError_Ref));
0123 results.diff_azNonZeroMeanAbsError  = results.azNonZeroMeanAbsError_Ref - results.azNonZeroMeanAbsError_Test;
0124 results.azSamplingGrid              = azSamplingGrid;
0125 results.samplingGrid                = samplingGrid;
0126 
0127 disp('Done with horizontal plane localization test...');
0128 
0129 %% (4) - Print results
0130 
0131 if printResults
0132     fprintf('\nRESULTS \n');
0133     disp('------------------------------------------------------');
0134     fprintf('Mean absolute azimuthal error testHRTFdataset (deg) \t\t %4.1f \n',results.azMeanAbsError_Test)
0135     fprintf('Mean absolute azimuthal error referenceHRTFdataset (deg) \t %4.1f \n',results.azMeanAbsError_Ref)
0136     fprintf('Mean absolute azimuthal error difference (deg) \t\t\t %4.1f \n',results.diff_azMeanAbsError)
0137     disp('------------------------------------------------------');
0138     fprintf('Non zero mean absolute azimuthal error testHRTFdataset (deg) \t %4.1f \n',results.azNonZeroMeanAbsError_Test)
0139     fprintf('Non zero mean absolute azimuthal error referenceHRTFdataset (deg) %4.1f \n',results.azNonZeroMeanAbsError_Ref)
0140     fprintf('Non zero mean absolute azimuthal error difference (deg) \t %4.1f \n',results.diff_azNonZeroMeanAbsError)
0141     disp('------------------------------------------------------');
0142 end
0143 
0144 end
0145

Generated on Wed 30-Nov-2022 14:15:00 by m2html © 2005