function padsynthft=sinefillspectrum(iloc,ival,iphase,nSines, ...
w1Length, zp, bh92SINE2SINE, bh92SINE2SINEsize)
%function padsynthf =sinefillspectrum(iloc,ival,iphase,nSines, ...
% w1Length, zp, bh92SINE2SINE, bh92SINE2SINEsize)
%
%=> compute the spectrum of all the sines in the frequency
% domain, in order to remove it from the signal
% data:
% padsynth:
% iloc, ival, iphase: location (bin), magnitude value (dB)
% and phase of a peak
% nSines: number of sines (=length of ival and iloc)
% w1Length: size of the analysis window
% zp: zero-padding multiplicative coefficient
% bh92SINE2SINE: Blackman-Harris window
% bh92SINE2SINEsize: Blackman-Harris window size
peakmag=10.^(ival/20); % magnitude (in [0;1])
halflobe=8*zp/2-1; % bin number of the half lobe
firstbin=floor(iloc)-halflobe; % first bin for filling positive
% frequencies
firstbin2=floor(w1Length*zp-iloc+2)-halflobe;
% idem for negative frequencies
binremainder=iloc-floor(iloc);
sinphase=sin(iphase);
cosphase=cos(iphase);
findex=1-binremainder;
bh92SINE2SINEindexes =zeros(8*zp,1);
sinepadsynthft=zeros(w1Length*zp+halflobe+halflobe+1,1);
padsynthft =zeros(w1Length*zp,1);
%--- computation of the complex value
for i=1:nSines %--- for each sine
if (iloc(i)~=0) %--- JUST WORK WITH NON ZEROS VALUES OF iloc !!!
% -> tracked sines
beginindex = floor(0.5 + findex(i)*512/zp)+1;
% alex
bh92SINE2SINEindexes = [beginindex:512/zp:beginindex+512/zp*(8*zp-1)]';
%bh92SINE2SINEindexes=[beginindex:512/zp:beginindex ...
%+512/zp*(8*zp-1)]';
if (bh92SINE2SINEindexes(8*zp)>bh92SINE2SINEsize)
bh92SINE2SINEindexes(8*zp)=bh92SINE2SINEsize;
end
magsin=bh92SINE2SINE(bh92SINE2SINEindexes) ...
.*sinphase(i)*peakmag(i);
magcos=bh92SINE2SINE(bh92SINE2SINEindexes) ...
.*cosphase(i)*peakmag(i);
%--- fill positive frequency
sinepadsynthft(firstbin(i)+halflobe:firstbin(i) ...
+halflobe+8*zp-1)= ...
sinepadsynthft(firstbin(i)+halflobe:firstbin(i)+ ...
halflobe+8*zp-1)+(magcos+j*magsin);
%--- fill negative frequency
if (firstbin2(i)+halflobe <= w1Length*zp)
sinepadsynthft(firstbin2(i)+halflobe:firstbin2(i) ...
+halflobe+8*zp-1)= ...
sinepadsynthft(firstbin2(i)+halflobe:firstbin2(i)+ ...
halflobe+8*zp-1)+(magcos-j*magsin);
end
end
end
%--- fill padsynthft
padsynthft=padsynthft+sinepadsynthft(halflobe+1:halflobe+1 ...
+w1Length*zp-1);
padsynthft(1:halflobe) = padsynthft(1:halflobe) + ...
sinepadsynthft(w1Length*zp+1:w1Length*zp+halflobe);
padsynthft(w1Length*zp-halflobe+1:w1Length*zp) = ...
padsynthft(w1Length*zp-halflobe+1:w1Length*zp) ...
+ sinepadsynthft(1:halflobe);