Commit df6c798c authored by Michael Kohnen's avatar Michael Kohnen

updated decoding for non itaAudio

parent 402e2a03
......@@ -2,12 +2,19 @@ function [ OutputSignals ] = ita_decodeAmbisonics( Bformat, LoudspeakerPos, vara
%ITA_DECODEAMBISONICS Summary of this function goes here
% Detailed explanation goes here
opts.decoding='remax'; % Decoding strategy (remax,inphase,plane)
% BFormat<nmax,LS>
opts.decoding='remax'; % Decoding strategy (remax,inphase,plane)
% opts.decoding='none';
opts = ita_parse_arguments(opts,varargin);
% Initializing further parameters
nmax=max(Bformat.nChannels);
if isa(Bformat, 'itaAudio')
nmax=max(Bformat.nChannels);
else
nmax=size(Bformat,2);
end
N=floor(sqrt(nmax)-1);
% Weighting for Inphase/ReMax
......@@ -36,10 +43,8 @@ end
% Inphase Decoding
if(sum(strcmp(lower(opts.decoding),{'inphase' 'both'})))
% Calculates the B-format channel weights for InPhase-Decoding
N = obj.ambGetOrder; % amb order from sim room
nmax = (N+1)^2; % number of channels
weightsInPhase=zeros(nmax,1);
N=numel(obj.monitorRoom.getSourcePosition)/3;% get number of loudspeaker
%Dissertation J.Daniel p.314, 'preserve Energy' in 0. order
%g_0=sqrt[N*(2*M+1)/(M+1)^2]
weightsInPhase(1)=sqrt(N*(2*N+1)/(N+1)^2);
......@@ -53,22 +58,22 @@ if(sum(strcmp(lower(opts.decoding),{'inphase' 'both'})))
g_in=weightsInPhase;
end
weights=g_in.*g_re; %merge weighting factors
weights=g_in.*g_re; % merge weighting factors
%% Applying weighting to BFormat
if isa(Bformat,'itaAudio')
for k=1:Bformat.nChannels
Bformat.time(:,k)=Bformat.time(:,k).*weights(k);
end
else
for k=1:numel(weights)
Bformat(:,k)=weights(k).*Bformat(:,k); %Apply weighting factors
Bformat(:,k)=weights(k).*Bformat(:,k);
end
end
% SH and inversion
%% SH and inversion of loudspeaker set-up
Y = ita_sph_base(LoudspeakerPos, N, 'real'); % generate basefunctions
Yinv=pinv(Y); % calculate Pseudoinverse
Yinv=pinv(Y); % calculate Pseudoinverse, moore penrose, svd
if isa(Bformat,'itaAudio')
for k=1:LoudspeakerPos.nPoints
......@@ -78,10 +83,10 @@ if isa(Bformat,'itaAudio')
OutputSignals(k)=sum(temp);
end
OutputSignals=ita_merge(OutputSignals(:));
OutputSignals.channelCoordinates=LoudspeakerPos;
else
OutputSignals=Bformat*Yinv;
end
OutputSignals.channelCoordinates=LoudspeakerPos;
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