From 3a4a53b864eee54829ce84f9ce3259a3c23c1c96 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Mon, 31 Oct 2011 03:55:28 +0000 Subject: [PATCH] tweaked soem of the LSP scripts while working on dropping LSP bit rate git-svn-id: https://svn.code.sf.net/p/freetel/code@293 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/octave/lsp_pdf.m | 19 ++++++++++++------- codec2-dev/octave/pllsp.m | 10 +++++----- codec2-dev/octave/pllspdt.m | 27 +++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 codec2-dev/octave/pllspdt.m diff --git a/codec2-dev/octave/lsp_pdf.m b/codec2-dev/octave/lsp_pdf.m index b54127fd..4fc1359a 100644 --- a/codec2-dev/octave/lsp_pdf.m +++ b/codec2-dev/octave/lsp_pdf.m @@ -10,15 +10,16 @@ function lsp_pdf(lsp) figure(1); clf; [x,y] = hist(lsp(:,1),100); - plot(y*4000/pi,x,";1;"); + plot(y*4000/pi,x,"+;1;"); hold on; - for i=2:c + for i=2:5 + [x,y] = hist(lsp(:,i),100); + legend = sprintf("+%d;%d;",i,i); + plot(y*4000/pi,x,legend); + endfor + for i=6:c [x,y] = hist(lsp(:,i),100); - if (mod(i,2)) - legend = sprintf(";%d;",i); - else - legend = sprintf("1;%d;",i); - endif + legend = sprintf("+%d;%d;",i-5,i); plot(y*4000/pi,x,legend); endfor hold off; @@ -83,4 +84,8 @@ function lsp_pdf(lsp) hold off; grid; axis([-200 200 0 16000]); + + figure(4); + clf; + plot((4000/pi)*(lsp(2:r,3)-lsp(1:r-1,3))) endfunction diff --git a/codec2-dev/octave/pllsp.m b/codec2-dev/octave/pllsp.m index f66e7ab2..7602fa3b 100644 --- a/codec2-dev/octave/pllsp.m +++ b/codec2-dev/octave/pllsp.m @@ -2,7 +2,7 @@ % This program is distributed under the terms of the GNU General Public License % Version 2 % -% Plots a bunch of information realted to LSP quantisation: +% Plots a bunch of information related to LSP quantisation: % - speech file % - LSPs before and after quantisation % - SNR for each frame @@ -10,10 +10,10 @@ % Note: there is a 160 sample (two frame delay) from the when a sample % enters the input buffer until it is at the centre of the analysis window -function pl(rawfile, - dumpfile_prefix_lpc_only, - dumpfile_prefix_lsp, - start_f, end_f) +function pllsp(rawfile, + dumpfile_prefix_lpc_only, + dumpfile_prefix_lsp, + start_f, end_f) fs=fopen(rawfile,"rb"); s=fread(fs,Inf,"short"); diff --git a/codec2-dev/octave/pllspdt.m b/codec2-dev/octave/pllspdt.m new file mode 100644 index 00000000..c711aa46 --- /dev/null +++ b/codec2-dev/octave/pllspdt.m @@ -0,0 +1,27 @@ +% pllspdt.m +% Copyright David Rowe 2010 +% This program is distributed under the terms of the GNU General Public License +% Version 2 +% +% Test script to plot differences in LSps between frames + +function pllspdt(rawfile,dumpfile_prefix_lsp,lspn, start_f, end_f) + + fs=fopen(rawfile,"rb"); + s=fread(fs,Inf,"short"); + + lsp_name = strcat(dumpfile_prefix_lsp,"_lsp.txt"); + lsps = load(lsp_name); + [m,n]=size(lsps); + lsp = lsps(1:2:m,:); + lsp_ = lsps(2:2:m,:); + lspdt = lsp(2:m/2,:) - lsp(1:m/2-1,:); + + figure(1); + clf; + sp = s((start_f-2)*80:(end_f-2)*80); + plot(sp); + + figure(2); + plot((4000/pi)*lspdt((start_f+1):end_f,lspn)); +endfunction -- 2.25.1