source: python/demos/demo_source_auto_samplerate.py @ c54b2c0

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since c54b2c0 was 08bc714, checked in by Paul Brossier <piem@piem.org>, 12 years ago

demo_source_auto_samplerate.py: add example of automatic samplerate selection

  • Property mode set to 100755
File size: 451 bytes
Line 
1#! /usr/bin/env python
2
3import sys
4from aubio import source
5
6if __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. )
Note: See TracBrowser for help on using the repository browser.