% %n=20;     % bitová délka mls sekvence; 2 - 24 b (Davies, W.D.T. (June, July, August, 1966). Generation and 
% %properties of maximum-length sequences. Control, 302-4, 364-5,431-3. Spring 2001, Christopher Brown, cbrown@phi.luc.edu)
% 

% ------------------------------------------------------------------

% generace mls signálu
% pomocí lineárního posuvného registru se zpětnou vazbou za využítí "tap
% bitů", které jsou definovány v souborech "mlsXtap.dll" ; (list of appropriate tap values in Vanderkooy, JAES, 42(4), 1994) 
% row a col jsou permutační vektory (FHT) 
% Zdroj výpočetního algoritmu jsou z oficiálních webové stránky výrobce
% programu  Matlab 
% (http://www.mathworks.com/matlabcentral/fileexchange/11392-acmus-room-aco
% ustic-parameters)

function  [mls,row,col] = generace(n)

switch n							
case 2								
   taps=2;							
   tap1=1;							
   tap2=2;			
case 3
   taps=2;
   tap1=1;
   tap2=3;
case 4
   taps=2;
   tap1=1;
   tap2=4;
case 5
   taps=2;
   tap1=2;
   tap2=5;
case 6
   taps=2;
   tap1=1;
   tap2=6;
case 7
   taps=2;
   tap1=1;
   tap2=7;
case 8
   taps=4;
   tap1=1;
   tap2=5;
   tap3=6;
   tap4=8;
case 9
   taps=2;
   tap1=4;
   tap2=9;
case 10
   taps=2;
   tap1=3;
   tap2=10;
case 11
   taps=2;
   tap1=2;
   tap2=11;
case 12
   taps=4;
   tap1=3;
   tap2=4;
   tap3=7;
   tap4=12;
case 13
   taps=4;
   tap1=1;
   tap2=3;
   tap3=4;
   tap4=13;
case 14
   taps=4;
   tap1=1;
   tap2=11;
   tap3=12;
   tap4=14;
case 15
   taps=2;
   tap1=1;
   tap2=15;
case 16
   taps=4;
   tap1=2;
   tap2=3;
   tap3=5;
   tap4=16;
case 17
   taps=2;
   tap1=3;
   tap2=17;
case 18
   taps=2;
   tap1=7;
   tap2=18;
case 19
   taps=4;
   tap1=1;
   tap2=5;
   tap3=6;
   tap4=19;
case 20
   taps=2;
   tap1=3;
   tap2=20;
case 21
   taps=2;
   tap1=2;
   tap2=21;
case 22
   taps=2;
   tap1=1;
   tap2=22;
case 23
   taps=2;
   tap1=5;
   tap2=23;
case 24
   taps=4;
   tap1=1;
   tap2=3;
   tap3=4;
   tap4=24;
case 25
  taps=2;
  tap1=3;
  tap2=25;
case 26
  taps=4;
  tap1=1;
  tap2=7;
  tap3=8;
  tap4=26;
case 27
  taps=4;
  tap1=1;
  tap2=7;
  tap3=8;
  tap4=27;
case 28
  taps=2;
  tap1=3;
  tap2=28;
case 29
  taps=2;
  tap1=2;
  tap2=29;
case 30
  taps=4;
  tap1=1;
  tap2=15;
  tap3=16;
  tap4=30;
case 31
  taps=2;
  tap1=3;
  tap2=31;
case 32
  taps=4;
  tap1=1;
  tap2=27;
  tap3=28;
  tap4=32;
otherwise
   disp(' ');
   error('input bits must be between 2 and 32');
end

if taps == 2
    [mls,row,col]=mls2tap(tap2,tap1,tap2);
    row_1=row;
    col_1=col;
elseif taps == 4
    [mls,row,col]=mls4tap(tap4,tap1,tap2,tap3,tap4);
end    

y=mls;  % případný výpis kvůli kontrole

