Advertisement
bitpwner

Morse the New Year

Jan 2nd, 2015
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. import wave
  2. n=wave.open("n.wav","w")           # Open a wav file for writing
  3. n.setparams((2,2,4e4,0,"NONE","")) # Sets the minimal params for the wav file
  4. k=68182                            # This number is such that the track is ~30 secs
  5. w=n.writeframes
  6. h=23450475295733                   # Contains base-4 morse code: '.'=1, '-'=3, ' '=0
  7. while h:
  8.     for i in range(h%2*k):w(h%4*chr(i%99)) # Writes saw-tooth signal using i%99
  9.     w((2-h%2)*k*" ")                       # Writes the pauses
  10.     h/=4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement