Commit df6c798c authored by Michael Kohnen's avatar Michael Kohnen
Browse files

updated decoding for non itaAudio

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