Given a key estimate, transpose chroma vectors back to C.

compmus_c_transpose(dat, key)

Arguments

dat

Data frame with a pitches column containing chroma vectors.

key

Character string naming the global or local tonal centre.

Examples

library(tidyverse)
spotifyr::get_playlist_audio_features("", "37i9dQZF1DWWEcRhUVtL8n") %>%
  slice(1:20) %>%
  add_audio_analysis() %>%
  mutate(segments = map2(segments, key, compmus_c_transpose))
#> # A tibble: 20 × 74
#>    playlist…¹ playl…² playl…³ playl…⁴ playl…⁵ dance…⁶ energy   key loudn…⁷  mode
#>    <chr>      <chr>   <chr>   <chr>   <chr>     <dbl>  <dbl> <int>   <dbl> <int>
#>  1 37i9dQZF1… Indie … https:… Spotify spotify   0.656  0.838     5   -8.41     1
#>  2 37i9dQZF1… Indie … https:… Spotify spotify   0.516  0.322     9  -11.8      1
#>  3 37i9dQZF1… Indie … https:… Spotify spotify   0.663  0.319     9  -13.5      1
#>  4 37i9dQZF1… Indie … https:… Spotify spotify   0.669  0.458     2   -9.01     1
#>  5 37i9dQZF1… Indie … https:… Spotify spotify   0.514  0.305     1  -11.3      0
#>  6 37i9dQZF1… Indie … https:… Spotify spotify   0.329  0.444     1   -9.97     1
#>  7 37i9dQZF1… Indie … https:… Spotify spotify   0.492  0.807    10   -3.68     0
#>  8 37i9dQZF1… Indie … https:… Spotify spotify   0.548  0.456     9   -5.98     1
#>  9 37i9dQZF1… Indie … https:… Spotify spotify   0.646  0.85      2   -5.47     1
#> 10 37i9dQZF1… Indie … https:… Spotify spotify   0.664  0.5       9   -6.94     1
#> 11 37i9dQZF1… Indie … https:… Spotify spotify   0.625  0.412     0   -8.48     1
#> 12 37i9dQZF1… Indie … https:… Spotify spotify   0.646  0.471    10   -9.25     1
#> 13 37i9dQZF1… Indie … https:… Spotify spotify   0.448  0.763     2   -5.42     1
#> 14 37i9dQZF1… Indie … https:… Spotify spotify   0.404  0.268     1   -9.63     1
#> 15 37i9dQZF1… Indie … https:… Spotify spotify   0.702  0.503     4  -10.7      1
#> 16 37i9dQZF1… Indie … https:… Spotify spotify   0.522  0.957     2   -4.92     1
#> 17 37i9dQZF1… Indie … https:… Spotify spotify   0.502  0.416     7   -9.50     1
#> 18 37i9dQZF1… Indie … https:… Spotify spotify   0.765  0.582     0   -4.53     1
#> 19 37i9dQZF1… Indie … https:… Spotify spotify   0.54   0.11      8  -19.9      1
#> 20 37i9dQZF1… Indie … https:… Spotify spotify   0.58   0.788     2   -4.71     1
#> # … with 64 more variables: speechiness <dbl>, acousticness <dbl>,
#> #   instrumentalness <dbl>, liveness <dbl>, valence <dbl>, tempo <dbl>,
#> #   track.id <chr>, analysis_url <chr>, time_signature <int>, added_at <chr>,
#> #   is_local <lgl>, primary_color <lgl>, added_by.href <chr>,
#> #   added_by.id <chr>, added_by.type <chr>, added_by.uri <chr>,
#> #   added_by.external_urls.spotify <chr>, track.artists <list>,
#> #   track.available_markets <list>, track.disc_number <int>, …