Commit 8ce469d7 authored by michael.kohnen's avatar michael.kohnen
Browse files

Merge branch 'ita_3da_dev'

parents adeb5415 5ee5fc9f
function [ CS_L CS_R ] = ita_ctc_channelSeparation(HRTF_real, CTCFilter, varargin) function [ CS_L CS_R CS_L_singleSpectrum CS_R_singleSpectrum ] = ita_ctc_channelSeparation(HRTF_real, CTCFilter, varargin)
%ITA_CTC_CHANNELSEPARATION Returns and plots channelseparation for ctc %ITA_CTC_CHANNELSEPARATION Returns and plots channelseparation for ctc
%systems %systems
% HRTF_real represent the real HRTFs that will occure in the CTC system, % HRTF_real represent the real HRTFs that will occure in the CTC system,
...@@ -15,7 +15,9 @@ function [ CS_L CS_R ] = ita_ctc_channelSeparation(HRTF_real, CTCFilter, varargi ...@@ -15,7 +15,9 @@ function [ CS_L CS_R ] = ita_ctc_channelSeparation(HRTF_real, CTCFilter, varargi
% [LS3_left_CTCFilter LS3_right_CTCFilter] % [LS3_left_CTCFilter LS3_right_CTCFilter]
% ... % ...
% %
opts.naturalCS = true; % TODO: Frequency ranges
opts.naturalCS = false;
opts.doubleSpectrum = true; opts.doubleSpectrum = true;
opts.singleSpectrum = true; opts.singleSpectrum = true;
opts.plot = true; opts.plot = true;
...@@ -23,13 +25,14 @@ opts.plot = true; ...@@ -23,13 +25,14 @@ opts.plot = true;
opts=ita_parse_arguments(opts, varargin); opts=ita_parse_arguments(opts, varargin);
hrtf=ita_merge(HRTF_real(:)); hrtf=ita_merge(HRTF_real(:));
hrtf.signalType='energy';
L=itaAudio; L=itaAudio;
L.signalType='energy';
helper=ita_convolve(hrtf.ch(1),CTCFilter(1)); helper=ita_convolve(hrtf.ch(1),CTCFilter(1));
numSamples=helper.nSamples; numSamples=helper.nSamples;
%% Left channel input %% Left channel input
L.time=zeros(numSamples,hrtf.nChannels/2); L.time=zeros(numSamples,1);
R=L; R=L;
for k=1:size(CTCFilter,1) for k=1:size(CTCFilter,1)
L=L+ita_convolve(hrtf.ch(2*k-1),CTCFilter(k,1)); L=L+ita_convolve(hrtf.ch(2*k-1),CTCFilter(k,1));
...@@ -38,7 +41,7 @@ end ...@@ -38,7 +41,7 @@ end
CS_L = ita_merge(L,R); CS_L = ita_merge(L,R);
%% Right channel input %% Right channel input
L.time=zeros(numSamples,hrtf.nChannels/2); L.time=zeros(numSamples,1);
R=L; R=L;
for k=1:size(CTCFilter,1) for k=1:size(CTCFilter,1)
L=L+ita_convolve(hrtf.ch(2*k-1),CTCFilter(k,2)); L=L+ita_convolve(hrtf.ch(2*k-1),CTCFilter(k,2));
...@@ -47,29 +50,46 @@ end ...@@ -47,29 +50,46 @@ end
CS_R = ita_merge(L,R); CS_R = ita_merge(L,R);
%% Bruno Diss p 83 (5-11) %% Bruno Diss p 83 (5-11)
CS_L_singleSpectrum = ita_divide_spk(CS_L.ch(1),CS_L.ch(2)); if opts.singleSpectrum
CS_R_singleSpectrum = ita_divide_spk(CS_R.ch(2),CS_R.ch(1)); CS_L_singleSpectrum = ita_divide_spk(CS_L.ch(1),CS_L.ch(2));
CS_R_singleSpectrum = ita_divide_spk(CS_R.ch(2),CS_R.ch(1));
CS_L_value end
%% Natural channel separation %% Natural channel separation
if opts.naturalCS if opts.naturalCS
for k=1:2:hrtf.nChannels [ natCS_L natCS_R ] =ita_ctc_channelSeparation_naturalOptimum(hrtf);
if hrtf.ch(k).rms>hrtf.ch(k+1).rms
naturalCS(ceil(k/2))=ita_divide_spk(hrtf.ch(k),hrtf.ch(k+1));
else
naturalCS(ceil(k/2))=ita_divide_spk(hrtf.ch(k+1),hrtf.ch(k));
end
end
end end
%% Plot %% Plot
if opts.plot if opts.plot
if opts.singleSpectrum
CS_L.pf; CS_R.pf;
end
if opts.doubleSpectrum if opts.doubleSpectrum
CS_L_singleSpectrum.pf; CS_L.pf; legend({'Left in, left ear' 'Left in, right ear'});
CS_R_singleSpectrum.pf; title('Channel separation - left ear');
set(gcf,'name','Channel separation - left ear');
CS_R.pf; legend({'Right in, left ear' 'Right in, right ear'});
title('Channel separation - right ear');
set(gcf,'name','Channel separation - right ear');
end
if opts.singleSpectrum && opts.naturalCS
merged_CS_L=ita_merge(natCS_L,CS_L_singleSpectrum);
merged_CS_R=ita_merge(natCS_R,CS_R_singleSpectrum);
merged_CS_L.pf; legend({'Optimal natural CS for left in' 'CTC CS for left in' });
title('Channel separation - left ear (natural vs CTC)');
set(gcf,'name','Channel separation - left ear');
merged_CS_R.pf; legend({'Optimal natural CS for right in' 'CTC CS for right in' });
title('Channel separation - right ear (natural vs CTC)');
set(gcf,'name','Channel separation - right ear');
elseif opts.singleSpectrum
merged_CS = ita_merge(CS_L_singleSpectrum, CS_R_singleSpectrum);
merged_CS.pf;
legend({'CS for left in' 'CS for right in' });
title('Channel separation');
set(gcf,'name','Channel separation');
elseif opts.naturalCS
merged_CS = ita_merge(natCS_L, natCS_R);
merged_CS.pf;
legend({'Optimal natural CS for left in' 'Optimal natural CS for right in'});
title('Channel separation');
set(gcf,'name','Channel separation');
end end
end end
\ No newline at end of file
function [ natCS_L natCS_R ] = ita_ctc_channelSeparation_naturalOptimum(ls_HRTF)
%ITA_CTC_CHANNELSEPARATION_NATURALOPTIMUM Summary of this function goes here
% Detailed explanation goes here
hrtf=ita_merge(ls_HRTF(:));
hrtf.signalType='energy';
for idxLS=1:(hrtf.nChannels/2)
L(idxLS)=ita_divide_spk(hrtf.ch(idxLS*2-1),hrtf.ch(idxLS*2));
R(idxLS)=ita_divide_spk(hrtf.ch(idxLS*2),hrtf.ch(idxLS*2-1));
end
L=ita_merge(L(:));
R=ita_merge(R(:));
natCS_L=L.ch(1);
natCS_R=R.ch(1);
for idxF=1:numel(L.ch(1).freqData)
natCS_L.freqData(idxF)=max(abs(L.freqData(idxF,:)));
natCS_R.freqData(idxF)=max(abs(R.freqData(idxF,:)));
end
function [ CTC ] = ita_3da_ctcFilter_regularized( varargin ) function [ CTC ] = ita_ctcFilter_regularized( varargin )
%ITA_3DA_CTCFILTER_REGULARIZED Generates a set of CTC Filter for a %ITA_3DA_CTCFILTER_REGULARIZED Generates a set of CTC Filter for a
%loudspeaker system with an arbitrary number of loudspeaker. %loudspeaker system with an arbitrary number of loudspeaker.
......
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