Commit 36feb18d authored by Michael Kohnen's avatar Michael Kohnen
Browse files

Bug fixes and compensation of distances losses in reproduction methods

parent 1cc4de52
...@@ -6,6 +6,7 @@ function [ binOut ] = ita_binauralMixdown( lsSignals, varargin ) ...@@ -6,6 +6,7 @@ function [ binOut ] = ita_binauralMixdown( lsSignals, varargin )
opts.HRTF = 'D:\DATA\sciebo\MKOScripts\HRTFs\2015_ITA-Kunstkopf_HRIR_2ch_D186_1x1_256_v17.daff'; % Path to the used HRTF opts.HRTF = 'D:\DATA\sciebo\MKOScripts\HRTFs\2015_ITA-Kunstkopf_HRIR_2ch_D186_1x1_256_v17.daff'; % Path to the used HRTF
opts.LSPos = itaCoordinates; % itaCoordinates of the loudspeaker positions opts.LSPos = itaCoordinates; % itaCoordinates of the loudspeaker positions
opts.distanceLoss=true;
if nargin>1 if nargin>1
opts=ita_parse_arguments(opts,varargin); opts=ita_parse_arguments(opts,varargin);
...@@ -27,11 +28,14 @@ binOut=itaAudio; ...@@ -27,11 +28,14 @@ binOut=itaAudio;
for k=1:lsSignals.nChannels for k=1:lsSignals.nChannels
hrtf=hrtfSet.findnearestHRTF(opts.LSPos.n(k)); hrtf=hrtfSet.findnearestHRTF(opts.LSPos.n(k));
if opts.distanceLoss
hrtf=hrtf/LSPos.r(k);
end
convolved=ita_convolve(lsSignals.ch(k),hrtf); convolved=ita_convolve(lsSignals.ch(k),hrtf);
if k==1 if k==1
binOut=convolved; binOut=convolved;
else else
binOut=binOut+convolved binOut=binOut+convolved;
end end
end end
...@@ -11,7 +11,9 @@ function [ CTC ] = ita_ctcFilter_regularized( varargin ) ...@@ -11,7 +11,9 @@ function [ CTC ] = ita_ctcFilter_regularized( varargin )
% ch(4) = LS2 Right Ear % ch(4) = LS2 Right Ear
% ch(5) = LS3 Left Ear % ch(5) = LS3 Left Ear
% ... % ...
% % Make sure that the HRTFs compensate for irregular loudspeaker arrays or
% off-centered listeners.
%
% The calculation algorithm is a simple inversion. Pre- and % The calculation algorithm is a simple inversion. Pre- and
% Postprocessing options can be found below % Postprocessing options can be found below
% %
......
function [ OutputSignals ] = ita_3da_decodeAmbisonics( Bformat, LoudspeakerPos, varargin ) function [ OutputSignals ] = ita_3da_decode( Bformat, LoudspeakerPos, varargin )
%ITA_DECODEAMBISONICS Decodes a BFormat Signal in ANC with SN3D %ITA_DECODEAMBISONICS Decodes a BFormat Signal in ANC with SN3D
%normalization %normalization
% Detailed explanation goes here % Detailed explanation goes here
......
function [ audioOut ] = ita_hoa_encodeAmbisonics( audioIn, order, sourcePos ) function [ audioOut ] = ita_hoa_encode( audioIn, order, sourcePos, varargin )
%ITA_ENCODEAMBISONICS Encodes a itaAudio with channel coordinates or a %ITA_ENCODEAMBISONICS Encodes a itaAudio with channel coordinates or a
% itaCoordinate with source positions into ambisonics channels % itaCoordinate with source positions into ambisonics channels
% %
% Detailed explanation goes here % Detailed explanation goes here
%% Init %% Init
opts.distanceloss=true;
opts=ita_parse_arguments(opts,varargin);
if isa(audioIn, 'itaAudio') if isa(audioIn, 'itaAudio')
aud=true; aud=true;
elseif isa(audioIn, 'itaCoordinates') elseif isa(audioIn, 'itaCoordinates')
...@@ -49,4 +52,7 @@ if aud ...@@ -49,4 +52,7 @@ if aud
audioOut=audioOut+ita_merge(audioOut_temp); audioOut=audioOut+ita_merge(audioOut_temp);
end end
end end
end
if opts.distanceLoss
audioOut=audioOut/sourcePos.r;
end end
\ No newline at end of file
function weights = ita_3da_panVBAP(pos_LS,pos_VS) function weights = ita_3da_panVBAP(pos_LS,pos_VS,varargin)
%panVBAP - Calculate weights for VBAP %panVBAP - Calculate weights for VBAP
% %
% This function receives the position of the loudspeakers and the position % This function receives the position of the loudspeakers and the position
% of the virtual source. Both input must be given as objects of the class % of the virtual source. Both input must be given as objects of the class
% itaCoordinates. % itaCoordinates.
% %
% The output is the set of frequency independent weights used to pan the % The output is the set of frequency independent weights used to pan the
% virtual source on the given array. % virtual source on the given array.
...@@ -20,9 +20,14 @@ function weights = ita_3da_panVBAP(pos_LS,pos_VS) ...@@ -20,9 +20,14 @@ function weights = ita_3da_panVBAP(pos_LS,pos_VS)
% if pos_LS.isPlane % if pos_LS.isPlane
% Number_of_active_loudspeakers = 2; %Extended Stereo % Number_of_active_loudspeakers = 2; %Extended Stereo
% else % else
Number_of_active_loudspeakers = 3; Number_of_active_loudspeakers = 3;
% end % end
opts.dim=3; % Zwei oder Dreidimensionales panning, standard ist 3
opts.distanceloss = true;
opts.normalizationGain=1;
opts=ita_parse_arguments(opts,varargin);
% Init
weights = zeros(pos_VS.nPoints,pos_LS.nPoints); weights = zeros(pos_VS.nPoints,pos_LS.nPoints);
if pos_VS.r == 0 if pos_VS.r == 0
...@@ -33,12 +38,12 @@ end ...@@ -33,12 +38,12 @@ end
% Calculate the distance of each loudspeaker to the virtual source with the % Calculate the distance of each loudspeaker to the virtual source with the
% help of the itaCoordinate overloaded function itaCoordinate.r. % help of the itaCoordinate overloaded function itaCoordinate.r.
% To sort the distance in ascending value, use the function sort. % To sort the distance in ascending value, use the function sort.
aux = pos_LS - pos_VS; aux = pos_LS - pos_VS;
dist = aux.r; dist = aux.r;
[junk,index] = sort(dist,'ascend'); [junk,index] = sort(dist,'ascend');
index = index(1:Number_of_active_loudspeakers); index = index(1:Number_of_active_loudspeakers);
active_loudspeakers = pos_LS.n(index); active_loudspeakers = pos_LS.n(index);
%% Calculate the weights for the active loudspeakers %% Calculate the weights for the active loudspeakers
% Create a base matrix with the direction of the active loudspeakers and % Create a base matrix with the direction of the active loudspeakers and
...@@ -53,4 +58,4 @@ for idx = 1:pos_VS.nPoints ...@@ -53,4 +58,4 @@ for idx = 1:pos_VS.nPoints
g = abs(g)/norm(g); g = abs(g)/norm(g);
weights(idx,index) = g; weights(idx,index) = g;
end end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment