% SUpDEq - Spatial Upsampling by Directional Equalization function [eqTF_L, eqTF_R] = supdeq_getEqTF(eqDataset,samplingGrid,mode,channel,transformCore,phaseOnly) This function returns an equalization transfer function (separately for the left/right ear) for an arbitrary direction, based on interpolation in the SH-domain and inverse spherical Fourier transform. Output: eqTF_L / R - Result of ISFT in Fourier domain (single-sided complex spectrum). Equalization transfer function (e.g., rigid sphere transfer function) for L/R channel at each spatial sampling point Input: eqDataset - Struct with equalization dataset as SH-coefficients. Can be the output of supdeq_getEqDataset. samplingGrid - Spatial sampling grid (Q x 2 matrix), where the first column holds the azimuth and the second the elevation (both in degree). Azimuth in degree (0=front, 90=left, 180=back, 270=right) (0 points to positive x-axis, 90 to positive y-axis) Elevations in degree (0=North Pole, 90=front, 180=South Pole) (0 points to positive z-axis, 180 to negative z-axis) mode - 'DEG' or 'RAD' (radiant or degree). Default: 'DEG' channel - Integer with 0, 1, or 2 0 - Only left channel 1 - Only right channel Default: 2 - Both channels (stereo) transformCore - String to define method to be used for the inverse spherical Fourier transform. 'sofia - sofia_itc from SOFiA toolbox 'ak' - AKisht from AKtools The results are exactly the same, but AKisht is faster with big sampling grids Default: 'sofia' phaseOnly - Set to 1 if eqTF_L/R should only contain the phase response of eqDataset (allpass-fitlers) and not the magnitude response too Default: 0 (eqTF_L/R with magnitude and phase) Dependencies: SOFiA toolbox, AKtools Reference: - (C) 2020 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 [eqTF_L, eqTF_R] = supdeq_getEqTF(eqDataset,samplingGrid,mode,channel,transformCore,phaseOnly) 0004 % 0005 % This function returns an equalization transfer function (separately for the left/right ear) 0006 % for an arbitrary direction, based on interpolation in the SH-domain and inverse 0007 % spherical Fourier transform. 0008 % 0009 % Output: 0010 % eqTF_L / R - Result of ISFT in Fourier domain (single-sided complex 0011 % spectrum). Equalization transfer function (e.g., 0012 % rigid sphere transfer function) for L/R channel at each 0013 % spatial sampling point 0014 % 0015 % Input: 0016 % eqDataset - Struct with equalization dataset as SH-coefficients. 0017 % Can be the output of supdeq_getEqDataset. 0018 % samplingGrid - Spatial sampling grid (Q x 2 matrix), where the first 0019 % column holds the azimuth and the second the 0020 % elevation (both in degree). 0021 % Azimuth in degree (0=front, 90=left, 180=back, 270=right) 0022 % (0 points to positive x-axis, 90 to positive y-axis) 0023 % Elevations in degree (0=North Pole, 90=front, 180=South Pole) 0024 % (0 points to positive z-axis, 180 to negative z-axis) 0025 % mode - 'DEG' or 'RAD' (radiant or degree). 0026 % Default: 'DEG' 0027 % channel - Integer with 0, 1, or 2 0028 % 0 - Only left channel 0029 % 1 - Only right channel 0030 % Default: 2 - Both channels (stereo) 0031 % transformCore - String to define method to be used for the inverse 0032 % spherical Fourier transform. 0033 % 'sofia - sofia_itc from SOFiA toolbox 0034 % 'ak' - AKisht from AKtools 0035 % The results are exactly the same, but AKisht is faster 0036 % with big sampling grids 0037 % Default: 'sofia' 0038 % phaseOnly - Set to 1 if eqTF_L/R should only contain the phase response 0039 % of eqDataset (allpass-fitlers) and not the magnitude response too 0040 % Default: 0 (eqTF_L/R with magnitude and phase) 0041 % 0042 % Dependencies: SOFiA toolbox, AKtools 0043 % 0044 % Reference: - 0045 % 0046 % (C) 2020 by JMA, Johannes M. Arend 0047 % TH Köln - University of Applied Sciences 0048 % Institute of Communications Engineering 0049 % Department of Acoustics and Audio Signal Processing 0050 0051 function [eqTF_L, eqTF_R] = supdeq_getEqTF(eqDataset,samplingGrid,mode,channel,transformCore,phaseOnly) 0052 0053 if nargin < 3 || isempty(mode) 0054 mode = 'DEG'; 0055 end 0056 0057 if nargin < 4 || isempty(channel) 0058 channel = 2; 0059 end 0060 0061 if nargin < 5 || isempty(transformCore) 0062 transformCore = 'sofia'; 0063 end 0064 0065 if nargin < 6 || isempty(phaseOnly) 0066 phaseOnly = 0; 0067 end 0068 0069 %Get angles 0070 az = samplingGrid(:,1); 0071 el = samplingGrid(:,2); 0072 0073 %SOFiA needs RAD 0074 if strcmp(transformCore,'sofia') 0075 if strcmp(mode,'DEG') 0076 az = az*pi/180; 0077 el = el*pi/180; 0078 end 0079 end 0080 0081 %AK needs DEG 0082 if strcmp(transformCore,'ak') 0083 if strcmp(mode,'RAD') 0084 az = az*180/pi; 0085 el = el*180/pi; 0086 end 0087 end 0088 0089 %Check range 0090 if sum(az < 0) > 0 || sum(el < 0) > 0 0091 error('Only positive azimuth/elevation values allowed!'); 0092 end 0093 0094 %% Perform transform 0095 0096 %Transform eqDataset to Fourier domain at sparse sampling grid points 0097 %(inverse spherical Fourier transform) 0098 [eqTF_L,eqTF_R] = supdeq_getArbHRTF(eqDataset,samplingGrid,mode,channel,transformCore); 0099 0100 if phaseOnly 0101 %fprintf('Phase only eqTFs...\n') 0102 %Get only phase response of eqTF 0103 eqTF_L_phase = angle(eqTF_L); 0104 eqTF_R_phase = angle(eqTF_R); 0105 eqTF_L_mag = ones(size(eqTF_L,1),size(eqTF_L,2)); 0106 eqTF_R_mag = ones(size(eqTF_R,1),size(eqTF_R,2)); 0107 eqTF_L = eqTF_L_mag.*exp(1i*eqTF_L_phase); 0108 eqTF_R = eqTF_R_mag.*exp(1i*eqTF_R_phase); 0109 end 0110 0111 end 0112 0113 0114 0115