python-soundfile
python-soundfile copied to clipboard
Very simple question
Thank you for the wonderful software!
It used to work fine, until I attempted using a very basic code, and for whatever reason it does not work. Why?
import soundfile as sf
sample_rate = 48000
wavdata = []
for i in range(10):
wavdata.append(0)
for x in range(40):
wavdata.append(1)
for y in range(10):
wavdata.append(0)
sf.write('blip.wav', wavdata, sample_rate)
Thank you so much!!
what's the error message?
Thank you for the reply! When viewed in Audacity, the wav is simply all zeros.

@zeke800 You might want to explicitly specify the data format subtype i.e., in your case maybe 'FLOAT'?
EDIT: From how I quickly grasp the implementation, *.wav files would use 'PCM_16' by default, which would require values to be scaled to 16bit integer for full-scale (to show up as 1 in the floating point representation in Audacity).
Try writing float data