Invalid 'n' argument error in readBin() wh

2019-07-21 07:24发布

问题:

I'm trying to load a sample from a 4GB+ mono WAV file (total file duration 24h, I'm loading a 15min slice).

library(tuneR)

so <-
  readWave(
    "file.wav", from = 1, to = 15, units = "minutes"
  )

This is the traceback Error in readBin(con, int, n = N, size = bytes, signed = (bytes != 1), : invalid 'n' argument 2 readBin(con, int, n = N, size = bytes, signed = (bytes != 1), endian = "little") 1 readWave(filePath, from = 1, to = 15, units = "minutes")

This happens for every 'from' and 'to' params (5,10,15,etc).

What I initially though is that I'm overflowing the data type of n, which I assume is long, but it doesn't really make sense because the error appears even when I try to load a 1min sample.

Any ideas about what may be causing this?

Note: The original file was mp3 stereo. It was split into 2 channels with WavePad and one of the channels was saves as a WAV. Maybe the conversion is the problem?

回答1:

Wave files are limited to 4GB of audio data because all of the size fields in a wave header are 32-bits. See http://en.wikipedia.org/wiki/WAV#Limitations

It's possible that WavePad uses the W64 format mentioned in the Wikipedia article but that readWave does not.