You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey
I had some problems running the script from outside the console and I found this way to solve it, I leave it here in case you want to add it to the code, I think I can't send pull requests
add:
def control(midi, pitch_modulation=10):
print("Playing")
curr_pitch = 'f2'
pyautogui.press(curr_pitch)
pyautogui.PAUSE = 0
for msg in midi.play():
if msg.type == 'note_on' and msg.velocity != 0:
pitch, key = map_piano_note_to_key(msg.note + pitch_modulation)
if curr_pitch != pitch:
pyautogui.press(pitch)
curr_pitch = pitch
if key:
pyautogui.press(key)
if keyboard.is_pressed("F6"):
print("Stop")
break
and in the main:
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python macro.py 'path'")
sys.exit(1)
midi_path = sys.argv[1]
midi = mido.MidiFile(midi_path)
print("Press F5 to play. F6 to stop")
keyboard.add_hotkey('F5', lambda: control(midi=midi), suppress=True, trigger_on_release=True)
keyboard.wait('F6', suppress=True)
for some reason the keyboard.add_hotkey works outside the console, but the keyboard.wait doesn't
The text was updated successfully, but these errors were encountered:
Hey
I had some problems running the script from outside the console and I found this way to solve it, I leave it here in case you want to add it to the code, I think I can't send pull requests
add:
and in the main:
for some reason the keyboard.add_hotkey works outside the console, but the keyboard.wait doesn't
The text was updated successfully, but these errors were encountered: