Message81547
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. |
|
Date |
User |
Action |
Args |
2009-02-10 13:09:30 | drj | set | recipients:
+ drj, gpolo |
2009-02-10 13:09:29 | drj | link | issue5202 messages |
2009-02-10 13:09:28 | drj | create | |
|