beepr (former pingr) is on CRAN. It’s easier than ever to make R go beep!

June 30, 2014
By

(This article was first published on Publishable Stuff, and kindly contributed to R-bloggers)

Even though I said it would never happen, my silly package with the sole purpose of playing notification sounds is now on CRAN. Big thanks to the CRAN maintainers for their patience! For instant gratification run the following in R to install beepr and make R produce a notification sound:

install.packages("beepr")
library(beepr)
beep()

This package was previously called pingr and included a ping() function. By request from the CRAN maintainers it has been renamed in order to not be confused with the Unix tool ping. Consequently it is now called beepr and includes a beep() function instead. Other things that have changed since the original announcement is that it is now possible to play a custom wav-file by running beep("path/to/my_sound.wav") and that a facsimile of the Facebook notification sound has been added and which can be played by running beep("facebook") (thanks Romain Francois for the suggestion!).

Bonus Animation of a “Ping”

For fun I made a little animation of the actual “ping” sound that plays when you run beep() using the audio package and the animation package. Sure, the function is now called beep but I still like the original sound :)

Beepr animation

Here is the code:

library(audio)
library(animation)
 # You would have to change this path to point to a valid wav-file 
w <- load.wave("inst/sounds/microwave_ping_mono.wav")
w <- w[1000:7000] # Trim both the start and the end of the ping sound

plot_frame <- function(sample_i) {
  old_par=par(mar=rep(0.1, 4));
  plot(w[seq(1, sample_i)], type="l", xaxt="n", yaxt="n", ylim=c(-0.3, 0.3), col="darkblue")
  text(x=3400, y=0.2, labels="beepr (former pingr)", cex=1.5)
  text(x=3900, y=-0.2, labels="- now on CRAN!", cex=1.5)
  par(old_par)
}

saveGIF(interval = 0.1, ani.width = 200, ani.height = 100, expr = {
  # The animation
  for(sample_i in seq(1, length(w), length.out=40)) {
    plot_frame(sample_i)
  }
  # Just repeating the last image a couple of times...
  for(i in 1:15) {
    plot_frame(length(w))
  }
})

To leave a comment for the author, please follow the link and comment on his blog: Publishable Stuff.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.