Title: | Easily Play Notification Sounds on any Platform |
---|---|
Description: | The main function of this package is beep(), with the purpose to make it easy to play notification sounds on whatever platform you are on. It is intended to be useful, for example, if you are running a long analysis in the background and want to know when it is ready. |
Authors: | Rasmus Bååth [aut, cre], Amanda Dobbyn [ctb] |
Maintainer: | Rasmus Bååth <[email protected]> |
License: | GPL-3 |
Version: | 2.0 |
Built: | 2024-11-03 05:06:21 UTC |
Source: | https://github.com/rasmusab/beepr |
beep
plays a short sound which is useful if you want to get notified,
for example, when a script has finished. As an added bonus there are a number
of different sounds to choose from.
beep(sound = 1, expr = NULL)
beep(sound = 1, expr = NULL)
sound |
character string or number specifying what sound to be played by either specifying one of the built in sounds, specifying the path to a wav file or specifying an url. The default is 1. Possible sounds are:
If |
expr |
An optional expression to be executed before the sound. |
If beep
is not able to play the sound a warning is issued rather than
an error. This is in order to not risk aborting or stopping the process that
you wanted to get notified about.
# Play a "ping" sound beep() ## Not run: # Play a fanfare instead of a "ping". beep("fanfare") # or beep(3) # Play a random sound beep(0) # Update all packages and "ping" when it's ready update.packages(ask=FALSE); beep() ## End(Not run)
# Play a "ping" sound beep() ## Not run: # Play a fanfare instead of a "ping". beep("fanfare") # or beep(3) # Play a random sound beep(0) # Update all packages and "ping" when it's ready update.packages(ask=FALSE); beep() ## End(Not run)
beep_on_error
wraps an expression and plays a short sound only if an
error occurs.
beep_on_error(expr, sound = 1)
beep_on_error(expr, sound = 1)
expr |
An expression to be evaluated for errors. |
sound |
character string or number specifying what sound to be played by either specifying one of the built in sounds, specifying the path to a wav file or specifying an url. The default is 1. Possible sounds are:
If |
If beep
is not able to play the sound a warning is issued rather than
an error. This is in order to not risk aborting or stopping the process that
you wanted to get notified about.
The value of expr
, if no error occurs. If an error occurs then
beep_on_error
will re-throw the error.
## Not run: # Play a "ping" sound if \code{expr} produces an error beep_on_error(log("foo")) # Stay silent if \code{expr} does not produce an error beep_on_error(log(1)) # Play the Wilhelm scream instead of a ping on error. beep_on_error(runif("bar"), "wilhelm") ## End(Not run)
## Not run: # Play a "ping" sound if \code{expr} produces an error beep_on_error(log("foo")) # Stay silent if \code{expr} does not produce an error beep_on_error(log(1)) # Play the Wilhelm scream instead of a ping on error. beep_on_error(runif("bar"), "wilhelm") ## End(Not run)
This package contains one function, beep(), with one purpose: To make it easy to play notification sounds on whatever platform you are on. It is intended to be useful, for example, if you are running a long analysis in the background and want to know when it is ready.
The package contains one main function beep
, check it out to
see what it does. For sound on Windows and MacOS beepr depends on the
audio package. For sound on Linux beepr depends on that either
the paplay utility from the Pulse Audio system, the aplay utility from the
ALSA system, or VLC media player (http://www.videolan.org/vlc/index.html) is
installed and on the PATH. Chances are that you already have one of these.
Rasmus Bååth < [email protected] >
Useful links:
# Play a "ping" sound beep()
# Play a "ping" sound beep()