From: drowe67 Date: Mon, 7 Sep 2009 04:22:45 +0000 (+0000) Subject: messing with phase models X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=e6dc252b7e01d1e833ba4c4a1b907f49dc9ec490;p=freetel-svn-tracking.git messing with phase models git-svn-id: https://svn.code.sf.net/p/freetel/code@39 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2/octave/phase.m b/codec2/octave/phase.m index 859dde8d..537e193b 100644 --- a/codec2/octave/phase.m +++ b/codec2/octave/phase.m @@ -9,6 +9,9 @@ function phase(samname, F0, randphase, png) N = 16000; A = 10000/L; phi = zeros(1,L); + for m=1:L + phi(m) = m*Wo*0.3*m; + end if (randphase == 1) rand("seed",0); phi = rand(L,1)*2*pi; diff --git a/codec2/octave/plamp.m b/codec2/octave/plamp.m index e72f9303..223dfb9f 100644 --- a/codec2/octave/plamp.m +++ b/codec2/octave/plamp.m @@ -35,6 +35,16 @@ function plamp(samname, f) 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 + do figure(1); clg; @@ -51,14 +61,12 @@ function plamp(samname, f) hold on; plot((0:255)*4000/256, Sw(f,:),";Sw;"); - if (file_in_path(".",sw__name)) - plot((0:255)*4000/256, Sw_(f,:),";Sw_;"); - endif - if (file_in_path(".",modelq_name)) Amq = modelq(f,3:(L+2)); plot((1:L)*Wo*4000/pi, 20*log10(Amq),";Amq;" ); - plot((0:255)*4000/256, 10*log10(Pw(f,:)),";Pw;"); + if (file_in_path(".",pw_name)) + plot((0:255)*4000/256, 10*log10(Pw(f,:)),";Pw;"); + endif signal = Am * Am'; noise = (Am-Amq) * (Am-Amq)'; snr = 10*log10(signal/noise); @@ -66,6 +74,19 @@ function plamp(samname, f) plot((1:L)*Wo*4000/pi, 20*log10(Amq) - 20*log10(Am), Am_err_label); endif + % phase model - determine SNR and error spectrum + + 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 = 10*log10(signal/noise); + + phase_err_label = sprintf(";phase_err SNR %4.2f dB;",snr); + 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'); @@ -74,6 +95,18 @@ function plamp(samname, f) hold off; + if (file_in_path(".",phase_name)) + figure(3); + plot((1:L)*Wo*4000/pi, unwrap(phase(f,1:L)), ";phase;"); + axis; + if (file_in_path(".",phase_name_)) + hold on; + plot((1:L)*Wo*4000/pi, unwrap(phase_(f,1:L)), ";phase_;"); + hold off; + endif + figure(2); + endif + % interactive menu printf("\rframe: %d menu: n-next b-back p-png q-quit ", f); diff --git a/codec2/octave/pulse.m b/codec2/octave/pulse.m index 994ceceb..223389e7 100644 --- a/codec2/octave/pulse.m +++ b/codec2/octave/pulse.m @@ -1,21 +1,33 @@ % pulse.m % David Rowe August 2009 -% experiments with human pulse perception for sinusoidal codecs -% lets try some pulses in noise +% +% Experiments with human pulse perception for sinusoidal codecs -function pulse(samname, F0, snr) +function pulse(samname) - N = 16000; - s = zeros(1,N); - Wo = 2*pi*F0/8000; - L = floor(pi/Wo); - A = 10000; - phi = zeros(1,L); - for m=1:L - s = s + (A/L)*cos(m*Wo*(1:N) + phi(m)); + 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 - randn("seed", 0); - s = s + A*(10 .^(-snr/20))*randn(1,N); + plot(s(1:250)); fs=fopen(samname,"wb");