source: interfaces/python/demo_beat.py @ b517cb3

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

merge from master, print beats once in demo_beat.py

  • Property mode set to 100644
File size: 688 bytes
Line 
1#! /usr/bin/python
2
3import sys
4from os.path import splitext, basename
5from aubio import tempo
6from aubioinput import aubioinput
7
8win_s = 512                 # fft size
9hop_s = win_s / 2           # hop size
10beat = tempo("default", win_s, hop_s)
11
12beats = []
13
14def process(samples, pos):
15    isbeat = beat(samples)
16    if isbeat:
17        thisbeat = (float(isbeat[0]) + pos * hop_s) / 44100.
18        print thisbeat
19        beats.append (thisbeat)
20
21if len(sys.argv) < 2:
22    print "Usage: %s <filename>" % sys.argv[0]
23else:
24    filename = sys.argv[1]
25    a = aubioinput(filename, process = process, hopsize = hop_s,
26            caps = 'audio/x-raw-float, rate=44100, channels=1')
27    a.run()
Note: See TracBrowser for help on using the repository browser.