pl.m 916 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. % Copyright David Rowe 2009
  2. % This program is distributed under the terms of the GNU General Public License
  3. % Version 2
  4. %
  5. % Plots a raw speech sample file, you can optionally specify the start and end
  6. % samples and create a large and small PNGs
  7. function pl(samname1, start_sam, end_sam, pngname)
  8. fs=fopen(samname1,"rb");
  9. s=fread(fs,Inf,"short");
  10. st = 1;
  11. en = length(s);
  12. if (nargin >= 2)
  13. st = start_sam;
  14. endif
  15. if (nargin >= 3)
  16. en = end_sam;
  17. endif
  18. figure(1);
  19. clf;
  20. plot(s(st:en));
  21. axis([1 en-st 1.1*min(s) 1.1*max(s)]);
  22. if (nargin == 4)
  23. % small image
  24. __gnuplot_set__ terminal png size 420,300
  25. ss = sprintf("__gnuplot_set__ output \"%s.png\"", pngname);
  26. eval(ss)
  27. replot;
  28. % larger image
  29. __gnuplot_set__ terminal png size 800,600
  30. ss = sprintf("__gnuplot_set__ output \"%s_large.png\"", pngname);
  31. eval(ss)
  32. replot;
  33. endif
  34. endfunction