demo_source.py: added simple example
authorPaul Brossier <piem@piem.org>
Sun, 15 Jul 2012 22:29:37 +0000 (16:29 -0600)
committerPaul Brossier <piem@piem.org>
Sun, 15 Jul 2012 22:29:37 +0000 (16:29 -0600)
interfaces/python/demo_source.py [new file with mode: 0755]

diff --git a/interfaces/python/demo_source.py b/interfaces/python/demo_source.py
new file mode 100755 (executable)
index 0000000..5c91236
--- /dev/null
@@ -0,0 +1,15 @@
+#! /usr/bin/python
+
+import sys
+from aubio import source
+
+if __name__ == '__main__':
+  if len(sys.argv) < 2:
+    print 'usage: %s <inputfile>' % sys.argv[0]
+    sys.exit(1)
+  f = source(sys.argv[1], 8000, 256)
+  total_frames, read = 0, 256
+  while read:
+    vec, read = f()
+    total_frames += read
+  print "read", total_frames / float(f.samplerate), "seconds from", f.uri