Home > SUpDEq-v5.0.0 > supdeq_demo_ALFE.m

supdeq_demo_ALFE

PURPOSE ^

% SUpDEq - Spatial Upsampling by Directional Equalization

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

% SUpDEq - Spatial Upsampling by Directional Equalization
  
 script supdeq_demo_ALFE

 This script shows how the ALFE (Adaptive Low Frequency Extention)
 algorithm can be applied in combination with SUpDEq.

 Reference:
 C. Pörschmann and J. M. Arend, "Obtaining Dense HRTF Sets from Sparse 
 Measurements in Reverberant Environments," in Proceedings of the 
 AES International Conference on Immersive and Interactive Audio, 
 York, UK, 2019, pp. 1?10.

 (C) 2019 by JMA, Johannes M. Arend
             CP, Christoph Pörschmann 
             Technische Hochschule Köln
             University of Applied Sciences
             Institute of Communications Engineering
             Department of Acoustics and Audio Signal Processing

% (1) - Load reference HRTF dataset (stored as SH-coefficients in spherical harmonics domain)
See publication for more info about the measurement setup of the reference HRTF dataset.
The reference dataset is only needed for comparison with the final de-equalized dataset...

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% SUpDEq - Spatial Upsampling by Directional Equalization
0002 %
0003 % script supdeq_demo_ALFE
0004 %
0005 % This script shows how the ALFE (Adaptive Low Frequency Extention)
0006 % algorithm can be applied in combination with SUpDEq.
0007 %
0008 % Reference:
0009 % C. Pörschmann and J. M. Arend, "Obtaining Dense HRTF Sets from Sparse
0010 % Measurements in Reverberant Environments," in Proceedings of the
0011 % AES International Conference on Immersive and Interactive Audio,
0012 % York, UK, 2019, pp. 1?10.
0013 %
0014 % (C) 2019 by JMA, Johannes M. Arend
0015 %             CP, Christoph Pörschmann
0016 %             Technische Hochschule Köln
0017 %             University of Applied Sciences
0018 %             Institute of Communications Engineering
0019 %             Department of Acoustics and Audio Signal Processing
0020 %
0021 %% (1) - Load reference HRTF dataset (stored as SH-coefficients in spherical harmonics domain)
0022 %See publication for more info about the measurement setup of the reference HRTF dataset.
0023 %The reference dataset is only needed for comparison with the final de-equalized dataset...
0024 referenceHRTFdataset = importdata('RAR_HRIR_1m_Genelec_2702SFD.mat');
0025 
0026 %% (2) - Load sparse HRTF dataset (stored as FFT-bins in Fourier domain)
0027 %See publication for more info about the measurement setup of the sparse HRTF dataset.
0028 load('ZW8_3_HRIR_1m_Genelec_sp_L86.mat');
0029 
0030 %% (3) - Get equalization dataset (SH-coefficients)
0031 %The eqDataset describes the sound pressure distribution on a sphere
0032 %Use defaults: N = 35, earDistance = 0.165m, NFFT = 512, fs = 48000;
0033 NFFT=(length(sparseHRTFdataset.HRTF_L(1,:))-1)*2;
0034 eqDataset = supdeq_getEqDataset(35,0.165,NFFT,48000);
0035 
0036 %% (4) - Perform equalization
0037 %Here, the sparse HRTF dataset is equalized with the eqDataset. The
0038 %equalized HRTF are transformed to the spherical harmonics domain again with
0039 %the maximal order N which is possible with the sparse sampling grid.
0040 %N and the sparse sampling grid are part of the sparseHRTFdataset struct
0041 sparseSamplingGrid = sparseHRTFdataset.samplingGrid;
0042 Nsparse = sparseHRTFdataset.Nmax;
0043 
0044 eqHRTFdataset = supdeq_eq(sparseHRTFdataset,eqDataset,Nsparse,sparseSamplingGrid);
0045 
0046 %% (4a) - Perform ALFE - If desired
0047 %In this section the lower frequency components below e certain frequency
0048 %xover are replaced by a frequecy-shaped dirac. The ALFE algorithm is done
0049 %on the equalized dataset in order to benefit from the constant frequency
0050 %response towards low frequencies.
0051 xover = [500 750];
0052 fs = 48000;
0053 [eqHRTFdataset_ALFE] = supdeq_alfe(eqHRTFdataset,sparseHRTFdataset.samplingGrid,xover,fs);
0054 eqHRTFdataset=eqHRTFdataset_ALFE;  
0055 
0056 %% (5) - Perform de-equalization
0057 %Here, the sparse equalized HRTF dataset is de-equalized with the
0058 %deqDataset. This is done on a dense spatial sampling grid. The results is a
0059 %dense HRTF/HRIR dataset. In this case, deqDataset is the same as the
0060 %eqDataset...
0061 
0062 %First, define dense spatial sampling grid. Here, we use the lebedev grid
0063 %with 2702 points again (same as the reference HRIR dataset).
0064 %The highest stable grid order here is N = 44. However, we use N = 35 for the
0065 %spherical Fourier transform of the de-equalized HRTFs.
0066 denseSamplingGrid = supdeq_lebedev(2702);
0067 Ndense = 35;
0068 
0069 %Perform de-equalization. Apply head and tail window (8 and 32 samples
0070 %respectively) to de-equalized HRIRs/HRTFs.
0071 [denseHRTFdataset, denseHRIRdataset, denseHRTFdataset_sh] = supdeq_deq(eqHRTFdataset, eqDataset, Ndense, denseSamplingGrid,[8,32]);
0072 
0073 %% (6) - Optional: Save as SOFA object
0074 %Use defaults: fs = 48000, earDistance = 0.165m, sourceDistance = 3.0m
0075 %denseHRIRdataset_SOFA = supdeq_writeSOFAobj(denseHRIRdataset.HRIR_L,denseHRIRdataset.HRIR_R,denseSamplingGrid);
0076 
0077 %% (6a) - Optional: Save SH coefficients
0078 save ('denseHRTFdataset_JBL_L2702.mat', 'denseHRTFdataset_sh')
0079 
0080 %% (7) - Optional: Plot HRIRs
0081 %Get HRIRs from reference dataset and de-equalized dense dataset. In this
0082 %example, we chose a lateral source, because most differences between the
0083 %reference and the de-equalized HRIRs occure at the contralateral ear.
0084 azPlot = 180;
0085 elPlot = 90;
0086 
0087 [hrir_ref(:,1),hrir_ref(:,2)] = supdeq_getArbHRIR(referenceHRTFdataset,[azPlot,elPlot],'DEG',2,'ak');
0088 [hrir_deq(:,1),hrir_deq(:,2)] = supdeq_getArbHRIR(denseHRTFdataset_sh,[azPlot,elPlot],'DEG',2,'ak');
0089 
0090 supdeq_plotIR(hrir_ref(:,2),hrir_deq(:,2),[],[],1);
0091 
0092 %% (8) - Optional: Listen to the results
0093 %Here, you can listen to a short drums sequence, spatialized with a
0094 %reference HRIR and a de-equalized HRIR
0095 
0096 %Load drums test signal
0097 [testSignal,fsTestSignal] = audioread('drums.wav');
0098 
0099 %Define az and el for playback
0100 azPlayback = 270;
0101 elPlayback = 90;
0102 
0103 %Convolve with reference HRIR and play back
0104 supdeq_listen(referenceHRTFdataset,testSignal,[azPlayback,elPlayback]);
0105 %Wait for length of test-signal
0106 pause(length(testSignal)/fsTestSignal+0.1);
0107 %Convolve with de-equalized HRIR and play back
0108 supdeq_listen(denseHRTFdataset_sh,testSignal,[azPlayback,elPlayback]);
0109 
0110 %% (9) - Optional: Technical Evaluation
0111 
0112 %Perform test of sagittal plane localization with default spatial sampling
0113 %grid
0114 spLocalization = supdeq_testSPlocalization(denseHRTFdataset_sh, referenceHRTFdataset);
0115 
0116 %Perform test of horizontal plane localizatoin with default spatial
0117 %sampling grid
0118 hpLocalization = supdeq_testHPlocalization(denseHRTFdataset_sh, referenceHRTFdataset);
0119 
0120 %Calculate spectral differences with default spatial sampling grid and
0121 %make simple plot
0122 specDifferences = supdeq_calcSpectralDifference(denseHRTFdataset_sh, referenceHRTFdataset,[],[],false,true);
0123 
0124 %Calculate spectral differences in auditory bands with default spatial
0125 %sampling grid and make simple plot
0126 specDifferences_auditoryBands = supdeq_calcSpectralDifference(denseHRTFdataset_sh, referenceHRTFdataset,[],[],true,true);
0127 
0128 %Calculate energy per order N and make simple plot
0129 energyPerOrder = supdeq_calcEnergyPerOrder(denseHRTFdataset_sh,true);

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