comparison modules-and-plug-ins/python-module/example.py @ 72:f4d9410f187e

flow: Merged <release> '1.0.0' to <master> ('master').
author Adam Stark <adamstark@users.noreply.github.com>
date Tue, 08 Jul 2014 12:32:27 +0100
parents ae3ec9b14092
children 2716b8d1b8ad
comparison
equal deleted inserted replaced
44:3049937d6ef1 72:f4d9410f187e
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)