Mercurial > hg > btrack
view modules-and-plug-ins/python-module/example.py @ 89:5ef334c782f3
Moved some parts of the algorithm from arrays needing lots of data moved around to lighted circular buffers
author | Adam Stark <adamstark.uk@gmail.com> |
---|---|
date | Fri, 04 Mar 2016 18:10:23 +0000 |
parents | ae3ec9b14092 |
children | 2716b8d1b8ad |
line wrap: on
line source
# need scikits audiolab for reading audio files from scikits.audiolab import wavread # need to import btrack, our beat tracker import btrack # set the path to an audio file on your machine audioFilePath = "/Users/adamstark/Documents/Audio/Databases/Hainsworth/audio/001.wav" # read the audio file audioData, fs, enc = wavread(audioFilePath) # extract audio from file # convert to mono if need be if (audioData[0].size == 2): print "converting to mono" data = np.average(data,axis=1) # ========================================== # Usage A: track beats from audio beats = btrack.trackBeats(audioData) # ========================================== # Usage B: extract the onset detection function onsetDF = btrack.calculateOnsetDF(audioData) # ========================================== # Usage C: track beats from the onset detection function (calculated in Usage B) ODFbeats = btrack.trackBeatsFromOnsetDF(onsetDF)