Home > SUpDEq-v5.0.0 > supdeq_getArbHRTF.m

supdeq_getArbHRTF

PURPOSE ^

% SUpDEq - Spatial Upsampling by Directional Equalization

SYNOPSIS ^

function [HRTF_L, HRTF_R] = supdeq_getArbHRTF(HRIRs_sfd,samplingGrid,mode,channel,transformCore)

DESCRIPTION ^

% SUpDEq - Spatial Upsampling by Directional Equalization

 function [HRTF_L, HRTF_R] = supdeq_getArbHRTF(HRIRs_sfd,samplingGrid,mode,channel,transformCore)

 This function returns a HRTF (separately for the left/right ear) for an 
 arbitrary direction, based on interpolation in the SH-domain and inverse 
 spherical Fourier transform.

 Output:
 HRTF_L / R    - Result of ISFT in Fourier domain (single-sided complex
                 spectrum). HRTF for L/R channel at each spatial sampling point

 Input:
 HRIRs_sfd     - Struct with HRIRs in spatial Fourier domain (sfd) / SH-domain
 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'

 Dependencies: SOFiA toolbox, AKtools

 Reference: 
 Bernschütz, B. (2016). Microphone Arrays and Sound Field Decomposition 
                        for Dynamic Binaural Recording. TU Berlin.

 (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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% SUpDEq - Spatial Upsampling by Directional Equalization
0002 %
0003 % function [HRTF_L, HRTF_R] = supdeq_getArbHRTF(HRIRs_sfd,samplingGrid,mode,channel,transformCore)
0004 %
0005 % This function returns a HRTF (separately for the left/right ear) for an
0006 % arbitrary direction, based on interpolation in the SH-domain and inverse
0007 % spherical Fourier transform.
0008 %
0009 % Output:
0010 % HRTF_L / R    - Result of ISFT in Fourier domain (single-sided complex
0011 %                 spectrum). HRTF for L/R channel at each spatial sampling point
0012 %
0013 % Input:
0014 % HRIRs_sfd     - Struct with HRIRs in spatial Fourier domain (sfd) / SH-domain
0015 % samplingGrid  - Spatial sampling grid (Q x 2 matrix), where the first
0016 %                 column holds the azimuth and the second the
0017 %                 elevation (both in degree).
0018 %                 Azimuth in degree (0=front, 90=left, 180=back, 270=right)
0019 %                 (0 points to positive x-axis, 90 to positive y-axis)
0020 %                 Elevations in degree (0=North Pole, 90=front, 180=South Pole)
0021 %                 (0 points to positive z-axis, 180 to negative z-axis)
0022 % mode          - 'DEG' or 'RAD' (radiant or degree).
0023 %                 Default: 'DEG'
0024 % channel       - Integer with 0, 1, or 2
0025 %                 0 - Only left channel
0026 %                 1 - Only right channel
0027 %                 Default: 2 - Both channels (stereo)
0028 % transformCore - String to define method to be used for the inverse
0029 %                 spherical Fourier transform.
0030 %                 'sofia - sofia_itc from SOFiA toolbox
0031 %                 'ak'   - AKisht from AKtools
0032 %                 The results are exactly the same, but AKisht is faster
0033 %                 with big sampling grids
0034 %                 Default: 'sofia'
0035 %
0036 % Dependencies: SOFiA toolbox, AKtools
0037 %
0038 % Reference:
0039 % Bernschütz, B. (2016). Microphone Arrays and Sound Field Decomposition
0040 %                        for Dynamic Binaural Recording. TU Berlin.
0041 %
0042 % (C) 2018 by JMA, Johannes M. Arend
0043 %             TH Köln - University of Applied Sciences
0044 %             Institute of Communications Engineering
0045 %             Department of Acoustics and Audio Signal Processing
0046 
0047 function [HRTF_L, HRTF_R] = supdeq_getArbHRTF(HRIRs_sfd,samplingGrid,mode,channel,transformCore)
0048 
0049 if nargin < 3 || isempty(mode)
0050     mode = 'DEG';
0051 end
0052 
0053 if nargin < 4 || isempty(channel)
0054     channel = 2;
0055 end
0056 
0057 if nargin < 5 || isempty(transformCore)
0058     transformCore = 'sofia';
0059 end
0060 
0061 %Get angles
0062 az = samplingGrid(:,1);
0063 el = samplingGrid(:,2);
0064 
0065 %SOFiA needs RAD
0066 if strcmp(transformCore,'sofia')
0067     if strcmp(mode,'DEG')
0068         az = az*pi/180;
0069         el = el*pi/180;
0070     end
0071 end
0072 
0073 %AK needs DEG
0074 if strcmp(transformCore,'ak')
0075     if strcmp(mode,'RAD')
0076         az = az*180/pi;
0077         el = el*180/pi;
0078     end
0079 end
0080 
0081 %Check range
0082 if sum(az < 0) > 0 || sum(el < 0) > 0
0083     error('Only positive azimuth/elevation values allowed!');
0084 end
0085 
0086 %% Perform transform with sofia_itc
0087 
0088 if strcmp(transformCore,'sofia')
0089     %Perform inverse spherical Fourier transform
0090     if channel == 0 %Only left channel
0091 
0092         HRTF_L = sofia_itc(HRIRs_sfd.Hl_nm, [az el]);
0093         HRTF_R = nan;
0094 
0095     elseif channel == 1 %Only right channel
0096 
0097         HRTF_L = nan;
0098         HRTF_R = sofia_itc(HRIRs_sfd.Hr_nm, [az el]);
0099 
0100     elseif channel == 2 %Default - Stereo
0101 
0102         HRTF_L = sofia_itc(HRIRs_sfd.Hl_nm, [az el]);
0103         HRTF_R = sofia_itc(HRIRs_sfd.Hr_nm, [az el]);
0104 
0105     end
0106 end
0107 
0108 %% Perform transform with AKisht
0109 
0110 if strcmp(transformCore,'ak')
0111     %Perform inverse spherical Fourier transform
0112     if channel == 0 %Only left channel
0113 
0114         HRTF_L = AKisht(HRIRs_sfd.Hl_nm,false,[az el],'complex');
0115         HRTF_L = HRTF_L.';
0116         HRTF_R = nan;
0117 
0118     elseif channel == 1 %Only right channel
0119 
0120         HRTF_L = nan;
0121         HRTF_R = AKisht(HRIRs_sfd.Hr_nm,false,[az el],'complex');
0122         HRTF_R = HRTF_R.';
0123 
0124     elseif channel == 2 %Default - Stereo
0125 
0126         HRTF_L = AKisht(HRIRs_sfd.Hl_nm,false,[az el],'complex');
0127         HRTF_L = HRTF_L.';
0128         HRTF_R = AKisht(HRIRs_sfd.Hr_nm,false,[az el],'complex');
0129         HRTF_R = HRTF_R.';
0130 
0131     end
0132 end
0133 
0134 end
0135 
0136 
0137 
0138

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