# HG changeset patch # User Chris Cannam # Date 1349705987 -3600 # Node ID d43d1adecea652e51663d37085792b172561b186 # Parent 99038dfea9e5b61cadcdb227744379f61848c40c Sketch implementation of tempo estimator diff -r 99038dfea9e5 -r d43d1adecea6 tempo_estimator.py --- 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)