2

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?

Yasen Slavov
  • 787
  • 4
  • 16

1 Answers1

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.

jaket
  • 9,140
  • 2
  • 25
  • 44
  • Can you propose a solution to the problem? Coverting to other formats (such as flac) is possible, but then I would need another library, as tuneR doesnt seem to work with flac. – Yasen Slavov Jun 02 '15 at 06:26
  • 1
    Maybe you could try chopping it into multiple .wav files or maybe use `readMP3`. I can only answer the question you posed without knowing more about your requirements. – jaket Jun 02 '15 at 06:41