Skip to content

Instantly share code, notes, and snippets.

@st98
Last active August 29, 2015 14:14
Show Gist options
  • Save st98/1e6f14740ce7ba853e95 to your computer and use it in GitHub Desktop.
Save st98/1e6f14740ce7ba853e95 to your computer and use it in GitHub Desktop.
たのしい winsound モジュール。play('ccggaagrffeeddcr')。
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