Site icon R-bloggers

R is a cool sound editor!

[This article was first published on Statistic on aiR, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Capabilities of R are definitely unless! After my previous posts about some easy image editing in R (they are here, and here), now is the time to explore if R is capable of sound editing!

Just for fun, here I created a function that receives a phone number (or another sequence of numbers), and returns the equivalent melody you can listen if you press that sequence on your house’ phone… =D



It requires the sound library, and here’s the code.



Now you can simply create your phone melody =)

s2 <- PlayTel("556c885a4623#")

You can listen to it with the command:

play(s2)

(NOTE: in Windows 7 I was unable to find a wave player that works on batch mode – i.e. mplay32.exe. So this command doesn’t work on Windows 7. It works on Windows XP)

You can save the output using the command:

saveSample(s2, "tel.wav")

(This command works on Windows 7)

Here is an example of the output:



Have fun!! =)

To leave a comment for the author, please follow the link and comment on their blog: Statistic on aiR.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.