piano.py
import time
from pynput.keyboard import Controller
import webbrowser
keyboard = Controller()
with open('辞九门回忆') as f:
music = f.readlines()
num = 0
for m in music:
music[num] = m.strip()
num += 1
'''
1234567
890q w e r
t y u i o p a
'''
num = 0
stop = False
webbrowser.open('https://www.autopiano.cn/post/3110')
time.sleep(15)
K = False
while True:
if not K:
t = 0.6
else:
t = 1.2
if len(music) > num:
if '-' not in music[num]:
stop = False
if not stop:
keyboard.type(music[num])
if music[num] == '/':
if not K:
K = True
else:
K = False
if '-' in music[num]:
stop = True
elif len(music[num]) == 2 and '-' not in music[num]:
t /= 2
elif len(music[num]) == 3 and '-' not in music[num]:
t /= 4
else:
break

本文介绍了如何使用Python进行自动化钢琴演奏,通过解析简谱并应用算法实现音乐的自动化播放。
最低0.47元/天 解锁文章
1619

被折叠的 条评论
为什么被折叠?



