You are on page 1of 1

import wave, struct, math, random

sampleRate = 44100.0 # hertz


duration = 1.0 # seconds
frequency = 440.0 # hertz
obj = wave.open('sound.wav','w')
obj.setnchannels(1) # mono
obj.setsampwidth(2)
obj.setframerate(sampleRate)
for i in range(99000):
v = math.sin(i * 800 * 2 * math.pi / sampleRate);
v += math.sin(i * 1760 * 2 * math.pi / sampleRate) * 0.45;
v += math.sin(i * 2500 * 2 * math.pi / sampleRate) * 0.05;

data = struct.pack('<h', int(v*1000))


obj.writeframesraw( data )
obj.close()

You might also like