471,323 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,323 software developers and data experts.

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 ?
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__
File "D:\Python23\lib\wave.py", line 143, in initfp
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 1774

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 rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.