changeset 9:d43d1adecea6

Sketch implementation of tempo estimator
author Chris Cannam
date Mon, 08 Oct 2012 15:19:47 +0100
parents 99038dfea9e5
children 7fc62809da94
files tempo_estimator.py
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/tempo_estimator.py	Mon Oct 08 15:12:37 2012 +0100
+++ b/tempo_estimator.py	Mon Oct 08 15:19:47 2012 +0100
@@ -1,5 +1,15 @@
+
+import audiofile as af
+
+def estimate_tempo_of_samples(samples, samplerate):
+    """Given some audio samples and their samplerate, return their estimated tempo in bpm."""
+    df = detection_function(samples)
+    acf = autocorrelation(df)
+    tempo = find_tempo_from_autocorrelation(acf)
+    return tempo
 
 def estimate_tempo_of_file(filename):
     """Given the name of a WAV file, return the estimated tempo in bpm."""
-    return 0
+    (samples, samplerate) = af.read_all_mono_samples_from_file(filename)
+    return estimate_tempo_of_samples(samples, samplerate)