Mercurial > hg > btrack
diff modules-and-plug-ins/python-module/example.py @ 67:ae3ec9b14092
Updated README, installation instructions for Python module and added an example.py file to explain how to use the Python module. Also regenerated documentation.
author | Adam Stark <adamstark@users.noreply.github.com> |
---|---|
date | Tue, 28 Jan 2014 01:07:44 +0000 |
parents | |
children | 2716b8d1b8ad |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules-and-plug-ins/python-module/example.py Tue Jan 28 01:07:44 2014 +0000 @@ -0,0 +1,28 @@ +# 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)