Skip to content

Instantly share code, notes, and snippets.

@pedrospdc
Last active April 3, 2023 14:09
Show Gist options
  • Save pedrospdc/5936122 to your computer and use it in GitHub Desktop.
Save pedrospdc/5936122 to your computer and use it in GitHub Desktop.
Python Song of Time
import platform
try:
import winsound
beep = winsound.Beep
except ImportError:
def beep(f, d):
s = 8000
hp = int(s/f/2)
b = chr(255)*hp+chr(0)*hp
b *= int(d*f)
a = open('/dev/audio', 'wb')
a.write(b)
a.close()
c = [
(880, 700),
(587, 1000),
(698, 500),
(880, 500),
(587, 1000),
(698, 500),
(880, 250),
(1046, 250),
(988, 500),
(784, 500),
(699, 230),
(784, 250),
(880, 500),
(587, 500),
(523, 250),
(659, 250),
(587, 750)
]
s = c + c
for f, d in s:
beep(f, d)
Copy link

ghost commented Apr 3, 2023

Nice bro✌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment