Skip to content

Instantly share code, notes, and snippets.

@cyberdude
Last active November 9, 2017 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cyberdude/ba0ead3abd196eda311d2dc31cb948f7 to your computer and use it in GitHub Desktop.
Save cyberdude/ba0ead3abd196eda311d2dc31cb948f7 to your computer and use it in GitHub Desktop.
Win_size Hope_size
// You can download file here: https://www.dropbox.com/s/ee5bpj6hvjixuna/example2.aif?dl=0
let path = Bundle.main.path(forResource: "example2", ofType: "aif")
if (path != nil) {
let win_size : uint_t = 2048 // Try it with 2048 and then 1024
let hop_size : uint_t = win_size/4
let a = new_fvec(hop_size)
let b = new_aubio_source(path, 0, hop_size)
var read: uint_t = 0
var total_frames : uint_t = 0
let samplerate = aubio_source_get_samplerate(b)
let OUT = new_fvec(1)
let o = new_aubio_tempo("default", win_size, hop_size, samplerate)
print(samplerate)
while (true) {
aubio_source_do(b, a, &read)
aubio_tempo_do(o, a, OUT)
print( aubio_tempo_get_last_ms(o), aubio_tempo_get_last_s(o),
aubio_tempo_get_last(o), aubio_tempo_get_bpm(o), aubio_tempo_get_confidence(o))
total_frames += read
if (read < hop_size) { break }
}
print("read", total_frames, "frames at", aubio_source_get_samplerate(b), "Hz")
del_aubio_source(b)
del_fvec(a)
} else {
print("could not find file")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment