%----------- B-format dekoder (Semestralni prace) -------------------------
%............rectangle layout loudspeaker feeds......................
% 16.11.2008
% verze 1 
% format vstupnich dat!!!
%--------------------------------------------------------------------------
function [LF RF LB RB]=rectanUHJ(WF,XF,YF,fi)
    
% loudspeaker at fi/2
            
           uhelLF = (fi/2) * (pi/180);
           uhelRF = -(fi/2)*(pi/180);
           uhelLB = pi - ((fi/2)*(pi/180));
           uhelRB = pi + ((fi/2)*(pi/180));

% loudspeaker feeds

           LF = 0.5*(WF + ( (1/sqrt(2)*cos(uhelLF)) * XF) + ( (1/sqrt(2)*sin(uhelLF)) * YF));
           RF = 0.5*(WF + ( (1/sqrt(2)*cos(uhelRF)) * XF) + ( (1/sqrt(2)*sin(uhelRF)) * YF));
           LB = 0.5*(WF + ( (1/sqrt(2)*cos(uhelLB)) * XF) + ( (1/sqrt(2)*sin(uhelLB)) * YF));
           RB = 0.5*(WF + ( (1/sqrt(2)*cos(uhelRB)) * XF) + ( (1/sqrt(2)*sin(uhelRB)) * YF));

disp('reproduktory jsou v pořadí: LF RF LB RB')
disp('(L - left,R - right,F - front,B - back,U - up,D - down)')           
           
% zapis na disk        
% 
% mkdir('c:\Dekoder-vystupy','rectangularUHJ');           
% 
%         wavwrite(0.999*(LF/max(abs(LF))),48000,'c:\Dekoder-vystupy\rectangularUHJ\LFfeed');                           
%         wavwrite(0.999*(LB/max(abs(LB))),48000,'c:\Dekoder-vystupy\rectangularUHJ\LBfeed');        
%         wavwrite(0.999*(RB/max(abs(RB))),48000,'c:\Dekoder-vystupy\rectangularUHJ\RBfeed');
%         wavwrite(0.999*(RF/max(abs(RF))),48000,'c:\Dekoder-vystupy\rectangularUHJ\RFfeed');           
