% SUpDEq - Spatial Upsampling by Directional Equalization function sparseHRTFdataset_dec = supdeq_dec(sparseHRTFdataset, eqDataset, targetDistance) This function performs a distance error compensation (dec) of a (sparse) HRTF set. It determines the onsets of the equalized datasets and adjusts/shifts the (sparse) dataset baset on these onsets. Output: sparseHRTFdataset_dec - Sparse HRTF dataset with shifted initial delays Input: sparseHRTFdataset - Struct with sparse HRTF dataset eqDataset: - Struct with equalization dataset (supdeq_getEqDataset) targetDistance: - Correct distance to target in m Default: 2.00m Dependencies: AKTools Reference: C. Pörschmann and J. M. Arend, ?How positioning inaccuracies influence the spatial upsampling of sparse head-related transfer function sets,? in Proceedings of the International Conference on Spatial Audio - ICSA 2019 (C) 2019 by CP, Christoph Pörschmann 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 sparseHRTFdataset_dec = supdeq_dec(sparseHRTFdataset, eqDataset, targetDistance) 0004 % 0005 % This function performs a distance error compensation (dec) of a (sparse) 0006 % HRTF set. It determines the onsets of the equalized datasets and 0007 % adjusts/shifts the (sparse) dataset baset on these onsets. 0008 % 0009 % Output: 0010 % sparseHRTFdataset_dec - Sparse HRTF dataset with shifted initial delays 0011 % 0012 % Input: 0013 % sparseHRTFdataset - Struct with sparse HRTF dataset 0014 % eqDataset: - Struct with equalization dataset 0015 % (supdeq_getEqDataset) 0016 % targetDistance: - Correct distance to target in m 0017 % Default: 2.00m 0018 % 0019 % Dependencies: AKTools 0020 % 0021 % Reference: 0022 % C. Pörschmann and J. M. Arend, ?How positioning inaccuracies influence 0023 % the spatial upsampling of sparse head-related transfer function sets,? 0024 % in Proceedings of the International Conference on Spatial Audio - ICSA 2019 0025 % 0026 % (C) 2019 by CP, Christoph Pörschmann 0027 % JMA, Johannes M. Arend 0028 % TH Köln - University of Applied Sciences 0029 % Institute of Communications Engineering 0030 % Department of Acoustics and Audio Signal Processing 0031 0032 function sparseHRTFdataset_dec = supdeq_dec(sparseHRTFdataset, eqDataset, targetDistance) 0033 0034 if nargin < 3 || isempty(targetDistance) 0035 targetDistance = 2; 0036 end 0037 0038 %Get data from eqDataset 0039 c = eqDataset.c; 0040 r = eqDataset.radius; 0041 0042 %Get data from sparseHRTFdataset and perform equalization 0043 fs = sparseHRTFdataset.f(end)*2; 0044 sparseSamplingGrid = sparseHRTFdataset.samplingGrid; 0045 Nsparse = sparseHRTFdataset.Nmax; 0046 eqHRTFdataset = supdeq_eq(sparseHRTFdataset,eqDataset,Nsparse,sparseSamplingGrid,false); 0047 0048 % Determine onsets 0049 for kk = 1:length(sparseHRTFdataset.samplingGrid(:,1)) 0050 %Get HRIRs 0051 eqHRIR_L=ifft([eqHRTFdataset.HRTF_L(kk,:) zeros(1,length(eqHRTFdataset.HRTF_L(kk,:))-2)],'symmetric'); 0052 eqHRIR_R=ifft([eqHRTFdataset.HRTF_R(kk,:) zeros(1,length(eqHRTFdataset.HRTF_R(kk,:))-2)],'symmetric'); 0053 %Determine onsets with 10 times oversampling and write in sparseHRTFdataset struct 0054 sparseHRTFdataset.onset(kk,1) = AKonsetDetect(eqHRIR_L',10,-1,'rel',[4000 fs]); 0055 sparseHRTFdataset.onset(kk,2) = AKonsetDetect(eqHRIR_R',10,-1,'rel',[4000 fs]); 0056 end 0057 %Get mean onset 0058 meanOnset = mean(mean(sparseHRTFdataset.onset)); 0059 0060 %"Normalize" onsets by substracting mean and transform to seconds 0061 sparseHRTFdataset.onset(:,1)=(sparseHRTFdataset.onset(:,1)-meanOnset)/fs; 0062 sparseHRTFdataset.onset(:,2)=(sparseHRTFdataset.onset(:,2)-meanOnset)/fs; 0063 0064 for kk = 1:length(sparseHRTFdataset.samplingGrid(:,1)) 0065 %Get "startingDistance" by adding (potential) offset/distance error to 0066 %target distance 0067 startingDistance(kk,:) = targetDistance+sparseHRTFdataset.onset(kk,:)*c; 0068 %Get targetDirection from respective sampling grid 0069 targetDirection = sparseSamplingGrid(kk,:); 0070 %Shift distance / compensate for distance errors 0071 %Use mean of left/right ear starting distance as staring distance for shift 0072 [sparseHRTFdataset.HRTF_L(kk,:),sparseHRTFdataset.HRTF_R(kk,:)] = supdeq_shiftDistance(sparseHRTFdataset.HRTF_L(kk,:),sparseHRTFdataset.HRTF_R(kk,:),mean(startingDistance(kk,:)),targetDistance,targetDirection,r,fs,c); 0073 end 0074 0075 %Save in new variable and add starting/target distance info 0076 sparseHRTFdataset_dec = sparseHRTFdataset; 0077 sparseHRTFdataset_dec.decStartingDistance = startingDistance; 0078 sparseHRTFdataset_dec.decTargetDistance = targetDistance; 0079 fprintf('Performed distance error compensation to target distance of %d m\n',targetDistance); 0080 0081 end 0082