amads.time.tempo#

This module provides functions for analyzing tempo characteristics in musical performances. It includes calculations for tempo slope, tempo drift, and tempo fluctuation.

References:
  • Cheston, H., Schlichting, J. L., Cross, I., & Harrison, P. M. C. (2024). Jazz Trio Database: Automated Annotation of Jazz Piano Trio Recordings Processed Using Audio Source Separation. Transactions of the International Society for Music Information Retrieval, 7(1), 144–158. https://doi.org/10.5334/tismir.186

  • Cheston, H., Cross, I., & Harrison, P. (2024). Trade-offs in Coordination Strategies for Duet Jazz Performances Subject to Network Delay and Jitter. Music Perception, 42(1), 48–72. https://doi.org/10.1525/mp.2024.42.1.48

Author:

Huw Cheston (2025)

amads.time.tempo.beats_to_tempo(beats) ndarray[source]#

Converts beat timestamps to instantaneous tempo measurements.

Parameters:

beats (ndarray)

Return type:

ndarray

amads.time.tempo.fit_tempo_linear_regression(beats)[source]#

Fits linear regression of BPM measurements vs. onset time.

Parameters:

beats (Iterable[float])

amads.time.tempo.tempo_fluctuation(beats) float[source]#

Calculates the fluctuation around the overall tempo of a sequence of beats.

Tempo fluctuation is measured as the standard deviation of the instantaneous tempo, normalized by the mean tempo. Higher values indicate greater variability in tempo.

The equation is:

\[\text{F} = \dfrac{\sqrt{\frac{1}{N-1} \sum\limits_{i=1}^N (y_i - \bar{y})^2}}{\bar{y}},\]

where \(y_i\) is the tempo value in (quarter-note) beats-per-minute at beat \(i\).

Parameters:

beats (Iterable[float]) – An iterable of beat timestamps in seconds, such as quarter-note onsets.

Returns:

The computed tempo fluctuation value.

Return type:

float

amads.time.tempo.tempo_mean(beats)[source]#

Calculates the mean tempo from an iterable of timestamps in quarter-note beats-per-minute.

The mean tempo can be calculated simply as:

\[\bar{y} = \dfrac{\sum\limits_{i=1}^N\frac{60}{x_i - x_{i-1}}}{N-1}\]

where \(x_i\) is the time of beat \(i\) (and \(i \geq 1\)) and \(N\) is the number of beats.

Parameters:

beats (Iterable[float]) – An iterable of beat timestamps in seconds, such as quarter-note onsets.

Returns:

The computed mean tempo value.

Return type:

float

amads.time.tempo.tempo_slope(beats) float[source]#

Calculates the tempo slope for a sequence of beat timestamps.

The tempo slope represents the overall tempo change per second in a performance. It is determined by the slope of a linear regression of instantaneous tempo against beat onset time. A negative slope indicates deceleration, while a positive slope indicates acceleration. The units are (quarter-note) beats-per-minute-per-second

The equation is:

\[\hat{S} = \frac{\sum\limits_{i=1}^N (x_i - \bar{x}) (y_i - \bar{y})}{\sum\limits_{i=1}^N (x_i - \bar{x})^2},\]

where \(x_i\) is the time of beat \(i\) and \(y_i\) is the tempo value in (quarter-note) beats-per-minute.

Parameters:

beats (Iterable[float]) – An iterable of beat timestamps in seconds, such as quarter-note onsets.

Returns:

The computed tempo slope value.

Return type:

float