Issue1512791
Created on 2006-06-26 15:16 by gpk, last changed 2009-07-29 00:27 by Red HamsterX.
| File name |
Uploaded |
Description |
Edit |
Remove |
|
1512791[2.7].diff
|
Red HamsterX,
2009-07-29 00:23
|
Patch containing unit test and solution for Python 2.7 |
|
|
|
1512791[3.2].diff
|
Red HamsterX,
2009-07-29 00:27
|
Patch containing unit test and solution for Python 3.2 |
|
|
|
msg60930 - (view) |
Author: Greg Kochanski (gpk) |
Date: 2006-06-26 15:16 |
|
In wave.py, a floating point frame rate is truncated
(rather than rounded) in function _write_header().
Fractional frame rates are perfectly reasonable,
even if not normally seen in audio practice,
and the software ought to represent them as accurately
as possible.
Moreover, it's sometimes reasonable to store the
inverse of the frame rate, which is the time
interval between frames. That's important
when you're doing signal processing, and some
data formats store 1.0/framerate rather than
framerate.
Anyhow, if you give setframerate() a float,
it truncates rather than rounding, so
dt = 1.0/44100
setframerate(1.0/dt) can end up setting
the frame rate to 44099 Hz in the resulting
data file.
The fix is to change the last line of setframerate() to
self._framerate = int(round(framerate))
.
That also has the beneficial side-effect of giving
an earlier error report in case someone gives
the wrong type of object to setframerate()
(such as None, or "44100", or some class).
|
|
msg91026 - (view) |
Author: Neil Tallim (Red HamsterX) |
Date: 2009-07-29 00:23 |
|
Attached a patch with a unit test and solution for this problem.
Patch built against Python 2.7, r74246.
Note: It may make more sense to just have wave.setframerate() assert
that it is being fed an integer, and that's a simple fix that won't
require a test. However, that's not what was approved for testing, so
that's not what I wrote.
|
|
msg91027 - (view) |
Author: Neil Tallim (Red HamsterX) |
Date: 2009-07-29 00:27 |
|
Attached a patch with a unit test and solution for this problem.
Patch built against Python 3.2, r74246.
Note: with Python 3.2, an error was thrown if the input value wasn't an
integer because a deprecated struct-related cast was removed. It's
debatable whether we want to actually apply this patch, since the error
couldn't manifest in this version of Python. However, if we patch 2.7,
we might as well patch this to maintain consistency. (Patching 3.2 will
not break anything or make previously broken logic work differently, so
it is safe)
|
|
| Date |
User |
Action |
Args |
| 2009-07-29 00:27:01 | Red HamsterX | set | files:
+ 1512791[3.2].diff
messages:
+ msg91027 |
| 2009-07-29 00:23:58 | Red HamsterX | set | files:
+ 1512791[2.7].diff
nosy:
+ Red HamsterX versions:
+ Python 3.2 messages:
+ msg91026
keywords:
+ patch type: feature request -> behavior |
| 2009-03-30 05:56:47 | ajaksu2 | set | priority: normal -> low stage: test needed type: feature request versions:
+ Python 2.7 |
| 2006-06-26 15:16:36 | gpk | create | |
|