knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ini0 <- Sys.time()
# CRAN (stable) install.packages('voice', dep = TRUE) # Github (development) devtools::install_github('filipezabala/voice')
https://github.com/filipezabala/voice
wavFiles <- list.files(system.file('extdata', package = 'wrassp'), pattern <- glob2rx('*.wav'), full.names = TRUE)
M <- voice::extract_features(wavFiles) dplyr::glimpse(M)
E <- dplyr::tibble(subject_id = c(1,1,1,2,2,2,3,3,3), wav_path = wavFiles) E
voice::tag(E)
voice::tag(E, groupBy = 'subject_id')
url0 <- 'https://github.com/filipezabala/voiceAudios/blob/main/wav/doremi.wav?raw=true' download.file(url0, paste0(tempdir(), '/doremi.wav'), mode = 'wb') # embedr::embed_audio(url0)
M <- voice::extract_features(tempdir(), features = 'f0') summary(M)
# Plot plot(M$f0) legend(-60, 170, 'Do (C3)' , bty = 'n') legend(80, 190 , 'Re (D3)' , bty = 'n') legend(220, 290, 'Mi (E4)' , bty = 'n') legend(350, 210, 'Fa (F3)' , bty = 'n') legend(480, 250, 'Sol (G3)', bty = 'n') legend(600, 270, 'La (A3)' , bty = 'n') legend(720, 310, 'Si (B3)' , bty = 'n') legend(910, 320, 'Do (C4)' , bty = 'n')
(note1 <- median(M$f0[1:150], na.rm = TRUE)) voice::notes(note1) (note2 <- median(M$f0[190:280], na.rm = TRUE)) voice::notes(note2) (note3 <- median(M$f0[310:380], na.rm = TRUE)) voice::notes(note3) (note4 <- median(M$f0[420:500], na.rm = TRUE)) voice::notes(note4) (note5 <- median(M$f0[590:630], na.rm = TRUE)) voice::notes(note5) (note6 <- median(M$f0[700:770], na.rm = TRUE)) voice::notes(note6) (note7 <- median(M$f0[820:900], na.rm = TRUE)) voice::notes(note7) (note8 <- median(M$f0[950:1100], na.rm = TRUE)) voice::notes(note8)
# gather (manually) (notes_vec <- c(paste0('note', 1:8), 'note8')) (f0_spn <- voice::notes(mget(notes_vec))) # duration (dur <- voice::duration(f0_spn)) # gm by Renfei Mao m <- gm::Music() m <- m + gm::Meter(4, 4) + gm::Line(pitches = as.list(as.character(dur$note)), durations = as.list(dur$dur_line)) + gm::Tempo(100) # gm::show(m, to = c('score', 'audio'))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.