Home > SUpDEq-v5.0.0 > supdeq_parallax.m

supdeq_parallax

PURPOSE ^

% SUpDEq - Spatial Upsampling by Directional Equalization

SYNOPSIS ^

function [samplingGridParL, samplingGridParR] = supdeq_parallax(samplingGrid, sourceDistance, radius, earPosition)

DESCRIPTION ^

% SUpDEq - Spatial Upsampling by Directional Equalization

 function [samplingGridParL, samplingGridParR] = supdeq_parallax(samplingGrid, sourceDistance, radius, earPosition) 

 This function applies parallax shifts to a (far-field) sampling grid according 
 to the source distance and the ear position, and returns the new sampling 
 grid including parallax shifts for the left and right ear.

 Output:
 samplingGridParL/R    - Parallax-shifted sampling grid for left and right ear

 Input:
 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)
 sourceDistance        - Distance (in meter) to sound source
 radius                - Head/Sphere radius in m
 earPosition           - 4 x 1 row vector describing the position of the ears in
                       spherical coordinates in degree [azL, elL, azR, elR]
                       Default: [90, 90, 270, 90] (left-right symmetrical)

 Dependencies: -

 (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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% SUpDEq - Spatial Upsampling by Directional Equalization
0002 %
0003 % function [samplingGridParL, samplingGridParR] = supdeq_parallax(samplingGrid, sourceDistance, radius, earPosition)
0004 %
0005 % This function applies parallax shifts to a (far-field) sampling grid according
0006 % to the source distance and the ear position, and returns the new sampling
0007 % grid including parallax shifts for the left and right ear.
0008 %
0009 % Output:
0010 % samplingGridParL/R    - Parallax-shifted sampling grid for left and right ear
0011 %
0012 % Input:
0013 % samplingGrid          - Spatial sampling grid (Q x 2 matrix), where the first
0014 %                       column holds the azimuth and the second the elevation (both in degree).
0015 %                       Azimuth in degree (0=front, 90=left, 180=back, 270=right)
0016 %                       (0 points to positive x-axis, 90 to positive y-axis)
0017 %                       Elevations in degree (0=North Pole, 90=front, 180=South Pole)
0018 %                       (0 points to positive z-axis, 180 to negative z-axis)
0019 % sourceDistance        - Distance (in meter) to sound source
0020 % radius                - Head/Sphere radius in m
0021 % earPosition           - 4 x 1 row vector describing the position of the ears in
0022 %                       spherical coordinates in degree [azL, elL, azR, elR]
0023 %                       Default: [90, 90, 270, 90] (left-right symmetrical)
0024 %
0025 % Dependencies: -
0026 %
0027 % (C) 2020 by JMA, Johannes M. Arend
0028 %             TH Köln - University of Applied Sciences
0029 %             Institute of Communications Engineering
0030 %             Department of Acoustics and Audio Signal Processing
0031 
0032 function [samplingGridParL, samplingGridParR] = supdeq_parallax(samplingGrid, sourceDistance, radius, earPosition)
0033 
0034 if nargin < 4 || isempty(earPosition)
0035     earPosition = [90, 90, 270, 90];
0036 end
0037 
0038 if sourceDistance < radius
0039     error('Source distance smaller than head radius!');
0040 end
0041 
0042 %% Transform sampling grid and ear positions to radiant in matlab coordinates system
0043 
0044 samplingGridRad(:,1:2) = samplingGrid(:,1:2)*pi/180;
0045 samplingGridRad(:,2) = pi/2 - samplingGridRad(:,2);
0046 
0047 earPosition_L = earPosition(1:2)*pi/180;
0048 earPosition_L(2) = pi/2 - earPosition_L(2);
0049 
0050 earPosition_R = earPosition(3:4)*pi/180;
0051 earPosition_R(2) = pi/2 - earPosition_R(2);
0052 
0053 %% Transform sampling grid and ear positions to cartesian coordinates and apply parallax shift
0054 
0055 [x,y,z] = sph2cart(samplingGridRad(:,1),samplingGridRad(:,2),sourceDistance);
0056 
0057 [x_ear_L,y_ear_L,z_ear_L] = sph2cart(earPosition_L(:,1),earPosition_L(:,2),radius); 
0058 [x_ear_R,y_ear_R,z_ear_R] = sph2cart(earPosition_R(:,1),earPosition_R(:,2),radius);  
0059 
0060 xL = x-x_ear_L;
0061 xR = x-x_ear_R;
0062 yL = y-y_ear_L;
0063 yR = y-y_ear_R;
0064 zL = z-z_ear_L;
0065 zR = z-z_ear_R;
0066 
0067 [AzParL,ElParL] = cart2sph(xL,yL,zL);
0068 [AzParR,ElParR] = cart2sph(xR,yR,zR);
0069 
0070 %% Transform back to degree in SH coordinates system
0071 
0072 AzParL = mod(AzParL,2*pi);
0073 AzParR = mod(AzParR,2*pi);
0074 AzParL = AzParL*180/pi;
0075 AzParR = AzParR*180/pi;
0076 
0077 ElParL=pi/2-ElParL;
0078 ElParR=pi/2-ElParR;
0079 ElParL = ElParL*180/pi;
0080 ElParR = ElParR*180/pi;
0081 
0082 %% Store in new samplingGrids for left and right channel
0083 
0084 samplingGridParL = [AzParL,ElParL];
0085 samplingGridParR = [AzParR,ElParR];
0086 
0087 end
0088

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