def getStream(frec, duration):
NF = int(BITRATE* duration)
RF = NF % BITRATE
WD = ''
for x in range(NF):
WD = WD+chr(int(math.sin(x/(BITRATE/frec)/math.pi))*127+128))
for x in range(RF):
WD = WD+chr(128)
return WD
file = open("sound.wav", "wb")
file.write(getStream(440, 2))
When I open the file it appears in windows player:
Windows Media Player can not play the file. The Player may not support the file type or codec used to compress the file.