classification
Title: wave sunau aifc 16bit errors
Type: behavior Stage: test needed
Components: Library (Lib), Windows Versions: Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: wave module sets data subchunk size incorrectly when writing wav file
View: 8311
Assigned To: Nosy List: christian.heimes, jeroen, serhiy.storchaka
Priority: normal Keywords:

Created on 2007-11-11 20:15 by jeroen, last changed 2015-02-10 11:48 by serhiy.storchaka. This issue is now closed.

Messages (8)
msg57377 - (view) Author: jeroen (jeroen) Date: 2007-11-11 20:15
When you write sound files wav sunau of aifc and you are using 16 bits
samples. The number of frames in the files is incorrect. close function
which updates the headers makes a mistake I assume. For the sunau type I
had to double the number of frames in the close function to make it correct.

If you do not correctg number of frames a 10 second file will play 5 seconds
msg57404 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-11-12 17:24
What software do you use to play the sample?  Is it perhaps ignoring the
nchannels value from the header?
msg57418 - (view) Author: jeroen (jeroen) Date: 2007-11-12 18:35
I played using winsound.PlaySound function for the wav. I used VLC and windows media player for wav,au and aiff after that

All had the same problem. It was solved for sunau by doubling the nframes number written by the close function in the sunau module. I assume something similar should be done for the wav and aiff modules.

This is what I changed in sunau I am not sure if adding *self._sampwidth breaks something else. It works for me now when I create 16bit stereo files.

def _patchheader(self):
        self._file.seek(8)
        # jjk added * sampwidth otherwise for 16 bit you get wrong nframes
        _write_u32(self._file, self._datawritten*self._sampwidth)
        self._datalength = self._datawritten
        self._file.seek(0, 2)

Hope this helps.
greetings
msg57575 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-11-15 23:26
Crys, since you apparently have working sound on Windows, could you have
a look at this?  There's also an (unrelated) issue with sunau.py on
Py3k, it doesn't work (but the unittests aren't strong enough to
discover that :-).
msg116785 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-09-18 14:34
Is this still valid?
msg116792 - (view) Author: jeroen (jeroen) Date: 2010-09-18 15:11
as far as I know. But i have not use or tested it since a long time

On Sat, Sep 18, 2010 at 4:34 PM, Mark Lawrence <report@bugs.python.org>wrote:

>
> Mark Lawrence <breamoreboy@yahoo.co.uk> added the comment:
>
> Is this still valid?
>
> ----------
> nosy: +BreamoreBoy -gvanrossum
> versions: +Python 2.7, Python 3.1, Python 3.2 -Python 2.6, Python 3.0
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue1423>
> _______________________________________
>
msg191789 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2013-06-24 17:12
Is somebody interested in this bug?
msg235682 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-02-10 11:48
This is a duplicate of issue8311. Was fixed in 3.4. In 2.7 you should first convert your data to str, bytearray, array('B') or buffer.
History
Date User Action Args
2015-02-10 11:48:21serhiy.storchakasetstatus: languishing -> closed

superseder: wave module sets data subchunk size incorrectly when writing wav file
versions: - Python 3.3, Python 3.4
nosy: + serhiy.storchaka

messages: + msg235682
resolution: duplicate
2014-02-03 19:53:42BreamoreBoysetnosy: - BreamoreBoy
2013-06-24 17:12:27christian.heimessetstatus: open -> languishing
assignee: christian.heimes ->
messages: + msg191789

versions: + Python 3.3, Python 3.4, - Python 3.1, Python 3.2
2013-02-06 19:15:19serhiy.storchakasetfiles: - unnamed
2010-09-18 15:11:24jeroensetfiles: + unnamed

messages: + msg116792
2010-09-18 14:34:02BreamoreBoysetnosy: + BreamoreBoy, - gvanrossum
messages: + msg116785
versions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.6, Python 3.0
2009-04-07 04:05:11ajaksu2setstage: test needed
type: behavior
components: + Windows
versions: + Python 2.6, Python 3.0, - Python 2.5
2007-11-15 23:26:55gvanrossumsetpriority: normal
assignee: christian.heimes
messages: + msg57575
nosy: + christian.heimes
2007-11-12 18:35:27jeroensetmessages: + msg57418
2007-11-12 17:24:23gvanrossumsetnosy: + gvanrossum
messages: + msg57404
2007-11-11 20:15:28jeroencreate