Mercurial > hg > btrack
comparison modules-and-plug-ins/python-module/example.py @ 30:687b8dd41934 develop
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 <adamstark.uk@gmail.com> |
---|---|
date | Tue, 28 Jan 2014 01:07:44 +0000 |
parents | |
children | 2716b8d1b8ad |
comparison
equal
deleted
inserted
replaced
29:bddd59087c36 | 30:687b8dd41934 |
---|---|
1 # need scikits audiolab for reading audio files | |
2 from scikits.audiolab import wavread | |
3 | |
4 # need to import btrack, our beat tracker | |
5 import btrack | |
6 | |
7 # set the path to an audio file on your machine | |
8 audioFilePath = "/Users/adamstark/Documents/Audio/Databases/Hainsworth/audio/001.wav" | |
9 | |
10 # read the audio file | |
11 audioData, fs, enc = wavread(audioFilePath) # extract audio from file | |
12 | |
13 # convert to mono if need be | |
14 if (audioData[0].size == 2): | |
15 print "converting to mono" | |
16 data = np.average(data,axis=1) | |
17 | |
18 # ========================================== | |
19 # Usage A: track beats from audio | |
20 beats = btrack.trackBeats(audioData) | |
21 | |
22 # ========================================== | |
23 # Usage B: extract the onset detection function | |
24 onsetDF = btrack.calculateOnsetDF(audioData) | |
25 | |
26 # ========================================== | |
27 # Usage C: track beats from the onset detection function (calculated in Usage B) | |
28 ODFbeats = btrack.trackBeatsFromOnsetDF(onsetDF) |