aviliami
aviliami

Reputation: 11

Incomplete wav file from load.wave, saved by save.wave

If you record and save a wave file in R using the audio package, there is an error trying to load it again. The object is to store the audio files for later retrieval.

library(audio)
k = 3 # three seconds
x <- rep(NA_real_, 44100*2*k)

# record and save wav file
record(x, 44100, 2) 
wait(k)
play(x)
save.wave(x, "test.wav")

# load file again    
y <- load.wave("test.wav")

After the last command we get:

Error in load.wave("test.wav") : incomplete file

A previous post has suggested an extra data problem, but why wouldn't a file type be internally consistent within a package?

Upvotes: 1

Views: 567

Answers (1)

RolandASc
RolandASc

Reputation: 3923

It looks like the version 0.1-5 on CRAN (https://cran.r-project.org/web/packages/audio/index.html) does not include the last commit / fix done in 2014 (http://www.rforge.net/audio/git.html).

When I clone the git project and re-build the audio package, I can now successfully run the following (which is broken using the CRAN package):

save.wave(audioSample(sin(1:48000/10), 48000), "test.wav")
play(load.wave("test.wav"))

Apart from this, there are two other potentially useful packages sound and tuneR on CRAN. They have been published more recently.

Upvotes: 1

Related Questions