%wp_level2P

%plots of the wavelets packets of the second resolution level and their SHA
%spectra

lole1=8%input('loglength of signal;0--former; ?')
if lole1>0
    lole=lole1;
    N=2^lole;
end
shi=1;%input('shift to the center--1; ?')
Ll1=4;%input('number of dyadic subdivision levels;0--former; ?')
if Ll1>0
    Ll=Ll1;
    M=N*2^(Ll-1);
end
Par1=input('spline order;0--former; ?')
if Par1>0
    P=Par1;
end


SP=[];fSP=[];
for kk=1:4
   
[spli fspli]=wp_genP([2,kk-1],P,N,Ll);
SP=[SP;spli];
fSP=[fSP;abs(fspli)];
end
x=(1:M)-M/2;
y=x/2^(Ll-1);

figure;
subplot(2,1,1)
for kk=1:4
a=[SP(kk,:) ];
a=circ_h(a,(kk-2)*M/4-M/8);
plot(y,a,'LineWidth',2);
hold on
axis([y(1) y(end) -1 1])
  set(gca,'FontSize',16)  
end
  title(['\fontsize{16}Spline order: '  int2str(P)])
 
subplot(2,1,2)
for kk=1:4
a=[fSP(kk,:) ];
%a=circ_h(a,N/2);
a=a(1:N/2);
plot(a,'LineWidth',2);
hold on
axis([1,N/2+1, 0 3.2])
 set(gca,'XTick',[1 32 64 96 128])
 %set(gca,'XTickLabel',{'-2\pi','-\pi','0','pi','2pi'})
 set(gca,'XTickLabel',{'0','32','64','96','128'})   
 set(gca,'FontSize',16)
end

