Home > SUpDEq-v5.0.0 > supdeq_shiftDistance.m

supdeq_shiftDistance

PURPOSE ^

% SUpDEq - Spatial Upsampling by Directional Equalization

SYNOPSIS ^

function [shiftedHRTF_L,shiftedHRTF_R] = supdeq_shiftDistance(startingHRTF_L, startingHRTF_R, startingDistance, targetDistance, targetDirection, headRadius, fs, c)

DESCRIPTION ^

% SUpDEq - Spatial Upsampling by Directional Equalization

 function [shiftedHRTF_L,shiftedHRTF_R] = supdeq_shiftDistance(startingHRTF_L, startingHRTF_R, startingDistance, targetDistance, targetDirection, headRadius, fs, c)

 This function performs a shifts HRTFs in distance considering a spherical head model

 Output:
 shiftedHRTF_L / R     - HRTFs shifted / adapted in distance

 Input:        
 startingHRTF_L / R    - Input HRTFs to be shifted / adapted in distance
 startingDistance:     - Distance at which the datasets were measured
 targetDistance:       - Distance to which the datasets are shifted / adapted
 targetDirection:      - Direction of the target (spatial sampling grid, 
                         Qx2 matrix with azimuth and elevation) in degree.
 headRadius:           - Radius of the spherical head model. For details
                         refer to AKsphericalHead.
 fs                    - Sampling rate in Hz
                         Default: 48000
 c                     - Speed of sound in m/s
                         Default: 343

 Dependencies: AKTools
   
 (C) 2019 by CP,  Christoph Pörschmann
             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 [shiftedHRTF_L,shiftedHRTF_R] = supdeq_shiftDistance(startingHRTF_L, startingHRTF_R, startingDistance, targetDistance, targetDirection, headRadius, fs, c)
0004 %
0005 % This function performs a shifts HRTFs in distance considering a spherical head model
0006 %
0007 % Output:
0008 % shiftedHRTF_L / R     - HRTFs shifted / adapted in distance
0009 %
0010 % Input:
0011 % startingHRTF_L / R    - Input HRTFs to be shifted / adapted in distance
0012 % startingDistance:     - Distance at which the datasets were measured
0013 % targetDistance:       - Distance to which the datasets are shifted / adapted
0014 % targetDirection:      - Direction of the target (spatial sampling grid,
0015 %                         Qx2 matrix with azimuth and elevation) in degree.
0016 % headRadius:           - Radius of the spherical head model. For details
0017 %                         refer to AKsphericalHead.
0018 % fs                    - Sampling rate in Hz
0019 %                         Default: 48000
0020 % c                     - Speed of sound in m/s
0021 %                         Default: 343
0022 %
0023 % Dependencies: AKTools
0024 %
0025 % (C) 2019 by CP,  Christoph Pörschmann
0026 %             JMA, Johannes M. Arend
0027 %             TH Köln - University of Applied Sciences
0028 %             Institute of Communications Engineering
0029 %             Department of Acoustics and Audio Signal Processing
0030 
0031 function [shiftedHRTF_L,shiftedHRTF_R] = supdeq_shiftDistance(startingHRTF_L, startingHRTF_R, startingDistance, targetDistance, targetDirection, headRadius, fs, c)
0032 
0033 if nargin < 7 || isempty(fs)
0034     fs = 48000;
0035 end
0036 
0037 if nargin < 8 || isempty(c)
0038     c = 343;
0039 end
0040 
0041 %Generate sampling grid with distance information based on targetDirection
0042 %and startingDistance/targetDistance
0043 sg=[targetDirection(1),90-targetDirection(2),startingDistance;targetDirection(1),90-targetDirection(2),targetDistance];
0044 %Define symmetrical ear position of spherical head model
0045 ear=[90 0];
0046 
0047 %Get respective spherical head impulse responses for starting and target distance
0048 hDistances=AKsphericalHead(sg,ear,false,headRadius,sg(1,3),100,length(startingHRTF_L)*2-2,fs,c);
0049 
0050 %Get distance variation functions for left and right ear
0051 H_L=fft(squeeze(hDistances(:,2,1)))./fft(squeeze(hDistances(:,1,1)));
0052 H_R=fft(squeeze(hDistances(:,2,2)))./fft(squeeze(hDistances(:,1,2)));
0053 
0054 %Get rid of mirror spectrum
0055 H_L=H_L(1:length(startingHRTF_L)).';
0056 H_R=H_R(1:length(startingHRTF_R)).';
0057 
0058 %Apply distance variation functions to HRTFs
0059 shiftedHRTF_L=H_L.*startingHRTF_L;
0060 shiftedHRTF_R=H_R.*startingHRTF_R;
0061         
0062 end
0063

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