From 08bc714f24a5d845a28b0eb06dc8b1cb0349aefb Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Mon, 11 Feb 2013 16:31:37 -0500 Subject: [PATCH] demo_source_auto_samplerate.py: add example of automatic samplerate selection --- python/demos/demo_source_auto_samplerate.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 python/demos/demo_source_auto_samplerate.py diff --git a/python/demos/demo_source_auto_samplerate.py b/python/demos/demo_source_auto_samplerate.py new file mode 100755 index 00000000..31ba55af --- /dev/null +++ b/python/demos/demo_source_auto_samplerate.py @@ -0,0 +1,17 @@ +#! /usr/bin/env python + +import sys +from aubio import source + +if __name__ == '__main__': + if len(sys.argv) < 2: + print 'usage: %s ' % sys.argv[0] + sys.exit(1) + f = source(sys.argv[1], 0, 256) + samplerate = f.get_samplerate() + total_frames, read = 0, 256 + while read: + vec, read = f() + total_frames += read + print f.uri, "is", + print "%.2f seconds long at %.1fkHz" % (total_frames / float(samplerate), samplerate / 1000. ) -- 2.11.0