ita_ctc_loudspeaker_signals.m 1.44 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
function LSSignals = ita_ctc_loudspeaker_signals(CTCFilter, binauralInput)
%ITA_CTC_LOUDSPEAKER_SIGNALS Combines binaural input and ctc filter to
%calculate the loudspeaker signals
% 
%   CTCFilter a multi-instance of itaAudio [ CTC-1L CTC-1R; CTC-2L CTC-2R; ...] 
%   binauralInput has to be itaAudio with 2 channels
%  
% 
%   Example: loudspeakerSignals=ita_ctc_loudspeaker_signals(CTCFilters_Calculated, BinauralSignalInput)


%% Initialization
if nargin < 2
    error('CTC:InputArguments','This function requires two input arguments.')
end

binauralInput=ita_merge(binauralInput(:));

if ~isa(binauralInput,'itaAudio') || ~isa(CTCFilter,'itaAudio')
    error('CTC:InputArguments','The input variable must be itaAudio objects.')
end


% Frequency vectors for the binaural input
if binauralInput.nChannels ~= 2
    error('CTC:InputArguments','The binaural signal must contain two channels.')
else
    inL = binauralInput.ch(1);
    inR = binauralInput.ch(2);
end

% Frequency vectors for the CTC filters.
% e.g.: CTC_LR -> transfer function for the filter from the left signal to
% the right loudspeaker.
if size(CTCFilter,2) ~= 2
    error('CTC:InputArguments','The CTC filter must contain two rows.')
end

%% CTC filtering
LSSignals=itaAudio(size(CTCFilter,1),1);
for k=1:size(CTCFilter,1)
    LSSignals(k)=ita_convolve(inL,CTCFilter(k,1))+ita_convolve(inR,CTCFilter(k,2));
end

%% Return in time domain as multichannel audio
LSSignals=ita_merge(LSSignals(:))';
end