aboutsummaryrefslogtreecommitdiff
path: root/octave/pitch_test.m
diff options
context:
space:
mode:
Diffstat (limited to 'octave/pitch_test.m')
-rw-r--r--octave/pitch_test.m39
1 files changed, 39 insertions, 0 deletions
diff --git a/octave/pitch_test.m b/octave/pitch_test.m
new file mode 100644
index 0000000..3fe0d1a
--- /dev/null
+++ b/octave/pitch_test.m
@@ -0,0 +1,39 @@
+% pitch_test.m
+% David Rowe Sep 2009
+% Constructs a sequence to test the pitch estimator
+
+function pitch_test(samname)
+ M=320;
+ F=200;
+
+ fs=fopen(samname,"wb");
+
+ f0 = 100;
+ for f=1:200
+ Wo=2*pi*f0/8000;
+ P=2*pi/Wo;
+ L = floor(pi/Wo);
+ A = 10000/L;
+ phi = zeros(1,L);
+ s = zeros(1,M);
+
+ for m=1:L
+ s = s + A*cos(m*Wo*(0:(M-1)) + phi(m));
+ endfor
+
+ figure(1);
+ clf;
+ plot(s);
+
+ fwrite(fs,s,"short");
+
+ f0 = f0 + 5;
+ if (f0 > 400)
+ f0 = 100;
+ endif
+ endfor
+
+ fclose(fs);
+
+endfunction
+