Question about 'wave' module

D

david.kettle

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,240
Messages
2,571,211
Members
47,848
Latest member
Alfonso227

Latest Threads

Top