2
0

cspec.m 986 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. % cspec.m
  2. % David Rowe Aug 2012
  3. % Used to compare spectromgrams while experimenting with phase
  4. function cspec(s1,s2)
  5. f1 = fopen(s1,"rb");
  6. s1 = fread(f1,Inf,"short");
  7. f2 = fopen(s2,"rb");
  8. s2 = fread(f2,Inf,"short");
  9. Fs = 8000;
  10. spec_win = 512;
  11. state = 's1';
  12. do
  13. if strcmp(state,'s1')
  14. spec(s1,Fs,spec_win);
  15. %title(s1);
  16. end
  17. if strcmp(state,'s2')
  18. spec(s2,Fs,spec_win);
  19. %title(s2);
  20. end
  21. if strcmp(state,'diff')
  22. spec(s1-s2,Fs,spec_win);
  23. %title("difference");
  24. end
  25. printf("\rstate: %s space-toggle d-diff q-quit", state);
  26. fflush(stdout);
  27. k = kbhit();
  28. if k == ' '
  29. if strcmp(state,"diff")
  30. next_state = 's1';
  31. end
  32. if strcmp(state,"s1")
  33. next_state = 's2';
  34. end
  35. if strcmp(state,'s2')
  36. next_state = 's1';
  37. end
  38. end
  39. if k == 'd'
  40. next_state = 'diff';
  41. end
  42. state = next_state;
  43. until (k == 'q')
  44. printf("\n");
  45. endfunction