History

demo_source_auto_samplerate.py: add example of automatic samplerate selection

Paul Brossier committed 13 years ago

Commit 08bc7141 parent d7954631 file · +17 −0Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

python/demos/demo_source_auto_samplerate.py+17−0
@@ -0,0 +1,17 @@
1+#! /usr/bin/env python
2+
3+import sys
4+from aubio import source
5+
6+if __name__ == '__main__':
7+ if len(sys.argv) < 2:
8+ print 'usage: %s <inputfile>' % sys.argv[0]
9+ sys.exit(1)
10+ f = source(sys.argv[1], 0, 256)
11+ samplerate = f.get_samplerate()
12+ total_frames, read = 0, 256
13+ while read:
14+ vec, read = f()
15+ total_frames += read
16+ print f.uri, "is",
17+ print "%.2f seconds long at %.1fkHz" % (total_frames / float(samplerate), samplerate / 1000. )

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t