Hello vahid.borji,

Re:

> How can we call a music file from our laptop (for example from desktop) and
> play it in R? Could you please give me an explicit example by writing
> commands in R. Is it necessary for our music file to be in a specific
> format? If yes, which format it has to be?

Wave files, and probably a few other formata, can be loaded, saved and 
manupulated with (a.o.)  these packages:

library(signal)  
library(seewave)
library(tuneR)


In addition, to play a wave file, a small Unix file is necessary, called "play".
It must be attached by the following line:

        
setWavPlayer("/Library/Frameworks/R.framework/Versions/3.6/Resources/bin/play") 
  # path depends on your R version etc.


Then, a simple script like the following will do:


        inname = file.choose()
        ywave=readWave(inname)
        ster=ywave@stereo
        srate=yw...@samp.rate
        play(ywave)


Hoping this helps, I remain
With best regards,


Franklin Bretschneider
Dept of Biology
Utrecht University
f.bretschnei...@uu.nl

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to