% SUpDEq - Spatial Upsampling by Directional Equalization function results = supdeq_calcEnergyPerOrder( HRTFdataset, plotResults ) This function calculates the energy of the SH-coefficients with respect to the transform order N. The function uses AKshEnergy, calculating the energy using Parseval's theorem and normalizing by 1/(4*pi). Output: results - Results struct with average energy per order N for SH-coefficients of left/right ear Input: testHRTFdataset - Struct with (SH-coefficients) of the test HRTF dataset (for example the de-equalized HRTF set or any other HRTF set like the referenceHRTFdataset) for the left (Hl_nm) and right (Hr_nm), channel/ear, absolute frequency scale f, transform order N, and FFToversize plotResults - plotResults true/false. Simple plot... Default: false Dependencies: AKtools (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_calcEnergyPerOrder( HRTFdataset, plotResults ) 0004 % 0005 % This function calculates the energy of the SH-coefficients with respect 0006 % to the transform order N. The function uses AKshEnergy, calculating 0007 % the energy using Parseval's theorem and normalizing by 1/(4*pi). 0008 % 0009 % Output: 0010 % results - Results struct with average energy per order N 0011 % for SH-coefficients of left/right ear 0012 % 0013 % Input: 0014 % testHRTFdataset - Struct with (SH-coefficients) of the test 0015 % HRTF dataset (for example the de-equalized HRTF set 0016 % or any other HRTF set like the referenceHRTFdataset) 0017 % for the left (Hl_nm) and right (Hr_nm), channel/ear, 0018 % absolute frequency scale f, transform order N, and FFToversize 0019 % plotResults - plotResults true/false. Simple plot... 0020 % Default: false 0021 % 0022 % Dependencies: AKtools 0023 % 0024 % (C) 2018 by JMA, Johannes M. Arend 0025 % TH Köln - University of Applied Sciences 0026 % Institute of Communications Engineering 0027 % Department of Acoustics and Audio Signal Processing 0028 0029 function results = supdeq_calcEnergyPerOrder( HRTFdataset, plotResults ) 0030 0031 if nargin < 2 0032 plotResults = false; 0033 end 0034 0035 %% Calculate energy for SH-coefficients of letft and right ear 0036 0037 [~,~,~,avgEperN_Hl_nm] = AKshEnergy(HRTFdataset.Hl_nm); 0038 [~,~,~,avgEperN_Hr_nm] = AKshEnergy(HRTFdataset.Hr_nm); 0039 0040 %Write results struct 0041 results.avgEperN_Hl_nm = avgEperN_Hl_nm; 0042 results.avgEperN_Hr_nm = avgEperN_Hr_nm; 0043 results.N = HRTFdataset.N; 0044 0045 %% Plot if intended 0046 0047 if plotResults 0048 figure; 0049 plot(0:results.N,10*log10(results.avgEperN_Hl_nm),'k','LineWidth',1.5); 0050 hold on; 0051 plot(0:results.N,10*log10(results.avgEperN_Hr_nm),'r','LineWidth',1.5); 0052 legend('Left','Right'); 0053 grid on; 0054 title('Total Energy per Order N') 0055 xlabel('Order N') 0056 ylabel('Energy [dB]') 0057 end 0058 0059 end 0060