Note
Go to the end to download the full example code.
Beat tracking and tempo
beat_track estimates the tempo and places beats on the onset envelope. The
helper mpl.plot_beats draws them over the waveform.
import numpy as np
import audio_samples as aus
from audio_samples import effects, mpl
A click track at 120 beats per minute.
sr = 22050
times = np.arange(0.5, 8.0, 0.5)
y = effects.clicks(times=times, sr=sr, length=8 * sr)
audio = aus.AudioSamples.new_mono(y.astype(np.float32), sr)
tempo 117.5 BPM, 15 beats
Total running time of the script: (0 minutes 1.626 seconds)