Playing a beep Sound in R Language – beep() Function

beep() function in R Language is used to make a beep sound in R language.
In this article, we will be studying more about this function how to implement it, its applications, and some of the different ways to use this function.

Syntax: beep()

Parameters:
1: ping
2: coin
3: fanfare
4: complete
5: treasure
6: ready
7: shotgun
8: mario
9: wilhelm
10: facebook
11: sword

Example 1: Play a beep sound

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to illustrate
# beep sound
  
# Install beepr package
install.packages("beepr"
  
# Load beepr package    
library(beepr)
  
beep()                      

chevron_right


Output:



This will play a ping sound.

Here in the above code, we have installed the beepr packages for beep() functions and then created a beep sound of ping.
If we do not choose any parameter the sound will be 1 which is ping.

Example 2: Play specific Sound

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to illustrate
# beep sound and play a specific sound
  
# Install beepr package
install.packages("beepr"
  
# Load beepr package    
library(beepr)
  
beep(5)                      

chevron_right


Output:

treasure

Here in the above code, we have specified 5 with the beep function so it will play a treasure sound.

Example 3: Play random Sound

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to illustrate
# beep sound and play a specific sound
  
# Install beepr package
install.packages("beepr"
  
# Load beepr package    
library(beepr)
  
beep(0)                      

chevron_right


Output:

Random Sound

Here in the above code, we have specified 0 with the beep function which means the function will play any random sound.

Applications

  • This beep sound can be used at any errors.
  • These sounds can be used on the success of a program.
  • These sounds can be used as a failure of a program.
  • These sounds can be s=used as the completion of any program.



My Personal Notes arrow_drop_up

Recommended Posts:


Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.