Last active
August 29, 2015 14:14
-
-
Save st98/1e6f14740ce7ba853e95 to your computer and use it in GitHub Desktop.
たのしい winsound モジュール。play('ccggaagrffeeddcr')。
This file contains 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 time | |
import winsound | |
_table = { 'c': 523, 'd': 587, 'e': 659, 'f': 698, 'g': 784, 'a': 880, 'b': 988 } | |
_dur = 60000 // 80 | |
def play(s): | |
s = s.lower() | |
for c in s: | |
if c not in 'cdefgabr': | |
continue | |
if c == 'r': | |
time.sleep(_dur / 1000) | |
else: | |
winsound.Beep(_table[c], _dur) | |
def main(s='ccggaagrffeeddcr', *_): | |
play(s) | |
if __name__ == '__main__': | |
import sys | |
main(*sys.argv[1:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment