little script to compare two spectrograms
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 22 Aug 2012 04:21:34 +0000 (04:21 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 22 Aug 2012 04:21:34 +0000 (04:21 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@635 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/octave/cspec.m [new file with mode: 0644]

diff --git a/codec2-dev/octave/cspec.m b/codec2-dev/octave/cspec.m
new file mode 100644 (file)
index 0000000..e0ca15b
--- /dev/null
@@ -0,0 +1,54 @@
+% cspec.m
+% David Rowe Aug 2012
+% Used to compare spectromgrams while experimenting with phase
+
+function cspec(s1,s2)
+  f1 = fopen(s1,"rb");
+  s1 = fread(f1,Inf,"short");
+  f2 = fopen(s2,"rb");
+  s2 = fread(f2,Inf,"short");
+
+  Fs = 8000;
+  spec_win = 512;
+
+  state = 's1';
+  do 
+    if strcmp(state,'s1')
+      spec(s1,Fs,spec_win);
+      %title(s1);
+    end
+    if strcmp(state,'s2')
+      spec(s2,Fs,spec_win);
+      %title(s2);
+    end
+    if strcmp(state,'diff')
+      spec(s1-s2,Fs,spec_win);
+      %title("difference");
+    end
+
+    printf("\rstate: %s  space-toggle d-diff q-quit", state);
+    fflush(stdout);
+    k = kbhit();
+    
+    if k == ' '
+      if strcmp(state,"diff")
+        next_state = 's1';
+      end
+      if strcmp(state,"s1")
+        next_state = 's2';
+      end
+      if strcmp(state,'s2')
+        next_state = 's1';
+      end
+    end
+
+    if k == 'd'
+      next_state = 'diff';
+    end
+
+    state = next_state;
+  until (k == 'q')
+
+  printf("\n");
+
+endfunction