Happy Birthday Pablo 🎂
Hello Pablo! We are really excited it’s your Birthday 🎂🎈🎉🎊🎁 In the spirit of new beginnings, we’ll send our wishes a little bit differently. We’ll R
them to you 😊
Notes for ‘Happy Birthday’ song and their respective values
note <- c('D4', 'D4', 'E4', 'D4', 'G4',
'F#4', 'D4', 'D4', 'E4', 'D4',
'A4', 'G4', 'D4', 'D4', 'D5',
'B4', 'G4', 'F#4', 'E4', 'C5',
'C5', 'B4', 'G4', 'A4', 'G4')
value <- c(rep(c(0.75, 0.25, 1, 1, 1, 2), 2),
0.75, 0.25, 1, 1, 1, 1, 1,
0.75, 0.25, 1, 1, 1, 2)
bday <- cbind.data.frame(note, value)
View(bday)
frequencies of audio waves associated with the notes. Being quite inept at music theory, I’ll scrap the data from Wikipedia.
suppressPackageStartupMessages({
library(htmltab)
library(dplyr)
})
wikitab <- htmltab("https://de.wikipedia.org/wiki/Frequenzen_der_gleichstufigen_Stimmung", 1,
colNames = c("key", "note", "ger", "freq")) %>%
mutate(freq = as.numeric(gsub(",", ".", freq)),
note = substr(note, 0, 3)) %>%
select(-3)
View(wikitab)
Assigning the ‘Happy Birthday’ notes to their corresponding frequencies
bday <- inner_join(bday, wikitab, by= "note") %>% select(-3)
View(bday)
Analog audio is recorded by sampling it 44,100 times per second, and these samples are used to reconstruct the audio signal when playing it back. Sine {sound}
creates samples for a sine wave when provided with a frequency, a duration (note value/BPM) and a sampling rate.
suppressMessages(library(sound))
sine_wave <- mapply(Sine, bday$freq, (bday$value/120)*60, rate = 44100, channels = 1) %>%
do.call("c", .)
bday_tune <- as.Sample(sine_wave)
On behalf of DekutR Data Science Comminity and my fellow Microsoft Learn Student Ambassadors in Kenya, we present to you a ‘Happy BiRthday’ tune made with lots of love and R: 🎵🎵
suppressMessages(library(audio))
audio::play.Sample(bday_tune)
Thank you for all the support and really inspiring us to be a force for good- locally and globally.
Happy Birthday once again 🎂🎈,
Eric.
LS0tDQp0aXRsZTogJyAnDQpvdXRwdXQ6DQogIGh0bWx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