wavread problem with Octave 3.2.3

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

wavread problem with Octave 3.2.3

tdtodd
Hi,

I'm having a problem reading a wav file and getting "error: memory exhausted or requested size too large for range of Octave's index type -- trying to return to prompt".

The wav file is about 1.6MB (32-bit samples) and far below the octave/machine size/memory limitations. I've noticed that if I give wavread a second (size) argument which is larger than the number of samples in the file, it reads the entire file in without any problem. I guess wavread is having a problem reading the size of the file?

Any pointers or help on this would be much appreciated.

Thanks,
Terry
Reply | Threaded
Open this post in threaded view
|

Re: wavread problem with Octave 3.2.3

Jordi Gutiérrez Hermoso
On 2 August 2010 09:46, tdtodd <[hidden email]> wrote:
> I'm having a problem reading a wav file and getting "error: memory exhausted
> or requested size too large for range of Octave's index type -- trying to
> return to prompt".

Could you please post the wav somewhere so that we may attempt to
reproduce and diagnose the problem? You won't be able to send it to
the mailing list due to size, but there are plenty of filesharing
sites online you could use instead.
_______________________________________________
Help-octave mailing list
[hidden email]
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: wavread problem with Octave 3.2.3

tdtodd
Hi Jordi,

Thanks ... I've posted the file in my public Dropbox at

http://dl.dropbox.com/u/2367921/speech.wav

Thanks,
Terry
Reply | Threaded
Open this post in threaded view
|

Re: wavread problem with Octave 3.2.3

Jordi Gutiérrez Hermoso
On 2 August 2010 09:46, tdtodd <[hidden email]> wrote:
> I'm having a problem reading a wav file and getting "error: memory exhausted
> or requested size too large for range of Octave's index type -- trying to
> return to prompt".


On 7 August 2010 10:41, tdtodd <[hidden email]> wrote:
> Thanks ... I've posted the file in my public Dropbox at
>
> http://dl.dropbox.com/u/2367921/speech.wav

I made a few weak attempts to diagnose this. Unfortunately, I don't
really understand how a RIFF and Microsoft PCM works, but a bit of
printf debugging quickly pointed out that the problem is that for
whatever reason, data_size in line 100 of wavread.m is a ridiculously
large number. The function that produces it is find_chunk in the same
file. Octave later tries to allocate a vector of this order of
magnitude, which is where you see the failure.

Interestingly enough, I was unable to reproduce the exact same problem
on the development sources. I think that bug #30309 that Rik patched
with changeset 10738:a4b8364e04c7 may have also squashed or alleviated
the one you're seeing. I still see Octave consuming a ridiculous
amount of memory even with this patch.

Can you try patching your version? There are several cosmetic changes
in that changeset. The only hunk of that patch that seems relevant is

@@ -230,6 +231,8 @@
     fseek (fid, chunk_size, "cof");
     id = char (fread (fid, 4))';
     chunk_size = fread (fid, 1, "uint32", 0, "ieee-le");
+    ## Chunk sizes must be word-aligned (2 byte)
+    chunk_size += rem (chunk_size, 2);
     offset = offset + 8 + chunk_size;
   endwhile
   if (! strcmp (id, chunk_id))
_______________________________________________
Help-octave mailing list
[hidden email]
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: wavread problem with Octave 3.2.3

tdtodd
I still get the same error after making this patch. However, I tried it using version 3.2.3.
Reply | Threaded
Open this post in threaded view
|

Re: wavread problem with Octave 3.2.3

tdtodd
I've discovered that the problem here isn't with wavread at all. The problem is with the gnome-sound-recorder (v. 2.30.0 installed with Ubuntu 10.04) that I used to create the wav file.

Poking into my wav file I found that the chunk size was set to 2.1474e+09, which is off by orders of magnitude. I wondered if gnome-sound-recorder had screwed up the endian, but this is not the problem either, so I have no idea where this number came from.

So sorry,

Terry
Reply | Threaded
Open this post in threaded view
|

Re: wavread problem with Octave 3.2.3

Jordi Gutiérrez Hermoso
On 12 August 2010 07:21, tdtodd <[hidden email]> wrote:
>
> I've discovered that the problem here isn't with wavread at all. The problem
> is with the gnome-sound-recorder (v. 2.30.0 installed with Ubuntu 10.04)
> that I used to create the wav file.
>
> Poking into my wav file I found that the chunk size was set to 2.1474e+09,
> which is off by orders of magnitude.

Well, it's good you found the bug, but perhaps wavread should ignore
that value and just look at the filesize instead? I don't know if this
is a good approach because I'm not familiar with the file format.
_______________________________________________
Help-octave mailing list
[hidden email]
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: wavread problem with Octave 3.2.3

tdtodd
Hi Jordi,

Yes, I think you are right. I had a quick look at the wav file format
and it seems pretty straightforward.

Various audio players have no problem playing my broken wav file just
fine. So they seem to ignore the ChunkSize field completely, and just
fetch data from the file until it reaches the end of the data
subchunk, which has its own size field. It seems that wavread only
uses the ChunkSize to limit the search when looking for new chunks.

Wavread could easily do a sanity check on this and output a
warning. However, maybe this issue isn't a common enough occurrence
that it is worth the effort?

Bye,
Terry
Reply | Threaded
Open this post in threaded view
|

Re: wavread problem with Octave 3.2.3

gurucharapathy
Hi,
Just FYI.
I had the same problem. As posted earlier, the issue is with Gnome sound recorder. The wavread works fine with Audacity.
Reply | Threaded
Open this post in threaded view
|

Re: wavread problem with Octave 3.2.3

Doug Stewart-4
In reply to this post by Jordi Gutiérrez Hermoso


2010/8/12 Jordi Gutiérrez Hermoso <[hidden email]>
On 12 August 2010 07:21, tdtodd <[hidden email]> wrote:
>
> I've discovered that the problem here isn't with wavread at all. The problem
> is with the gnome-sound-recorder (v. 2.30.0 installed with Ubuntu 10.04)
> that I used to create the wav file.
>
> Poking into my wav file I found that the chunk size was set to 2.1474e+09,
> which is off by orders of magnitude.

Well, it's good you found the bug, but perhaps wavread should ignore
that value and just look at the filesize instead? I don't know if this
is a good approach because I'm not familiar with the file format.


You must be careful with file size. The riff format allows for many different chunks in one file. You would have to read and process all the info of each chunk and then compare with the actual file size, to see if the total adds up.  But wee could do a simple check and see if the the chunk size is much bigger that the actual file size, and then give a warning message. At the present time I think we assume that the wav file is valid.

Should we check for errors in the formatting of the wav file?

Just my 2C worth

Doug


_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave