Mercurial > hg > btrack
changeset 109:edb071c0cd1f
Fixed numpy include problem in python module example
author | Adam Stark <adamstark.uk@gmail.com> |
---|---|
date | Sat, 30 Dec 2017 23:48:41 +0000 |
parents | a6701b3f636f |
children | 0fdaf082ad1a |
files | modules-and-plug-ins/python-module/example.py |
diffstat | 1 files changed, 8 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/modules-and-plug-ins/python-module/example.py Tue Sep 12 08:40:16 2017 +0100 +++ b/modules-and-plug-ins/python-module/example.py Sat Dec 30 23:48:41 2017 +0000 @@ -1,6 +1,9 @@ # need scikits audiolab for reading audio files from scikits.audiolab import wavread +# import numpy (needed to convert stereo audio to mono) +import numpy as np + # need to import btrack, our beat tracker import btrack @@ -8,21 +11,21 @@ audioFilePath = "/path/to/your/audioFile.wav" # read the audio file -audioData, fs, enc = wavread(audioFilePath) # extract audio from 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) + audioData = np.average (audioData, axis = 1) # ========================================== # Usage A: track beats from audio -beats = btrack.trackBeats(audioData) +beats = btrack.trackBeats (audioData) # ========================================== # Usage B: extract the onset detection function -onsetDF = btrack.calculateOnsetDF(audioData) +onsetDF = btrack.calculateOnsetDF (audioData) # ========================================== # Usage C: track beats from the onset detection function (calculated in Usage B) -ODFbeats = btrack.trackBeatsFromOnsetDF(onsetDF) +ODFbeats = btrack.trackBeatsFromOnsetDF (onsetDF)