From 13df24c21aac88f8ca0ec1a2059b939b5f0caa2e Mon Sep 17 00:00:00 2001 From: drowe67 Date: Sat, 13 Nov 2010 02:39:31 +0000 Subject: [PATCH] plotting improved voicing git-svn-id: https://svn.code.sf.net/p/freetel/code@222 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2/octave/plvoicing.m | 46 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/codec2/octave/plvoicing.m b/codec2/octave/plvoicing.m index 7285d38e..a5317476 100644 --- a/codec2/octave/plvoicing.m +++ b/codec2/octave/plvoicing.m @@ -20,6 +20,21 @@ function plvoicing(samfilename, samname, start_f, end_f, pngname) model_name = strcat(samname,"_model.txt"); model = load(model_name); + Wo = model((start_f+1):end_f,1); + F0 = Wo*4000/pi; + dF0 = F0(1:length(Wo)-1) - F0(2:length(Wo)); + + % work out LP and HP energy + + for f=(start_f+1):end_f + L = model(f,2); + Am = model(f,3:(L+2)); + L2 = floor(L/2); + elow = Am(1:L2) * Am(1:L2)'; + ehigh = Am(L2:L) * Am(L2:L)'; + erat(f-(start_f+1)+1) = 10*log10(elow/ehigh); + endfor + figure(1); clf; sp = s((start_f-2)*80:(end_f-2)*80); @@ -27,10 +42,33 @@ function plvoicing(samfilename, samname, start_f, end_f, pngname) hold on; vhigh = snr((start_f+1):end_f) > 7; vlow = snr((start_f+1):end_f) > 4; + + % test correction based on erat + + vlowadj = vlow; + + for f=1:length(erat)-1 + if (vlow(f) == 0) + if (erat(f) > 10) + vlowadj(f) = 1; + endif + endif + if (vlow(f) == 1) + if (erat(f) < -10) + vlowadj(f) = 0; + endif + if (abs(dF0(f)) > 15) + vlowadj(f) = 0; + endif + endif + endfor + x = 1:(end_f-start_f); plot(x*80,snr((start_f+1):end_f)*1000,';SNRdB x 1000;g+'); plot(x*80,-8000 + vhigh*2000,';7dB thresh;g'); - plot(x*80,-11000 + vlow*2000,';4dB thresh;r'); + plot(x*80,-11000 + vlowadj*2000,';vlow with corr;g'); + plot(x*80,erat*1000,';elow/ehigh in dB;r'); + plot(x*80,-14000 + vlow*2000,';4dB thresh;r'); hold off; grid if (nargin == 5) @@ -40,8 +78,12 @@ function plvoicing(samfilename, samname, start_f, end_f, pngname) figure(2) Wo = model((start_f+1):end_f,1); F0 = Wo*4000/pi; - %dF0 = F0(1:length(Wo)-1) - F0(2:length(Wo)); + dF0 = F0(1:length(Wo)-1) - F0(2:length(Wo)); %plot(dF0,'+--') + %hold on; + %plot([ 1 length(dF0) ], [10 10] ,'r') + %plot([ 1 length(dF0) ], [-10 -10] ,'r') %axis([1 length(dF0) -50 50]) + %hold off; plot(F0,'+--') endfunction -- 2.25.1