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

Feature suggestion #24

Open Jakeysause opened 2 years ago

Jakeysause commented 2 years ago

I was wondering if you could add midi velocity, like if I was using a midi input to roblox. And maybe add full support for 88keys aswell.

Stereo101 commented 2 years ago

Without writing midi events directly, there is no way for me to represent key velocity using keyboard presses like you could with an actual midi keyboard. The key is either pressed or it isn't . This makes songs that have half pressed notes sound rather poor, but there is nothing I can do about that.

If you want midi input support, and the platform you are targeting supports it, I would recommend using a different program. Full midi input will always be richer than what you can do with keyboard. This program is better for platforms where that option isn't available.

Jakeysause commented 2 years ago

Without writing midi events directly, there is no way for me to represent key velocity using keyboard presses like you could with an actual midi keyboard. The key is either pressed or it isn't . This makes songs that have half pressed notes sound rather poor, but there is nothing I can do about that.

If you want midi input support, and the platform you are targeting supports it, I would recommend using a different program. Full midi input will always be richer than what you can do with keyboard. This program is better for platforms where that option isn't available.

I was only asking for this game that is called Piano visualizations 2, they made a program for midi input to qwerty. I have pasted the link to the program, I guess the next question would be could you make a midi to midi input, so that I can use their program to then convert that midi input to qwerty?

Stereo101 commented 2 years ago

I'll look into it. I have the exe, deleting for security/safety purposes just in case.

Jakeysause commented 2 years ago

Alright thank you, hope I am not asking to much of you to do.

Stereo101 commented 2 years ago

I had to track down the source code of the executable you linked but I found it and figured out what it was doing. I visited the discord server Piano Visualizations 2 and even talked to a server dev a bit and he was a cool dude. He had his own working midi player that took velocity into account as well.

Inside the discord I found some of my old code that somebody modified to mass convert midi to virtualpiano sheet music. Happy to see it getting some use.

Anyways the Piano Visualizations 2 uses alt+key to change the the global note velocity. The program sets the global key velocity before every played note. This can work because the Piano Visualizations 2 server manages to accept key presses at an impressive rate beating out virtualpiano.net, the VRchat pianos, and other roblox piano servers. It manages to sound great with minimal audio peaking as well.

Currently, velocity information is extracted but not passed on by pyMIDI. I can change that and create a Roblox:PV2 specific configuration to get it working. It might take a bit of time to build those systems out.

Jakeysause commented 2 years ago

That is wonderful, I see that you had a brief conversation with tainted_desires aswell, I suppose just keep me updated on the progress, and that you again for taking my suggestion into consideration. I hope that I am no inconvenience, and that you are enjoying this quote on quote project.

Jakeysause commented 2 years ago

How is everything going so far?

Stereo101 commented 2 years ago

How is everything going so far?

Ahhh sorry to leave you hanging. I thought I already posted this about a little over a week ago, must not have hit enter to publish the comment.

My PC's SSD died about a week ago, but I already got all the work I had done pushed to github under a dev branch. I don't have a working windows install to continue development currently.

I added a settings system, and a janky REPL interface that just barely gets the job done. You can process midi's (in bulk now!), change settings, and play songs from the same interface.

I got the setting for alt velocity working, but I had some issues with alt keys already being bound at an operating system level which mute my volume and adjust up and down during playback. I tried to figure out which keybinds these were to exclude them, but I inexplicably couldn't get the same things to happen pressing the alt+key combinations manually. You might not have the same issues.

You can check out the dev branch which has these changes.

To turn alt_velocity on either type in set alt_velocity true to use the setting for the session, or turn it on permanently by changing by including the Piano Visualizations 2 config file by editing the config_order line in settings.json to "config_order":["base.json","roblox_piano_visualizations_2.json"].