Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # tests by Scar32
- import wave, struct, math, random
- from PIL import Image
- def addsample(S):
- data = struct.pack('<h', S)
- obj.writeframesraw(data)
- sampleRate = 8008135 # hertz
- duration = 1.0 # seconds, this does nothing
- frequency = 500 # hertz, this will change the frequency
- wavehight = 65534
- obj = wave.open(f'wave.wav', 'w')
- obj.setnchannels(1) # mono
- obj.setsampwidth(2)
- obj.setframerate(sampleRate)
- loop = 65534 # how many samples do you want?
- for i in range(loop):
- if i % 10 ** 6 == 0:
- print(f"%{i * 100 / loop}")
- addsample(i % wavehight - 32767)
Advertisement
Add Comment
Please, Sign In to add comment