python/demos/demo_miditofreq.py: added simple miditofreq example
authorPaul Brossier <piem@piem.org>
Fri, 22 Mar 2013 17:35:26 +0000 (12:35 -0500)
committerPaul Brossier <piem@piem.org>
Fri, 22 Mar 2013 17:35:26 +0000 (12:35 -0500)
python/demos/demo_miditofreq.py [new file with mode: 0755]

diff --git a/python/demos/demo_miditofreq.py b/python/demos/demo_miditofreq.py
new file mode 100755 (executable)
index 0000000..c325fb5
--- /dev/null
@@ -0,0 +1,17 @@
+#! /usr/bin/env python
+
+from aubio import miditofreq
+from numpy import arange
+
+upsampling = 100.
+midi = arange(-10, 148 * upsampling)
+midi /= upsampling
+freq = miditofreq(midi)
+
+from matplotlib import pyplot as plt
+
+ax = plt.axes()
+ax.semilogy(midi, freq, '.')
+ax.set_xlabel('midi note')
+ax.set_ylabel('frequency (Hz)')
+plt.show()