From 5da605e1279081b58604cd50c31530b8a1cfe918 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Mon, 14 May 2012 20:23:39 +0000 Subject: [PATCH] conference demo script git-svn-id: https://svn.code.sf.net/p/freetel/code@461 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/octave/codec2_demo.m | 108 ++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 codec2-dev/octave/codec2_demo.m diff --git a/codec2-dev/octave/codec2_demo.m b/codec2-dev/octave/codec2_demo.m new file mode 100644 index 00000000..0f3950bf --- /dev/null +++ b/codec2-dev/octave/codec2_demo.m @@ -0,0 +1,108 @@ +% Copyright David Rowe 2012 +% This program is distributed under the terms of the GNU General Public License +% Version 2 +% +% codec2_demo.m + +% Designed as an educational tool to explain the operation of Codec 2 +% for conference and user group presentations on a projector. An +% alternative to static overhead slides. +% +% Derived from codec2-dev/octave/plamp.m +% +% usage: +% octave:1> plamp("../src/hts2a",40) +% +% Then press: +% c - to cycle through the wavform being displayed on the figure +% n - next frame +% b - back one frame +% +% tip: hold down n or b to animate the display +% +% The text files used as input are generated using c2sim: +% +% /codec2-dev/src$ c2sim ../raw/hts2a.raw --dump hts2a +% +% The Codec 2 README explains how to build c2sim with dump files +% enabled. + +function codec2_demo(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); + + figure(1); + + k = ' '; + wf = "Sn"; + do + + if strcmp(wf,"Sn") + clf; + s = [ Sn(2*f-1,:) Sn(2*f,:) ]; + plot(s); + axis([1 length(s) -20000 20000]); + end + + if (strcmp(wf,"Sw")) + clf; + plot((0:255)*4000/256, Sw(f,:),";Sw;"); + end + + if strcmp(wf,"SwAm") + Wo = model(f,1); + L = model(f,2); + Am = model(f,3:(L+2)); + plot((0:255)*4000/256, Sw(f,:),";Sw;"); + hold on; + plot((1:L)*Wo*4000/pi, 20*log10(Am),"+;Am;r"); + axis([1 4000 -10 80]); + hold off; + end + + if strcmp(wf,"Am") + 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]); + end + + % interactive menu + + printf("\rframe: %d menu: n-next b-back w-cycle window q-quit", f); + fflush(stdout); + k = kbhit(); + if (k == 'n') + f = f + 1; + end + if (k == 'b') + f = f - 1; + end + if (k == 'w') + if strcmp(wf,"Sn") + next_wf = "Sw"; + end + if strcmp(wf,"Sw") + next_wf = "SwAm"; + end + if strcmp(wf,"SwAm") + next_wf = "Am"; + end + if strcmp(wf,"Am") + next_wf = "Sn"; + end + wf = next_wf; + end + + until (k == 'q') + printf("\n"); + +endfunction -- 2.25.1