Working codec2 support

This commit is contained in:
Brian West
2010-09-21 12:35:41 -05:00
parent 549b2356d6
commit 62b55523c2
150 changed files with 14078 additions and 3 deletions

View File

@@ -0,0 +1,25 @@
% glottal.m
% David Rowe 12 Sep 2009
% Matlab script to generate the phase spectra of a glottal pulse
% lpc10 pulse from spandsp. When the file glottal.c was used as a part of the
% excitation phase component in phase.c, phase_synth_zero_order(), no difference
% in speech quality was apparent. So left out of code for now.
sh=12
kexc = [ 8, -16, 26, -48, 86, -162, 294, -502, 718, -728, 184 672, -610, -672, 184, 728, 718, 502, 294, 162, 86, 48, 26, 16, 8];
kexc = shift(kexc,sh);
kexc = [kexc(1:sh) zeros(1,512-25) kexc(sh+1:25)];
figure(1)
plot(kexc)
figure(2)
G = fft(kexc);
plot((1:256)*(4000/256),unwrap(angle(G(1:256))))
f=fopen("glottal.c","wt");
fprintf(f,"float glottal[]={\n");
for m=1:255
fprintf(f," %f,\n",angle(G(m)));
endfor
fprintf(f," %f};\n",angle(G(256)));
fclose(f);

View File

@@ -0,0 +1,8 @@
% load_raw.m
% David Rowe 7 Oct 2009
function s = load_raw(fn)
fs=fopen(fn,"rb");
s = fread(fs,Inf,"short");
plot(s)
endfunction

View File

@@ -0,0 +1,50 @@
% lsp_pdf.m
% David Rowe 2 Oct 2009
% Plots histograms (PDF estimates) of LSP training data
function lsp_pdf(lsp)
[r,c] = size(lsp);
% LSPs
figure(3);
clf;
[x,y] = hist(lsp(:,1),100);
plot(y*4000/pi,x,";1;");
hold on;
for i=2:c
[x,y] = hist(lsp(:,i),100);
legend = sprintf(";%d;",i);
plot(y*4000/pi,x,legend);
endfor
hold off;
grid;
% LSP differences
figure(4);
clf;
subplot(211)
[x,y] = hist(lsp(:,1),100);
plot(y,x,";1;");
hold on;
for i=2:5
[x,y] = hist(lsp(:,i) - lsp(:,i-1),100);
legend = sprintf(";%d;",i);
plot(y,x,legend);
endfor
hold off;
grid;
subplot(212)
[x,y] = hist(lsp(:,6)-lsp(:,5),100);
plot(y,x,";6;");
hold on;
for i=7:c
[x,y] = hist(lsp(:,i) - lsp(:,i-1),100);
legend = sprintf(";%d;",i);
plot(y,x,legend);
endfor
hold off;
grid;
endfunction

View File

@@ -0,0 +1,56 @@
% phase.m
% David Rowe August 2009
% experiments with phase for sinusoidal codecs
function phase(samname, F0, png)
Wo=2*pi*F0/8000;
P=2*pi/Wo;
L = floor(pi/Wo);
Nsam = 16000;
N = 80;
F = Nsam/N;
A = 10000/L;
phi = zeros(1,L);
s = zeros(1,Nsam);
for m=floor(L/2):L
phi_off(m) = -m*Wo*8;
end
for f=1:F
phi(1) = phi(1) + Wo*N;
phi(1) = mod(phi(1),2*pi);
for m=1:L
phi(m) = m*phi(1);
end
x = zeros(1,N);
for m=1:L
x = x + A*cos(m*Wo*(0:(N-1)) + phi(m));
endfor
s((f-1)*N+1:f*N) = x;
endfor
figure(1);
clf;
plot(s(1:250));
fs=fopen(samname,"wb");
fwrite(fs,s,"short");
fclose(fs);
if (nargin == 3)
% small image to fit blog
__gnuplot_set__ terminal png size 450,300
ss = sprintf("__gnuplot_set__ output \"%s.png\"", samname);
eval(ss)
replot;
% for some reason I need this to stop large plot getting wiped
__gnuplot_set__ output "/dev/null"
endif
endfunction

View File

@@ -0,0 +1,50 @@
% phase2.m
% David Rowe Sep 2009
% experiments with phase for sinusoidal codecs, looking at phase
% of excitation with real Am samples from hts1
function phase2(samname, png)
N = 16000;
f=45;
model = load("../src/hts1a_model.txt");
phase = load("../src/hts1a_phase_phase.txt");
Wo = model(f,1);
P=2*pi/Wo;
L = model(f,2);
A = model(f,3:(L+2));
phi = phase(f,1:L);
phi = zeros(1,L);
for m=L/2:L
phi(m) = 2*pi*rand(1,1);
end
s = zeros(1,N);
for m=1:L
s_m = A(m)*cos(m*Wo*(0:(N-1)) + phi(m));
s = s + s_m;
endfor
figure(1);
clf;
plot(s(1:250));
fs=fopen(samname,"wb");
fwrite(fs,s,"short");
fclose(fs);
if (nargin == 2)
% small image to fit blog
__gnuplot_set__ terminal png size 450,300
ss = sprintf("__gnuplot_set__ output \"%s.png\"", samname);
eval(ss)
replot;
% for some reason I need this to stop large plot getting wiped
__gnuplot_set__ output "/dev/null"
endif
endfunction

View File

@@ -0,0 +1,39 @@
% pitch_test.m
% David Rowe Sep 2009
% Constructs a sequence to test the pitch estimator
function pitch_test(samname)
M=320;
F=200;
fs=fopen(samname,"wb");
f0 = 100;
for f=1:200
Wo=2*pi*f0/8000;
P=2*pi/Wo;
L = floor(pi/Wo);
A = 10000/L;
phi = zeros(1,L);
s = zeros(1,M);
for m=1:L
s = s + A*cos(m*Wo*(0:(M-1)) + phi(m));
endfor
figure(1);
clf;
plot(s);
fwrite(fs,s,"short");
f0 = f0 + 5;
if (f0 > 400)
f0 = 100;
endif
endfor
fclose(fs);
endfunction

View File

@@ -0,0 +1,42 @@
% Copyright David Rowe 2009
% This program is distributed under the terms of the GNU General Public License
% Version 2
function pl(samname1, start_sam, end_sam, pngname)
fs=fopen(samname1,"rb");
s=fread(fs,Inf,"short");
st = 1;
en = length(s);
if (nargin >= 2)
st = start_sam;
endif
if (nargin >= 3)
en = end_sam;
endif
figure(1);
clf;
plot(s(st:en));
axis([1 en-st min(s) max(s)]);
if (nargin == 4)
% small image
__gnuplot_set__ terminal png size 420,300
ss = sprintf("__gnuplot_set__ output \"%s.png\"", pngname);
eval(ss)
replot;
% larger image
__gnuplot_set__ terminal png size 800,600
ss = sprintf("__gnuplot_set__ output \"%s_large.png\"", pngname);
eval(ss)
replot;
endif
endfunction

View File

@@ -0,0 +1,50 @@
% Copyright David Rowe 2009
% This program is distributed under the terms of the GNU General Public License
% Version 2
function pl2(samname1, samname2, start_sam, end_sam, pngname)
fs1=fopen(samname1,"rb");
s1=fread(fs1,Inf,"short");
fs2=fopen(samname2,"rb");
s2=fread(fs2,Inf,"short");
st = 1;
en = length(s1);
if (nargin >= 3)
st = start_sam;
endif
if (nargin >= 4)
en = end_sam;
endif
figure(1);
clf;
subplot(211);
l1 = strcat("r;",samname1,";");
plot(s1(st:en), l1);
axis([1 en-st min(s1(st:en)) max(s1(st:en))]);
subplot(212);
l2 = strcat("r;",samname2,";");
plot(s2(st:en),l2);
axis([1 en-st min(s1(st:en)) max(s1(st:en))]);
if (nargin == 5)
% small image
__gnuplot_set__ terminal png size 420,300
s = sprintf("__gnuplot_set__ output \"%s.png\"", pngname);
eval(s)
replot;
% larger image
__gnuplot_set__ terminal png size 800,600
s = sprintf("__gnuplot_set__ output \"%s_large.png\"", pngname);
eval(s)
replot;
endif
endfunction

View File

@@ -0,0 +1,166 @@
% Copyright David Rowe 2009
% This program is distributed under the terms of the GNU General Public License
% Version 2
%
% Plot ampltiude modelling information from dump files.
function plamp(samname, f)
sn_name = strcat(samname,"_sn.txt");
Sn = load(sn_name);
sw_name = strcat(samname,"_sw.txt");
Sw = load(sw_name);
sw__name = strcat(samname,"_sw_.txt");
if (file_in_path(".",sw__name))
Sw_ = load(sw__name);
endif
model_name = strcat(samname,"_model.txt");
model = load(model_name);
modelq_name = strcat(samname,"_qmodel.txt");
if (file_in_path(".",modelq_name))
modelq = load(modelq_name);
endif
pw_name = strcat(samname,"_pw.txt");
if (file_in_path(".",pw_name))
Pw = load(pw_name);
endif
lsp_name = strcat(samname,"_lsp.txt");
if (file_in_path(".",lsp_name))
lsp = load(lsp_name);
endif
phase_name = strcat(samname,"_phase.txt");
if (file_in_path(".",phase_name))
phase = load(phase_name);
endif
phase_name_ = strcat(samname,"_phase_.txt");
if (file_in_path(".",phase_name_))
phase_ = load(phase_name_);
endif
snr_name = strcat(samname,"_snr.txt");
if (file_in_path(".",snr_name))
snr = load(snr_name);
endif
k = ' ';
do
figure(1);
clf;
% s = [ Sn(2*(f-2)-1,:) Sn(2*(f-2),:) ];
s = [ Sn(2*f-1,:) Sn(2*f,:) ];
plot(s);
axis([1 length(s) -20000 20000]);
figure(2);
Wo = model(f,1);
L = model(f,2);
Am = model(f,3:(L+2));
plot((1:L)*Wo*4000/pi, 20*log10(Am),";Am;r");
axis([1 4000 -10 80]);
hold on;
% plot((0:255)*4000/256, Sw(f-2,:),";Sw;");
plot((0:255)*4000/256, Sw(f,:),";Sw;");
if (file_in_path(".",modelq_name))
Amq = modelq(f,3:(L+2));
plot((1:L)*Wo*4000/pi, 20*log10(Amq),";Amq;g" );
if (file_in_path(".",pw_name))
plot((0:255)*4000/256, 10*log10(Pw(f,:)),";Pw;c");
endif
signal = Am * Am';
noise = (Am-Amq) * (Am-Amq)';
snr1 = 10*log10(signal/noise);
Am_err_label = sprintf(";Am error SNR %4.2f dB;m",snr1);
plot((1:L)*Wo*4000/pi, 20*log10(Amq) - 20*log10(Am), Am_err_label);
endif
if (file_in_path(".",snr_name))
snr_label = sprintf(";phase SNR %4.2f dB;",snr(f));
plot(1,1,snr_label);
endif
% phase model - determine SNR and error spectrum for phase model 1
if (file_in_path(".",phase_name_))
orig = Am.*exp(j*phase(f,1:L));
synth = Am.*exp(j*phase_(f,1:L));
signal = orig * orig';
noise = (orig-synth) * (orig-synth)';
snr_phase = 10*log10(signal/noise);
phase_err_label = sprintf(";phase_err SNR %4.2f dB;",snr_phase);
plot((1:L)*Wo*4000/pi, 20*log10(orig-synth), phase_err_label);
endif
if (file_in_path(".",lsp_name))
for l=1:10
plot([lsp(f,l)*4000/pi lsp(f,l)*4000/pi], [60 80], 'r');
endfor
endif
hold off;
if (file_in_path(".",phase_name))
figure(3);
plot((1:L)*Wo*4000/pi, phase(f,1:L), ";phase;");
axis;
if (file_in_path(".",phase_name_))
hold on;
plot((1:L)*Wo*4000/pi, phase_(f,1:L), ";phase_;");
hold off;
endif
figure(2);
endif
% autocorrelation function to research voicing est
%M = length(s);
%sw = s .* hanning(M)';
%for k=0:159
% R(k+1) = sw(1:320-k) * sw(1+k:320)';
%endfor
%figure(4);
%R_label = sprintf(";R(k) %3.2f;",max(R(20:159))/R(1));
%plot(R/R(1),R_label);
%grid
% interactive menu
printf("\rframe: %d menu: n-next b-back p-png q-quit ", f);
fflush(stdout);
k = kbhit();
if (k == 'n')
f = f + 1;
endif
if (k == 'b')
f = f - 1;
endif
% optional print to PNG
if (k == 'p')
figure(1);
pngname = sprintf("%s_%d_sn.png",samname,f);
print(pngname, '-dpng', "-S500,500")
pngname = sprintf("%s_%d_sn_large.png",samname,f);
print(pngname, '-dpng', "-S800,600")
figure(2);
pngname = sprintf("%s_%d_sw.png",samname,f);
print(pngname, '-dpng', "-S500,500")
pngname = sprintf("%s_%d_sw_large.png",samname,f);
print(pngname, '-dpng', "-S800,600")
endif
until (k == 'q')
printf("\n");
endfunction

View File

@@ -0,0 +1,11 @@
load ../unittest/tinterp_prev.txt;
load ../unittest/tinterp_interp.txt;
load ../unittest/tinterp_next.txt;
clf;
plot(tinterp_prev(:,1), 20.0*log10(tinterp_prev(:,2)),";prev;")
hold on;
plot(tinterp_interp(:,1), 20.0*log10(tinterp_interp(:,2)),'g+-;interp;')
plot(tinterp_next(:,1), 20.0*log10(tinterp_next(:,2)),'ro-;next;')
hold off;
axis([0 pi 0 80])

View File

@@ -0,0 +1,134 @@
% Copyright David Rowe 2009
% This program is distributed under the terms of the GNU General Public License
% Version 2
%
% Plot NLP states from dump files.
function plnlp(samname, f)
sn_name = strcat(samname,"_sn.txt");
Sn = load(sn_name);
sw_name = strcat(samname,"_sw.txt");
Sw = load(sw_name);
fw_name = strcat(samname,"_fw.txt");
if (file_in_path(".",fw_name))
fw = load(fw_name);
endif
e_name = strcat(samname,"_e.txt");
if (file_in_path(".",e_name))
e = load(e_name);
endif
p_name = strcat(samname,".p");
if (file_in_path(".",p_name))
p = load(p_name);
endif
sq_name = strcat(samname,"_sq.txt");
if (file_in_path(".",sq_name))
sq = load(sq_name);
endif
dec_name = strcat(samname,"_dec.txt");
if (file_in_path(".",dec_name))
dec = load(dec_name);
endif
do
figure(1);
clf;
s = [ Sn(2*f-1,:) Sn(2*f,:) ];
plot(s, ";Sn;");
grid
axis([1 length(s) -20000 20000]);
figure(2);
plot((0:255)*4000/256, Sw(f,:),";Sw;");
grid
axis([1 4000 -10 80]);
hold on;
f0 = 8000/p(f);
Wo = 2*pi/p(f);
L = floor(pi/Wo);
f0_label = sprintf("b;P=%3.1f F0=%3.0f;",p(f),f0);
for m=1:L-1
plot([ m*Wo*4000/pi m*Wo*4000/pi], [10 60], 'b');
endfor
plot([ L*Wo*4000/pi L*Wo*4000/pi], [10 60], f0_label);
hold off;
if (file_in_path(".",fw_name))
figure(3);
if (file_in_path(".",e_name))
subplot(211);
endif
plot((0:255)*800/256, fw(f,:)/max(fw(f,:)), ";Fw;");
axis([1 400 0 1]);
if (file_in_path(".",e_name))
subplot(212);
e_concat = [ e(2*f-1,:) e(2*f,:) ];
plot(e_concat(1:400)/max(e_concat(1:400)), "+;MBE E(f);");
axis([1 400 0 1]);
endif
endif
if (file_in_path(".",sq_name))
figure(4);
sq_concat = [ sq(2*f-1,:) sq(2*f,:) ];
axis
plot(sq_concat, ";sq;");
endif
if (file_in_path(".",dec_name))
figure(5);
plot(dec(f,:), ";dec;");
endif
figure(2);
% interactive menu
printf("\rframe: %d menu: n-next b-back p-png q-quit ", f);
fflush(stdout);
k = kbhit();
if (k == 'n')
f = f + 1;
endif
if (k == 'b')
f = f - 1;
endif
% optional print to PNG
if (k == 'p')
pngname = sprintf("%s_%d",samname,f);
% small image
__gnuplot_set__ terminal png size 420,300
ss = sprintf("__gnuplot_set__ output \"%s.png\"", pngname);
eval(ss)
replot;
% larger image
__gnuplot_set__ terminal png size 800,600
ss = sprintf("__gnuplot_set__ output \"%s_large.png\"", pngname);
eval(ss)
replot;
% for some reason I need this to stop large plot getting wiped
__gnuplot_set__ output "/dev/null"
endif
until (k == 'q')
printf("\n");
endfunction

View File

@@ -0,0 +1,198 @@
% Copyright David Rowe 2009
% This program is distributed under the terms of the GNU General Public License
% Version 2
%
% Plot phase modelling information from dump files.
function plphase(samname, f)
sn_name = strcat(samname,"_sn.txt");
Sn = load(sn_name);
sw_name = strcat(samname,"_sw.txt");
Sw = load(sw_name);
model_name = strcat(samname,"_model.txt");
model = load(model_name);
sw__name = strcat(samname,"_sw_.txt");
if (file_in_path(".",sw__name))
Sw_ = load(sw__name);
endif
pw_name = strcat(samname,"_pw.txt");
if (file_in_path(".",pw_name))
Pw = load(pw_name);
endif
ak_name = strcat(samname,"_ak.txt");
if (file_in_path(".",ak_name))
ak = load(ak_name);
endif
phase_name = strcat(samname,"_phase.txt");
if (file_in_path(".",phase_name))
phase = load(phase_name);
endif
phase_name_ = strcat(samname,"_phase_.txt");
if (file_in_path(".",phase_name_))
phase_ = load(phase_name_);
endif
snr_name = strcat(samname,"_snr.txt");
if (file_in_path(".",snr_name))
snr = load(snr_name);
endif
sn_name_ = strcat(samname,".raw");
if (file_in_path(".",sn_name_))
fs_ = fopen(sn_name_,"rb");
sn_ = fread(fs_,Inf,"short");
endif
k = ' ';
do
figure(1);
clf;
s = [ Sn(2*f-1,:) Sn(2*f,:) ];
plot(s);
grid;
axis([1 length(s) -20000 20000]);
if (k == 'p')
pngname = sprintf("%s_%d_sn",samname,f);
png(pngname);
endif
figure(2);
Wo = model(f,1);
L = model(f,2);
Am = model(f,3:(L+2));
plot((1:L)*Wo*4000/pi, 20*log10(Am),"r;Am;");
axis([1 4000 -10 80]);
hold on;
plot((0:255)*4000/256, Sw(f,:),";Sw;");
grid;
if (file_in_path(".",sw__name))
plot((0:255)*4000/256, Sw_(f,:),"g;Sw_;");
endif
if (file_in_path(".",pw_name))
plot((0:255)*4000/256, 10*log10(Pw(f,:)),";Pw;");
endif
if (file_in_path(".",snr_name))
snr_label = sprintf(";phase SNR %4.2f dB;",snr(f));
plot(1,1,snr_label);
endif
% phase model - determine SNR and error spectrum for phase model 1
if (file_in_path(".",phase_name_))
orig = Am.*exp(j*phase(f,1:L));
synth = Am.*exp(j*phase_(f,1:L));
signal = orig * orig';
noise = (orig-synth) * (orig-synth)';
snr_phase = 10*log10(signal/noise);
phase_err_label = sprintf("g;phase_err SNR %4.2f dB;",snr_phase);
plot((1:L)*Wo*4000/pi, 20*log10(orig-synth), phase_err_label);
endif
hold off;
if (k == 'p')
pngname = sprintf("%s_%d_sw",samname,f);
png(pngname);
endif
if (file_in_path(".",phase_name))
figure(3);
plot((1:L)*Wo*4000/pi, phase(f,1:L)*180/pi, "-o;phase;");
axis;
if (file_in_path(".", phase_name_))
hold on;
plot((1:L)*Wo*4000/pi, phase_(f,1:L)*180/pi, "g;phase_;");
grid
hold off;
endif
if (k == 'p')
pngname = sprintf("%s_%d_phase",samname,f);
png(pngname);
endif
endif
% synthesised speech
if (file_in_path(".",sn_name_))
figure(4);
s_ = sn_((f-3)*80+1:(f+1)*80);
plot(s_);
axis([1 length(s_) -20000 20000]);
if (k == 'p')
pngname = sprintf("%s_%d_sn_",samname,f)
png(pngname);
endif
endif
if (file_in_path(".",ak_name))
figure(5);
axis;
akw = ak(f,:);
weight = 1.0 .^ (0:length(akw)-1);
akw = akw .* weight;
H = 1./fft(akw,8000);
subplot(211);
plot(20*log10(abs(H(1:4000))),";LPC mag spec;");
grid;
subplot(212);
plot(angle(H(1:4000))*180/pi,";LPC phase spec;");
grid;
if (k == 'p')
% stops multimode errors from gnuplot, I know not why...
figure(2);
figure(5);
pngname = sprintf("%s_%d_lpc",samname,f);
png(pngname);
endif
endif
% autocorrelation function to research voicing est
%M = length(s);
%sw = s .* hanning(M)';
%for k=0:159
% R(k+1) = sw(1:320-k) * sw(1+k:320)';
%endfor
%figure(4);
%R_label = sprintf(";R(k) %3.2f;",max(R(20:159))/R(1));
%plot(R/R(1),R_label);
%grid
figure(2);
% interactive menu
printf("\rframe: %d menu: n-next b-back p-png q-quit ", f);
fflush(stdout);
k = kbhit();
if (k == 'n')
f = f + 1;
endif
if (k == 'b')
f = f - 1;
endif
% optional print to PNG
if (k == 'p')
pngname = sprintf("%s_%d",samname,f);
png(pngname);
endif
until (k == 'q')
printf("\n");
endfunction

View File

@@ -0,0 +1,36 @@
% Copyright David Rowe 2009
% This program is distributed under the terms of the GNU General Public License
% Version 2
%
% plpitch.m
% Plots two pitch tracks on top of each other, used for comparing pitch
% estimators
function plpitch(pitch1_name, pitch2_name, start_fr, end_fr)
pitch1 = load(pitch1_name);
pitch2 = load(pitch2_name);
st = 1;
en = length(pitch1);
if (nargin >= 3)
st = start_fr;
endif
if (nargin >= 4)
en = end_fr;
endif
figure(1);
clf;
l1 = strcat("r;",pitch1_name,";")
l1
st
en
plot(pitch1(st:en), l1);
axis([1 en-st 20 160]);
l2 = strcat("g;",pitch2_name,";");
hold on;
plot(pitch2(st:en),l2);
hold off;
endfunction

View File

@@ -0,0 +1,25 @@
% Copyright David Rowe 2009
% This program is distributed under the terms of the GNU General Public License
% Version 2
%
% Replot current plot as a png, generates small and large versions
function png(pngname)
% small image
__gnuplot_set__ terminal png size 420,300
ss = sprintf("__gnuplot_set__ output \"%s.png\"", pngname);
eval(ss)
replot;
% larger image
__gnuplot_set__ terminal png size 800,600
ss = sprintf("__gnuplot_set__ output \"%s_large.png\"", pngname);
eval(ss)
replot;
% for some reason I need this to stop large plot getting wiped
__gnuplot_set__ output "/dev/null"
endfunction

View File

@@ -0,0 +1,24 @@
% Copyright David Rowe 2009
% This program is distributed under the terms of the GNU General Public License
% Version 2
%
% Plot postfilter doing its thing
function postfilter(samname)
p = load(samname);
figure(1);
plot(p(:,1),";energy;");
hold on;
plot(p(:,2),";bg_est;");
hold off;
grid;
pngname=sprintf("%s_postfilter_1", samname);
png(pngname);
figure(2);
plot(p(:,3),";% unvoiced;");
grid;
pngname=sprintf("%s_postfilter_2", samname);
png(pngname);
endfunction

View File

@@ -0,0 +1,37 @@
% pulse.m
% David Rowe August 2009
%
% Experiments with human pulse perception for sinusoidal codecs
function pulse(samname)
A = 1000;
K = 16000;
N = 80;
frames = K/N;
s = zeros(1,K);
for f=1:frames
% lets try placing np random pulses in every frame
P = 20 + (160-20)*rand(1,1);
Wo = 2*pi/P;
L = floor(pi/Wo);
sf = zeros(1,N);
for m=1:L/2:L
pos = floor(rand(1,1)*N)+1;
%pos = 50;
for l=m:m+L/2-1
sf = sf + A*cos(l*Wo*((f-1)*N+1:f*N) - pos*l*Wo);
endfor
endfor
s((f-1)*N+1:f*N) = sf;
endfor
plot(s(1:250));
fs=fopen(samname,"wb");
fwrite(fs,s,"short");
fclose(fs);
endfunction