Create 32bit float wav file in python?

前端 未结 3 1735
感动是毒
感动是毒 2021-01-21 06:15

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

3条回答
  •  鱼传尺愫
    2021-01-21 07:11

    I tried testing P Moran's code and absolutely does not work, like 'len(int(3))?'. Sorry man, I don't think it was tested. But fear not, modern python has ways!

    import numpy as np
    songtime=np.arange(0,100,60/44100.,dtype=float)
    coswav=np.cos(songtime)
    sinewav=np.sin(songtime)
    np.column_stack((coswav,sinwav))
    songwav=np.column_stack((coswav,sinwav)).astype('float32')
    
    import scipy.io.wavfile as scipy_io_wavfile
    scipy_io_wavfile.write("5secof60Hz.wav",44100,songwav)
    

    https://docs.python.org/3.7/library/wave.html https://docs.scipy.org/doc/scipy/reference/generated/scipy.io.wavfile.write.html

提交回复
热议问题