Skip to content

daroczig/singR

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
R
 
 
 
 
man
 
 
 
 
 
 
 
 
 
 

singR: helper functions to "sing" songs with R

Initially created for Code Poetry Slam 2.0, where I plan to tribute to the KC & The Sunshine Band for Give It Up. Yes, this is a fun project -- but I'm happy to merge serious pull requests :)

Installation

This will probably never end up on CRAN:

devtools::install_github('daroczig/singR')

POC pseudo-R code

The minimal version:

while (TRUE)
    give_up(it)

The refrain of the classic "Give It Up" song:

rep(NA, 11)
give_up(what = it, who = Baby)
give_up(what = it)
give_up(what = it, who = Baby)
rep(NA, 11)
give_up(what = it, who = Baby)
give_up(what = it)
give_up(what = it, who = Baby)
verify(give_up(what = it, who = you), times = 2)
give_up(what = it)

Some parts of the above pseudo-R script actually works, e.g. the "Na, na, na, na ..." part:

> rep(NA, 11)
 [1] NA NA NA NA NA NA NA NA NA NA NA

And we can also implement e.g. a minimal give_up function easily:

give_up <- function(what, who = '')
	sprintf('%s give %s up', who, what)

Working R code

After loading the singR package, the above psuedo-code should work:

> library(singR)
> rep(NA, 11)
 [1] NA NA NA NA NA NA NA NA NA NA NA
> give_up(what = it, who = Baby)
[1] "Baby give it up!"
> give_up(what = it)
[1] "Give it up!"
> give_up(what = it, who = Baby)
[1] "Baby give it up!"
> rep(NA, 11)
 [1] NA NA NA NA NA NA NA NA NA NA NA
> give_up(what = it, who = Baby)
[1] "Baby give it up!"
> give_up(what = it)
[1] "Give it up!"
> give_up(what = it, who = Baby)
[1] "Baby give it up!"
> verify(give_up(what = it, who = you), times = 2)
[1] "Can you give it up?" "Can you give it up?"
> give_up(what = it)
[1] "Give it up!"

Let R sing the song!

Building on the koRpus package, we can easily find all the syllables that can be written to the standard output in a timely manner:

sing(
    capture.output(
        rep(NA, 11),
        give_up(what = it, who = Baby),
        give_up(what = it),
        give_up(what = it, who = Baby),
        rep(NA, 11),
        give_up(what = it, who = Baby),
        give_up(what = it),
        give_up(what = it, who = Baby),
        verify(give_up(what = it, who = you), times = 2),
        give_up(what = it)
    )
)

Resulting in:

bringing rythms to life with tap.along()

Using the following note figures, accompany your rythms with lyrics and hear a beeping sound giving you the rythm:

  • w : whole note
  • wd : whole note, dotted
  • h : half note
  • hd : half note, dotted
  • q : quarter note
  • qd : quarter note, dotted
  • e : eight note
  • ed : eight note, dotted
  • t : triplet
  • s : sixteenth note
heyjude <- list()
heyjude$lyrics <- c(rep(NA, 11), "Hey", "Hey","Jude")
heyjude$time.pattn <- "h, q, q, s, s, e, hd, s, s, e, h, s, ed, w"
heyjude$tempo <- 60
heyjude$repet <- 8 # I hesitated between this and "Inf"

do.call(what = tap.along, args = heyjude)
NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  Hey  Hey  Jude 
NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  Hey  Hey  Jude 
NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  Hey  Hey  Jude 
(ad infinitum)

Future

But there's a lot more to do: my idea is to create a reference class for it with a function called give etc, which will end up in a beautiful, object-oriented R poetry! Or something else.

About

helper functions to "sing" songs with R

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages