"Permission denied" when playing a WAV file

I am trying to play a wav file in R using the tuneR package. I do not know the background of the function, but it seems that it is trying to save the wav file to a temporary file that it does not have access to. I do the following:

> # install package if you don't have it > install.packages("tuneR") > library(tuneR) > # load some WAV file > mySound = readWave("Beethoven.wav"); > # plot it to see if things are working: > plot(mySound) > # play the sound > play(mySound) sh: /var/folders/qv/sw8_92hn4qg0rb5w40gz9mf40000gn/T//RtmpKU9kVN/tuneRtemp.wav: Permission denied 

Thus, he does not have access to this folder. How can I change this folder or give R access to this folder?

I am working on MacOSX 10.7.5, with RStudio version 0.98.501.

+7
r macos
source share
2 answers

When using OSX, a simple solution is to use the built-in command line audio player in / usr / bin. (see: http://hints.macworld.com/article.php?story=20081002080543392 )

Therefore use:

 setWavPlayer('/usr/bin/afplay') 
+9
source share

I made an R package that allows you to make your own music a while ago. I had this problem trying to get tuneR to work with a Mac. As you can see here: https://github.com/Dasonk/musicmakeR/blob/master/R/playsong.R my solution (which is probably not the best) was to do this

 if(Sys.info()["sysname"] == "Darwin"){ filename <- tempfile("tuneRtemp", fileext = ".wav") #on.exit(unlink(filename)) writeWave(song, filename) system(paste("open -a iTunes", filename)) return(invisible()) } 

where song is the wave data. So my solution was to write it to a file, which, as you know, you have access to, and then directly call the music player using the system.

+1
source share

All Articles