[SciPy-Dev] Suggested Change to io.wavfile
Brian Hone
brianhone@gmail....
Mon Aug 13 07:25:05 CDT 2012
I'm in the process of spinning up a technical team that is using scipy
for audio signal processing, so I expect that we'll be finding lots of
issues with wavfile. I'll take a look at the bug list and see if we
knock off a few of them as we go.
Happy to do the test and pull request. Stupid question though - I
haven't yet made the jump from good old svn to git. Can anyone give me
the right sequence of commands so I don't mess it up?
Brian
On 8/11/2012 1:00 PM, scipy-dev-request@scipy.org wrote:
>
> Thanks for posting. I see we don't have a nominated maintainer for
> io.wavfile - Ralf - is that right?
>
> https://github.com/scipy/scipy/blob/master/doc/MAINTAINERS.rst.txt
>
> Does anyone who uses wav files feel able to comment here?
>
> Brian - please consider a test and a pull request? Please do email
> again if that's hard to do. Do you think we should omit a warning or
> make this fix optional, perhaps with the fix set as the default
> behavior?
>
> Thanks again,
>
> Matthew
>
>
> ------------------------------
>
> Message: 2
> Date: Fri, 10 Aug 2012 22:02:07 +0200
> From: Ralf Gommers<ralf.gommers@gmail.com>
> Subject: Re: [SciPy-Dev] Suggested Change to io.wavfile
> To: SciPy Developers List<scipy-dev@scipy.org>
> Message-ID:
> <CABL7CQimy=nGtzPmYR46a-n1yrwQf0gaNzD+BzByvfv=UMzaKw@mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> On Fri, Aug 10, 2012 at 9:51 PM, Matthew Brett<matthew.brett@gmail.com>wrote:
>
>> Hi,
>>
>> On Thu, Aug 9, 2012 at 8:08 AM, Brian Hone<brianhone@gmail.com> wrote:
>>> Hi folks,
>>>
>>> I'm running into a wavfile read error which appears to be caused by
>>> slight problems in wavfile meta-data. (Specifically, the meta-data
>>> mis-reports the number of frames). Unfortunately, 2/3 of the wav files
>>> I've randomly sampled have this problem, and most audio packages just
>>> deal with it.
>>>
>>> I notice from a search that a lot of people have this problem with
>>> io.wavfile.read:
>>>
>>> /usr/lib/python2.7/site-packages/scipy/io/wavfile.pyc in read(file)
>>> 125 else:
>>> 126 fmt = '<i'
>>> --> 127 size = struct.unpack(fmt, data)[0]
>>> 128 fid.seek(size, 1)
>>> 129 fid.close()
>>>
>>>
>>> Here's a fix - just calculate the actual file length and use the minimum
>>> or the file length and the meta-data reported length.
>>>
>>> 113,121c113
>>> <
>>> < ## Calculate the actual file length in case meta-data is incorrect
>>> < current_pos = fid.tell()
>>> < fid.seek(0,2)
>>> < actual_file_length = fid.tell()
>>> < fid.seek( current_pos )
>>> < total_length = min( fsize, actual_file_length )
>>> <
>>> < while (fid.tell()< total_length):
>>> ---
>>> > while (fid.tell()< fsize):
>> Thanks for posting. I see we don't have a nominated maintainer for
>> io.wavfile - Ralf - is that right?
>>
> Yes, unfortunately. I count 7 open tickets for wavfile, some of which are
> quite old. Wavfile is<200 lines of Python code, so fixing most of these
> probably won't be very difficult. If there's someone who is interested in
> this code and would be willing to put in some time, that would be great.
>
> Ralf
>
>
>> https://github.com/scipy/scipy/blob/master/doc/MAINTAINERS.rst.txt
>>
>> Does anyone who uses wav files feel able to comment here?
>>
>> Brian - please consider a test and a pull request? Please do email
>> again if that's hard to do. Do you think we should omit a warning or
>> make this fix optional, perhaps with the fix set as the default
>> behavior?
>>
>> Thanks again,
>>
>> Matthew
>> _______________________________________________
>> SciPy-Dev mailing list
>> SciPy-Dev@scipy.org
>> http://mail.scipy.org/mailman/listinfo/scipy-dev
>>
More information about the SciPy-Dev
mailing list