40 lines · 943 B · Python
RawDownload
#! /usr/bin/env python import sysfrom aubio import tempo, source win_s = 512                 # fft sizehop_s = win_s // 2          # hop size if len(sys.argv) < 2:    print("Usage: %s <filename> [samplerate]" % sys.argv[0])    sys.exit(1) filename = sys.argv[1] samplerate = 0if len( sys.argv ) > 2: samplerate = int(sys.argv[2]) s = source(filename, samplerate, hop_s)samplerate = s.samplerateo = tempo("default", win_s, hop_s, samplerate) # tempo detection delay, in samples# default to 4 blocks delay to catch up withdelay = 4. * hop_s # list of beats, in samplesbeats = [] # total number of frames readtotal_frames = 0while True:    samples, read = s()    is_beat = o(samples)    if is_beat:        this_beat = int(total_frames - delay + is_beat[0] * hop_s)        print("%f" % (this_beat / float(samplerate)))        beats.append(this_beat)    total_frames += read    if read < hop_s: break#print len(beats)

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