468,738 Members | 1,752 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,738 developers. It's quick & easy.

Question about 'wave' module

Hello Python World!

I've been playing with the 'wave' and 'audioop' modules in the library,
and I have a question. When I tried to read a "wav" file with samples
in 32-bit float, I got the following error:

Traceback (most recent call last):
File "Play.py", line 111, in ?
playWAV(sys.argv[1])
File "Play.py", line 69, in playWAV
f = wave.open(fname,'rb')
File "D:\Python23\lib\wave.py", line 483, in open
return Wave_read(f)
File "D:\Python23\lib\wave.py", line 162, in __init__
self.initfp(f)
File "D:\Python23\lib\wave.py", line 143, in initfp
self._read_fmt_chunk(chunk)
File "D:\Python23\lib\wave.py", line 264, in _read_fmt_chunk
raise Error, 'unknown format: ' + `wFormatTag`
wave.Error: unknown format: 3

Although the documentation doesn't explicitly say so, it appears
that only 16-bit format is supported. I looked at the source code
('wave.py'), and I think my hunch is correct. On lines 245 (in
method 'readframes') and 412 (in method 'writeframesraw'), a call
is made to the array method 'byteswap' if the machine is "big-
endian", without testing to see if the samples are 16-bit or
32-bit. I don't understand how this could work without knowing
how many bytes to "swap", (ie, 2 or 4).

Has anyone on this list used these modules? Am I missing something?
BTW, I'm on version 2.3.2 for Windows. The 32-bit sound file was
created with a program called "Audacity". I believe the format of
the file is a valid wave file format, I'm able to play it with
Windows Media Player.

Thanks for your help.
--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .
Jul 19 '05 #1
0 1664

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Eric Woudenberg | last post: by
2 posts views Thread by andrea valle | last post: by
6 posts views Thread by Xanax | last post: by
reply views Thread by PickwickBob3 | last post: by
4 posts views Thread by vikram | last post: by
5 posts views Thread by m.topczewski | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.