0

I am a beginner in RStudio, and I am planning to use it to analyze audio. I have downloaded wavelets and tuneR packages and have created sine waves and analyzed them. However, I can't seem to get RStudio to read wave files stored on my computer. I have tried readWave, but am continually getting an error:

file does not exist

How do I get this wave file into RStudio to be analyzed?

Thank you so much for any help you can offer!

user2554330
  • 37,248
  • 4
  • 43
  • 90
user18556
  • 1
  • 1
  • 2
    please provide your code, otherwise it is just guessing for us, what is wrong – Linus Mar 10 '18 at 05:04
  • > library(tuneR) > readWave(kupdB.wav, from=1, to=Inf, units=c("samples"), header=FALSE, toWaveMC=NULL) Error in readWave(kupdB.wav, from = 1, to = Inf, units = c("samples"), : object 'kupdB.wav' not found > 1kup<-("kupdB.wav") Error: unexpected symbol in "1kup" > kup<-("kupdB.wav") > readWave(kup, from=1, to=Inf, units=c("samples"), header=FALSE, toWaveMC=NULL) Error in readWave(kup, from = 1, to = Inf, units = c("samples"), header = FALSE, : File 'kupdB.wav' does not exist. – user18556 Mar 10 '18 at 23:29
  • It looks like your working directory is set different in Rstudio than in plain R. The filepath is wrong. You can try to use the full path to the file. – Linus Mar 11 '18 at 14:41
  • Thank you! I'm using a file on the Desktop. I tried entering the file path but am getting errors. I tried changing multiple small things and am learning as I go along, but I still must be doing something wrong. Does it have to do with changing the working directory? I'm very new to all of this! – user18556 Mar 12 '18 at 03:25
  • Here's an example of the code I ran with the file path: > readWave(Users//sephr\\Desktop\\R Files\\kupdB.wav, from=1, to=Inf, units=c("samples"), header=FALSE, toWaveMC=NULL) Error: unexpected '/' in "readWave(Users//" – user18556 Mar 12 '18 at 03:28
  • One more example, in case it helps: > readWave(C:\\Users/sephr\\Desktop\\R Files\\kupdB.wav, from=1, to=Inf, units=c("samples"), header=FALSE, toWaveMC=NULL) Error: unexpected input in "readWave(C:\" > readWave(C:\\Users//sephr\\Desktop\\R Files\\kupdB.wav, from=1, to=Inf, units=c("samples"), header=FALSE, toWaveMC=NULL) Error: unexpected input in "readWave(C:\" > readWave( "C:\\Users/sephr\\Desktop\\R Files\\kupdB.wav", from=1, to=Inf, units=c("samples"), header=FALSE, toWaveMC=NULL) Error in readWave("C:\\Users/sephr\\Desktop\\R Files\\kupdB.wav", from = 1, : No data chunk found – user18556 Mar 12 '18 at 03:29
  • Did you created a projekt in Rstudio? If not. create a folder on your Desktop. use create projekt -> existing directory. copy your script and your wav file into the folder. Your working directory should be find then. – Linus Mar 12 '18 at 05:30
  • Thank you so much, Linus! This helped! I am able to get my file into my session now. Unfortunately, it is now being recognized as a function rather than a Wave class. Any tips on this? > kupdB.wav<-readWave > ?tuneR > play(kupdB.wav) Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘play’ for signature ‘"function"’ > Wobjm11s<-extractWave(kupdB.wav) Error in extractWave(kupdB.wav) : 'object' needs to be of class 'Wave' or 'WaveMC' > ?Wave > class(kupdB.wav) [1] "function" – user18556 Mar 17 '18 at 02:07
  • kupdB.wav<-readWave('you_file') i do not know the function but you normally need to provide file name to the function. – Linus Mar 17 '18 at 06:07

0 Answers0