David Jones <d...@pobox.com> added the comment:

On 10 Feb 2009, at 12:28, Guilherme Polo wrote:

>
> Guilherme Polo <ggp...@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.

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue5202>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to