This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author drj
Recipients drj, gpolo
Date 2009-02-10.13:09:28
SpamBayes Score 4.3431925e-13
Marked as misclassified No
Message-id <B1ACAE52-4EB0-4119-9CDF-FE1A1FEEE924@pobox.com>
In-reply-to <1234268923.19.0.122980458213.issue5202@psf.upfronthosting.co.za>
Content
On 10 Feb 2009, at 12:28, Guilherme Polo wrote:

>
> Guilherme Polo <ggpolo@gmail.com> added the comment:
>
> I'm really unsure about the proposed patch.

Perhaps my example was too trivial.  The point is that if you call  
setnframes then you can get wave.py to avoid patching the header; so  
it does not need to seek on the output file.  However, that _still_  
doesn't let you pipe the output, because of the "tell" problem.   
That's what the patch is for.

Here is a (slightly) less trivial example:

#!/usr/bin/env python
import sys
import wave
w = wave.open(sys.stdout, 'w')
w.setnchannels(1)
w.setsampwidth(1)
w.setframerate(2000)
w.setnframes(100)
for _ in range(50): w.writeframesraw('\x00\xff')
w.close()

(The wave file that it outputs is 100ms of 1000 Hz sine wave by the way)

Note the call to setnframes _before_ the data is written.  That's  
what means the header does not need to be patched.  With my patch  
applied the output of this program can be fed to a pipe.

If you remove the call to setnframes then the header will need to be  
patched, and this still (correctly, usefully) raises an error with my  
patch applied.
History
Date User Action Args
2009-02-10 13:09:30drjsetrecipients: + drj, gpolo
2009-02-10 13:09:29drjlinkissue5202 messages
2009-02-10 13:09:28drjcreate