Computes a Fourier-based tempogram based on onsets of Spotify segments. Returns a tibble with time, bpm, and power columns. Power is normalised to a max of 1 (Chebyshev norm) within each time point.

tempogram(
  track_analysis,
  window_size = 8,
  hop_size = 1,
  cyclic = FALSE,
  bpms = if (cyclic) 80:160 else 30:600,
  window_function = signal::hamming
)

Arguments

track_analysis

Spotify audio analysis as returned by get_tidy_audio_analysis.

window_size

Window size in seconds (default 8).

hop_size

Hop size in seconds (default 1).

cyclic

Boolean stating whether the tempogram should be cyclic (default not).

bpms

Vector of tempi in beats per minute to include in the tempogram (default 30--200 for non-cyclic and 80--160 for cyclic, inclusive of all integer tempi).

window_function

Window function for the Fourier analysis (default Hamming).

Examples

library(tidyverse)
get_tidy_audio_analysis("6PJasPKAzNLSOzxeAH33j2") %>%
  tempogram(window_size = 4, hop_size = 2)
#> # A tibble: 85,650 × 3
#>     time   bpm  power
#>    <dbl> <int>  <dbl>
#>  1  2.00    30 0.0113
#>  2  2.00    31 0.0127
#>  3  2.00    32 0.0145
#>  4  2.00    33 0.0163
#>  5  2.00    34 0.0181
#>  6  2.00    35 0.0197
#>  7  2.00    36 0.0209
#>  8  2.00    37 0.0217
#>  9  2.00    38 0.0221
#> 10  2.00    39 0.0221
#> # … with 85,640 more rows