Various packages implement a spectrogram method including
seewave, tuneR, phonTools, and
gsignal. The problem is that they don’t return spectrograms
in a standard format. With retimer you can use the
spectrogram() wrapper to create a spectrogram with any of
these packages and either return a list or a
tibble.
For example, we can use the tuneR::powerspec() method
like so:
and then plot it in base R:
Or we could output as a tibble (the default output) like
so:
and then plot it with ggplot2:
phontools_spec |>
    ggplot() +
    geom_raster(aes(t, f, fill = amp), show.legend = F) +
    scale_fill_viridis_c()We should get similar results with different methods:
list(seewave = 'seewave', phontools = 'phontools', tuner = 'tuner', gsignal = 'gsignal') |>
    lapply(\(method) spectrogram(mm1, method = method)) |>
    bind_rows(.id = 'method') |>
    mutate(method = factor(method, levels = c('seewave', 'phontools', 'tuner', 'gsignal'))) |>
    group_by(method) |>
    mutate(amp = amp - min(amp),
           amp = amp / max(amp)) |>
    ungroup() |>
    ggplot() +
    geom_raster(aes(t, f, fill = amp), show.legend = F) +
    facet_grid(rows = vars(method)) +
    scale_fill_viridis_c()