%pylab import wave, struct maxshort=32767 f0=44000 # sampling rate wsecs=2 # length of sample in seconds t=r_[0:wsecs:1/f0] y1=sin(t*2*pi*440) # define left waveform in the [-1;1] range y2=sin(t*2*pi*445) # define right waveform in the [-1;1] range wf=wave.open("d:/tmp/sine1.wav",mode="wb") wf.setframerate(f0) wf.setsampwidth(2) wf.setnchannels(2) wf.writeframes(struct.pack("<%sh" % (2*len(t)),*[short(round(maxshort*y)) for yp in zip(y1,y2) for y in yp])) wf.close()