[R] Playing a music file in R
bret@chr @end|ng |rom x@4@||@n|
Tue Jul 21 23:39:40 CEST 2020
> 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:
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()
ster=ywave using stereo
srate=ywave using samp.rate
Hoping this helps, I remain
With best regards,
Dept of Biology
f.bretschneider using uu.nl
More information about the R-help