I want to create 32bit float WAV files in Python (2.x). While "standard" WAV files usually use int, many professional audio applications process (and save) audio data as float. The standard wave module is not capable to do this: http://bugs.python.org/issue16525 Has anyone achieved this without using patched modules ? tnx for any help.
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- Can we recover audio from MFCC coefficients?
- How to get the background from multiple images by
- Evil ctypes hack in python
Here's my contribution... includes arbitrary word size and arbitrary number of channels. I've taken the liberty of changing float32_wav_file to include a file save for testing. Note that the multichannel data portion of the file structure interleaved. That loop could be be greatly pythonized I'm sure.
This sounded like fun (see my handle), so I hammered out something. Maybe you can use it. If your Python script generates a monophonic waveform of numerical values that fall between [-1.0 .. 1.0], send that waveform in through
sample_array
and also specifysample_rate
(e.g., 44100 or 48000). This will return to you an array that you can write to disk as a .wav file.I tested the resulting .wav output in Windows Media Player, Apple QuickTime Player, and VLC (all on Windows 7). They all played it.