Open In App

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

Last Updated : 26 May, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

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




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


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




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


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




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


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.


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads