Stereo101 / python-MidiToVirtualPianoMacro

Takes a midi file and converts it into a macro which will play the midi using virtualpiano.net. Uses pyHook and ctypes for macro execution.
96 stars 82 forks source link

tempo refinements, pausing, python 3.9 #18

Closed ken-tn closed 3 years ago

ken-tn commented 3 years ago

uses import keyboard instead of pyhook uses import threading adds pausing, rewind, skip (del, end, home) use index instead of time dynamic tempo

not tested on linux/mac

g1-1-1 commented 3 years ago

why did you close this PR?

ken-tn commented 3 years ago

i messed up some code, it's fixed now

Stereo101 commented 3 years ago

I like most of these changes, especially using the "import keyboard" over the horrible boilerplate I was using before. I'm mixed about opening a new thread for every keypress, but it would solve most of the concurrency issues I remember having.

There still seems to be some issues. Playing "bach.mid" included in the directory. Some notes are generating a 2 second wait that shouldn't be.

Playing "CorridorsOfTime.mid", notes that are pressed in succession seem to not work due to the code meant to hold notes down instead of instantly releasing them.

keyboard.press(strLetter) keyboard.call_later(keyboard.release, args=(strLetter), delay=t)

releasing the key earlier fixes this:

keyboard.call_later(keyboard.release, args=(strLetter), delay=t*.5)

Another an error that prevents certain notes from playing was also made on playSong.py:40 which needs to be keyboard.call_later(keyboard.release, args=(strLetter.lower()), delay=t) instead of keyboard.call_later(keyboard.release, args=(strLetter), delay=t)

With the above 2 changes, "CorridorsOfTime.mid" plays properly (after a manual tempo set in song.txt)

ken-tn commented 3 years ago

that should be most of the bugs gone might be some small things left though