ita_binauralMixdown.m 1.18 KB
Newer Older
Michael Kohnen's avatar
Michael Kohnen committed
1
function [ binOut ] = ita_binauralMixdown( lsSignals, varargin )
2
3
%ITA_3DA_BINAURALMIXDOWN Produces a 2-Channel binaural stream out of
%loudspeaker signal(s) and coordinates (given as optional coordinates or
4
%better: encoded in the itaAudio channel coordinates)
5
%   Detailed explanation goes here
6
7
8

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
9
opts.distanceLoss=true;
10
11

if nargin>1
Michael Kohnen's avatar
Michael Kohnen committed
12
    opts=ita_parse_arguments(opts,varargin);
13
14
15
16
17
18
19
20
21
22
23
24
end
if ~(isa(lsSignals, 'itaAudio')&&(lsSignals.nChannels>0))
    error('First input must be itaAudio with at least one channel')
end

if opts.LSPos.nPoints<1
    opts.LSPos=lsSignals.channelCoordinates;
    if opts.LSPos.nPoints<1
        error('We need some channel coordinates!');
    end
end

Michael Kohnen's avatar
Michael Kohnen committed
25
hrtfSet=itaHRTF(opts.HRTF);
26
27
28
29
30

binOut=itaAudio;

for k=1:lsSignals.nChannels
    hrtf=hrtfSet.findnearestHRTF(opts.LSPos.n(k));
31
    if opts.distanceLoss
32
        hrtf=hrtf/opts.LSPos.r(k);
33
    end
34
35
36
37
    convolved=ita_convolve(lsSignals.ch(k),hrtf);
    if k==1
        binOut=convolved;
    else
38
        binOut=binOut+convolved;
39
40
41
    end
end