4 from aubio import tempo, source
7 hop_s = win_s // 2 # hop size
10 print("Usage: %s <filename> [samplerate]" % sys.argv[0])
13 filename = sys.argv[1]
16 if len( sys.argv ) > 2: samplerate = int(sys.argv[2])
18 s = source(filename, samplerate, hop_s)
19 samplerate = s.samplerate
20 o = tempo("default", win_s, hop_s, samplerate)
22 # tempo detection delay, in samples
23 # default to 4 blocks delay to catch up with
26 # list of beats, in samples
29 # total number of frames read
35 this_beat = int(total_frames - delay + is_beat[0] * hop_s)
36 print("%f" % (this_beat / float(samplerate)))
37 beats.append(this_beat)
39 if read < hop_s: break