% SUpDEq - Spatial Upsampling by Directional Equalization function results = supdeq_testSPlocalization( testHRTFdataset, referenceHRTFdataset, samplingGrid, S, lat, fs, printResults ) This function models sagittal plane localization for the testHRTFdataset and the referenceHRTFdataset on a pre-defined or given sampling grid. The function uses the model according to Baumgartner2014 (see references), which is part of the Auditory Modeling Toolbox (AMT). The result is a struct with quadrant errors (qe) in percent and polar errors (pe) in degree for the test/reference HRTF dataset and the difference between both estimations. Output: results - Output struct with qe (quadrant errors in %) and pe (local polar errors in degree) 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 1° in azimuth and elevation, azimuth range from 0-359°, elevation range from -30 - +90) S - Listener-specific sensitivity threshold (threshold of the sigmoid link function representing the psychometric link between transformation from the distance metric and similarity index) to S. Default: 0.76 (according to Baumgartner2014) lat - Apparent lateral angle of the sound sources to be tested (azimuth) Default: 0 (0 degree - sound source in the front) fs - Sampling Rate Default: 48000 printResults - Print results true/false Default:false Dependencies: Auditory Modeling Toolbox (AMT) References: R. Baumgartner, P. Majdak, and B. Laback. Modeling sound-source localization in sagittal planes for human listeners. The Journal of the Acoustical Society of America, 136(2):791-802, 2014. (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
0001 %% SUpDEq - Spatial Upsampling by Directional Equalization 0002 % 0003 % function results = supdeq_testSPlocalization( testHRTFdataset, referenceHRTFdataset, samplingGrid, S, lat, fs, printResults ) 0004 % 0005 % This function models sagittal plane localization for the testHRTFdataset 0006 % and the referenceHRTFdataset on a pre-defined or given sampling grid. 0007 % The function uses the model according to Baumgartner2014 (see references), 0008 % which is part of the Auditory Modeling Toolbox (AMT). The result is a 0009 % struct with quadrant errors (qe) in percent and polar errors (pe) in degree 0010 % for the test/reference HRTF dataset and the difference between both estimations. 0011 % 0012 % Output: 0013 % results - Output struct with qe (quadrant errors in %) and pe 0014 % (local polar errors in degree) of the 0015 % test/referenceHRTFdataset 0016 % 0017 % Input: 0018 % testHRTFdataset - Struct with SH-coefficients of the test 0019 % HRTF dataset (for example the de-equalized HRTF set 0020 % or any other HRTF set based on the referenceHRTFdataset) 0021 % for the left (Hl_nm) and right (Hr_nm) channel/ear, 0022 % absolute frequency scale f, transform order N, and FFToversize 0023 % referenceHRTFdataset - Struct with SH-coefficients of the reference 0024 % HRTF dataset for the left (Hl_nm) and right (Hr_nm) channel/ear, 0025 % absolute frequency scale f, transform order N, and FFToversize 0026 % samplingGrid - Spatial sampling grid. Must be a Qx2 matrix where 0027 % the first column holds the azimuth and the second 0028 % the elevation. 0029 % If no samplingGrid (or []) is passed, the default 0030 % sampling grid is used with equidistant values 0031 % (steps of 1° in azimuth and elevation, azimuth 0032 % range from 0-359°, elevation range from -30 - +90) 0033 % S - Listener-specific sensitivity threshold 0034 % (threshold of the sigmoid link function representing 0035 % the psychometric link between transformation from the 0036 % distance metric and similarity index) to S. 0037 % Default: 0.76 (according to Baumgartner2014) 0038 % lat - Apparent lateral angle of the sound sources to be 0039 % tested (azimuth) 0040 % Default: 0 (0 degree - sound source in the front) 0041 % fs - Sampling Rate 0042 % Default: 48000 0043 % printResults - Print results true/false 0044 % Default:false 0045 % 0046 % Dependencies: Auditory Modeling Toolbox (AMT) 0047 % 0048 % References: 0049 % R. Baumgartner, P. Majdak, and B. Laback. Modeling sound-source 0050 % localization in sagittal planes for human listeners. 0051 % The Journal of the Acoustical Society of America, 136(2):791-802, 2014. 0052 % 0053 % (C) 2018 by JMA, Johannes M. Arend 0054 % TH Köln - University of Applied Sciences 0055 % Institute of Communications Engineering 0056 % Department of Acoustics and Audio Signal Processing 0057 0058 function results = supdeq_testSPlocalization( testHRTFdataset, referenceHRTFdataset, samplingGrid, S, lat, fs, printResults ) 0059 0060 % SamplingGrid according to Baumgartner2014 0061 % (-30 to +60 elevation, steps of 1 degree in azimuth and elevation 0062 if nargin < 3 || isempty(samplingGrid) 0063 [~, samplingGrid] = AKsubGrid(1, 'transverse', 90:-1:-30); 0064 %Transform elevation to required range 0065 samplingGrid(:,2) = 90-samplingGrid(:,2); 0066 end 0067 0068 if nargin < 4 || isempty(S) 0069 S = 0.76; 0070 end 0071 0072 if nargin < 5 || isempty(lat) 0073 lat = 0; 0074 end 0075 0076 if nargin < 6 || isempty(fs) 0077 fs = 48000; 0078 end 0079 0080 if nargin < 7 0081 printResults = false; 0082 end 0083 0084 % Get values of sampling grid for defined lateral value (azimuth) 0085 latIDFront = find(samplingGrid(:,1) == lat); 0086 latIDBack = find(samplingGrid(:,1) == 180-lat); 0087 if isempty(latIDFront) || isempty(latIDBack) 0088 error('Could not find lateral target angle (lat, front or back) in sampling grid. Please re-define lateral target angle or sampling grid!'); 0089 else 0090 %Get also values for back (latID = 180) 0091 samplingGrid = [samplingGrid(latIDFront,:);samplingGrid(latIDBack,:)]; 0092 end 0093 0094 %% (1) - Get HRIRs according to sampling grid 0095 0096 fprintf('Extracting 2 x %d HRIRs. This may take some time...\n',size(samplingGrid,1)); 0097 [HRIRs_Test_L,HRIRs_Test_R] = supdeq_getArbHRIR(testHRTFdataset,samplingGrid,[],[],'ak'); 0098 [HRIRs_Ref_L,HRIRs_Ref_R] = supdeq_getArbHRIR(referenceHRTFdataset,samplingGrid,[],[],'ak'); 0099 fprintf('2 x %d HRIRs extracted...\n',size(samplingGrid,1)) 0100 0101 %% (2) - Save in SOFA format 0102 0103 testSOFA = supdeq_writeSOFAobj(HRIRs_Test_L',HRIRs_Test_R',samplingGrid, fs); 0104 refSOFA = supdeq_writeSOFAobj(HRIRs_Ref_L',HRIRs_Ref_R',samplingGrid, fs); 0105 0106 %Apply diffuse field compensation 0107 testSOFA = SOFAhrtf2dtf(testSOFA); 0108 refSOFA = SOFAhrtf2dtf(refSOFA); 0109 0110 %% (3) - Run model baumgartner2014 0111 0112 disp('Running model according to Baumgartner2014...'); 0113 0114 qe_pe_test = baumgartner2014(testSOFA, testSOFA, 'QE_PE_EB', 'S', S, 'lat', lat, ... 0115 'fs', fs, 'fsstim', fs); 0116 qe_pe_ref = baumgartner2014(refSOFA, refSOFA, 'QE_PE_EB', 'S', S, 'lat', lat, ... 0117 'fs', fs, 'fsstim', fs); 0118 qe_pe_testVSref = baumgartner2014(testSOFA, refSOFA, 'QE_PE_EB', 'S', S, 'lat', lat, ... 0119 'fs', fs, 'fsstim', fs); 0120 0121 qe_diff = qe_pe_ref.qe - qe_pe_testVSref.qe; 0122 pe_diff = qe_pe_ref.pe - qe_pe_testVSref.pe; 0123 0124 %% (4) - Write results struct 0125 0126 results.qe_test = qe_pe_test.qe; 0127 results.pe_test = qe_pe_test.pe; 0128 results.qe_ref = qe_pe_ref.qe; 0129 results.pe_ref = qe_pe_ref.pe; 0130 results.qe_testVSref = qe_pe_testVSref.qe; 0131 results.pe_testVSref = qe_pe_testVSref.pe; 0132 results.qe_diff = qe_diff; 0133 results.pe_diff = pe_diff; 0134 results.samplingGrid = samplingGrid; 0135 results.S = S; 0136 results.lat = [lat, 180-lat]; 0137 0138 disp('Done with sagittal plane localization test...'); 0139 0140 %% (5) - Print results 0141 0142 if printResults 0143 fprintf('\nRESULTS \n'); 0144 disp('------------------------------------------------------'); 0145 fprintf('Quadrant errors testHRTFdataset (%%) \t\t %4.1f \n',results.qe_test) 0146 fprintf('Local polar RMS error testHRTFdataset (deg) \t %4.1f \n',results.pe_test) 0147 disp('------------------------------------------------------'); 0148 fprintf('Quadrant errors referenceHRTFdataset (%%) \t %4.1f \n',results.qe_ref) 0149 fprintf('Local polar RMS error referenceHRTFdataset (deg) %4.1f \n',results.pe_ref) 0150 disp('------------------------------------------------------'); 0151 fprintf('Quadrant errors testVSreference (%%) \t\t %4.1f \n',results.qe_testVSref) 0152 fprintf('Local polar RMS error testVSreference (deg) \t %4.1f \n',results.pe_testVSref) 0153 disp('------------------------------------------------------'); 0154 fprintf('Quadrant errors difference (%%) \t\t\t %4.1f \n',results.qe_diff) 0155 fprintf('Local polar RMS error difference (deg) \t\t %4.1f \n',results.pe_diff) 0156 disp('------------------------------------------------------'); 0157 end 0158 0159 end 0160