% SUpDEq - Spatial Upsampling by Directional Equalization script get_sparse_HRTF_set_Gauss Just a small script to show how to get a sparse HRTF dataset based on the reference HRTF dataset 'HRIRs_sfd_Nx' or 'HRIRs_NF150_sfd_Nx'. Field sourceDistance is used if available. Important for DVF (distance variation function) processing with 'HRIRs_NFxxx' as reference. (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 % script get_sparse_HRTF_set_Gauss 0004 % 0005 % Just a small script to show how to get a sparse HRTF dataset based on the 0006 % reference HRTF dataset 'HRIRs_sfd_Nx' or 'HRIRs_NF150_sfd_Nx'. 0007 % Field sourceDistance is used if available. Important for DVF (distance 0008 % variation function) processing with 'HRIRs_NFxxx' as reference. 0009 % 0010 % (C) 2018 by JMA, Johannes M. Arend 0011 % TH Köln - University of Applied Sciences 0012 % Institute of Communications Engineering 0013 % Department of Acoustics and Audio Signal Processing 0014 0015 %% 0016 clear all; 0017 %Load reference dataset 0018 referenceHRTFdataset = importdata('HRIRs_sfd_N35.mat'); 0019 0020 %Simply do subsampling of the referenceHRTFdataset 0021 %Define spatial order 0022 nSparse = 35; 0023 %Get sparse sampling grid 0024 [sparseGrid, ~, NmaxSparse] = supdeq_equiangular(nSparse); 0025 0026 %% Create HRTF dataset as mat file (for internal use) 0027 %Get HRTFs from referenceHRTFdataset 0028 [sparseHRTFdataset.HRTF_L, sparseHRTFdataset.HRTF_R] = supdeq_getArbHRTF(referenceHRTFdataset,sparseGrid); 0029 %Fill struct with additional info 0030 sparseHRTFdataset.f = referenceHRTFdataset.f; 0031 sparseHRTFdataset.Nmax = NmaxSparse; 0032 sparseHRTFdataset.FFToversize = referenceHRTFdataset.FFToversize; 0033 sparseHRTFdataset.samplingGrid = sparseGrid; 0034 if isfield(referenceHRTFdataset,'sourceDistance') 0035 sparseHRTFdataset.sourceDistance = referenceHRTFdataset.sourceDistance; 0036 end 0037 0038 % Save as mat file 0039 fileName = ['sparseHRTFdataset_E',num2str(nSparse)]; 0040 save(fileName,'sparseHRTFdataset') 0041 0042 %% Create HRIR dataset in SOFA format (for standardized input format) 0043 %Get HRIRs from referenceHRTFdataset 0044 [sparseHRIRdataset.HRIR_L, sparseHRIRdataset.HRIR_R] = supdeq_getArbHRIR(referenceHRTFdataset,sparseGrid); 0045 % Write SOFA object 0046 if isfield(referenceHRTFdataset,'sourceDistance') 0047 %Get source distance if is field 0048 sparseHRIRdataset_SOFA = supdeq_writeSOFAobj(sparseHRIRdataset.HRIR_L',sparseHRIRdataset.HRIR_R',sparseGrid(:,1:2),[],[],referenceHRTFdataset.sourceDistance); 0049 else 0050 % %Use defaults: fs = 48000, earDistance = 0.165m, sourceDistance = 3.0m 0051 sparseHRIRdataset_SOFA = supdeq_writeSOFAobj(sparseHRIRdataset.HRIR_L',sparseHRIRdataset.HRIR_R',sparseGrid(:,1:2)); 0052 end 0053 0054 % Save as SOFA file 0055 fileName = ['sparseHRIRdataset_E',num2str(nSparse),'.sofa']; 0056 SOFAsave(fileName,sparseHRIRdataset_SOFA)