--- /dev/null
+% 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(1);
+ clg;
+ [x,y] = hist(lsp(:,1),100);
+ plot(y,x,";1;");
+ hold on;
+ for i=2:c
+ [x,y] = hist(lsp(:,i),100);
+ legend = sprintf(";%d;",i);
+ plot(y,x,legend);
+ endfor
+ hold off;
+ grid;
+
+ % LSP differences
+
+ figure(2);
+ clg;
+ 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
% David Rowe August 2009
% experiments with phase for sinusoidal codecs
-function phase(samname, F0, randphase, png)
+function phase(samname, F0, png)
Wo=2*pi*F0/8000;
P=2*pi/Wo;
L = floor(pi/Wo);
- N = 16000;
+ Nsam = 16000;
+ N = 80;
+ F = Nsam/N;
A = 10000/L;
phi = zeros(1,L);
- for m=1:L
- phi(m) = m*Wo*50.125;
+ s = zeros(1,Nsam);
+
+ for m=floor(L/2):L
+ phi_off(m) = -m*Wo*8;
end
- if (randphase == 1)
- rand("seed",0);
- phi = rand(L,1)*2*pi;
- endif
- s = zeros(1,N);
- for m=1:L
- s = s + A*cos(m*Wo*(0:(N-1)) + phi(m));
+ for f=1:F
+ phi(1) = phi(1) + Wo*N;
+ phi(1) = mod(phi(1),2*pi);
+
+ for m=2: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) + phi_off(m));
+ endfor
+ s((f-1)*N+1:f*N) = x;
endfor
figure(1);
fwrite(fs,s,"short");
fclose(fs);
- if png
+ if (nargin == 3)
% small image to fit blog
__gnuplot_set__ terminal png size 450,300
--- /dev/null
+% 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");
+ Wo = model(f,1);
+ P=2*pi/Wo;
+ L = model(f,2);
+ A = model(f,3:(L+2));
+
+ phi = zeros(1,L);
+ for m=1:L
+ phi(m) = -m*Wo*0.3*rand(1,1)*L;
+ end
+ s = zeros(1,N);
+
+ for m=1:L
+ s = s + A(m)*cos(m*Wo*(0:(N-1)) + phi(m));
+ endfor
+
+ figure(1);
+ clg;
+ 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
+
endif
signal = Am * Am';
noise = (Am-Amq) * (Am-Amq)';
- snr = 10*log10(signal/noise);
- Am_err_label = sprintf(";Am_err SNR %4.2f dB;",snr);
+ snr1 = 10*log10(signal/noise);
+ Am_err_label = sprintf(";Am_err SNR %4.2f dB;",snr1);
plot((1:L)*Wo*4000/pi, 20*log10(Amq) - 20*log10(Am), Am_err_label);
endif