Last active
April 3, 2023 14:09
-
-
Save pedrospdc/5936122 to your computer and use it in GitHub Desktop.
Python Song of Time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice bro✌