aboutsummaryrefslogtreecommitdiff
path: root/octave/pl.m
diff options
context:
space:
mode:
authorAuthor Name <[email protected]>2023-07-07 12:20:59 +0930
committerDavid Rowe <[email protected]>2023-07-07 12:29:06 +0930
commitac7c48b4dee99d4c772f133d70d8d1b38262fcd2 (patch)
treea2d0ace57a9c0e2e5b611c4987f6fed1b38b81e7 /octave/pl.m
shallow zip-file copy from codec2 e9d726bf20
Diffstat (limited to 'octave/pl.m')
-rw-r--r--octave/pl.m45
1 files changed, 45 insertions, 0 deletions
diff --git a/octave/pl.m b/octave/pl.m
new file mode 100644
index 0000000..0d54788
--- /dev/null
+++ b/octave/pl.m
@@ -0,0 +1,45 @@
+% Copyright David Rowe 2009
+% This program is distributed under the terms of the GNU General Public License
+% Version 2
+%
+% Plots a raw speech sample file, you can optionally specify the start and end
+% samples and create a large and small PNGs
+
+function pl(samname1, start_sam, end_sam, pngname)
+
+ fs=fopen(samname1,"rb");
+ s=fread(fs,Inf,"short");
+
+ st = 1;
+ en = length(s);
+ if (nargin >= 2)
+ st = start_sam;
+ endif
+ if (nargin >= 3)
+ en = end_sam;
+ endif
+
+ figure(1);
+ clf;
+ plot(s(st:en));
+ axis([1 en-st 1.1*min(s) 1.1*max(s)]);
+
+ if (nargin == 4)
+
+ % small image
+
+ __gnuplot_set__ terminal png size 420,300
+ ss = sprintf("__gnuplot_set__ output \"%s.png\"", pngname);
+ eval(ss)
+ replot;
+
+ % larger image
+
+ __gnuplot_set__ terminal png size 800,600
+ ss = sprintf("__gnuplot_set__ output \"%s_large.png\"", pngname);
+ eval(ss)
+ replot;
+
+ endif
+
+endfunction