Browse Source

Audio

pull/10/head
Jure Šorn 5 years ago
parent
commit
27ea919985
1 changed files with 7 additions and 7 deletions
  1. 14
      README.md

14
README.md

@ -1533,13 +1533,13 @@ Audio
#### Saves a list of floats with values between 0 and 1 to a WAV file:
```python
import wave, struct
frames = [struct.pack('h', int((a-0.5)*60000)) for a in <list>]
wf = wave.open(<filename>, 'wb')
wf.setnchannels(1)
wf.setsampwidth(4)
wf.setframerate(44100)
wf.writeframes(b''.join(frames))
wf.close()
samples = [struct.pack('h', int((a-0.5)*60000)) for a in <list>]
wav = wave.open(<filename>, 'wb')
wav.setnchannels(1)
wav.setsampwidth(4)
wav.setframerate(44100)
wav.writeframes(b''.join(samples))
wav.close()
```

Loading…
Cancel
Save