Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # mp3_stereo.py
- from struct import pack
- from math import sin, pi
- import wave
- import random
- RATE=44100
- ## GENERATE STEREO FILE ##
- wv = wave.open('C://py//audio//test_stereo.mp3', 'w') # .mp3 or .wav
- wv.setparams((2, 2, RATE, 0, 'NONE', 'compressed'))
- maxVol=2**15-1.0 #maximum amplitude
- wvData=""
- for i in range(0, RATE*3):
- wvData+=pack('h', maxVol*sin(i*500.0/RATE)) #500Hz left
- wvData+=pack('h', maxVol*sin(i*200.0/RATE)) #200Hz right
- wv.writeframes(wvData)
- wv.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement