[Piano Player] TU Midi Player

Greetings,

After experimenting for a while with the various piano playing applications that people have made I have decided to create my own.
This one is a little different from the rest, it’ll play a midi file directly rather than relying on a key sheet as the others do.

The interface basically explains itself but here are some little nuances that you should be aware of;

  • If you browse a file mid-playback your song will be stopped

  • There is a 3 second delay after pressing ‘Start’ to the keys being pressed

  • This will only play *.mid and *.midi files made specifically for the piano, if you give it a 16 track midi file with guitars and who knows what else it’ll throw an error or give a funky output.

  • This implementation only supports 61-key pianos such as the TU piano, any notes outside this range will not be interpreted.

  • Like everybody else I have struggled for the past week to get black keys to play but to no avail. I will be doing my best to solve this problem but so far I have no leads as to how to fix this. Luckily these notes will still be played however they will default to their natural counterpart e.g. C# => C

If you find any bugs, want to suggest new features or just want to give me some feedback please post them here :smile:

Current known bugs:

  • Sometimes impossible to alt-tab back into the software until the song is finished. Hotkey support will be added soon.

Current Version:
v1.1.0, 13th June 2016.

Patch notes v1.1.0:

  • Added hotkey support.
  • Added keyboard buffer clear-up on forced and natural playback halting.

Download Link:
Here

How to run:
Simply run the “midiplayer.exe” contained in the zip file. All of the required Python files are included.

Where can I find music to play?:
I have been using this website for most of mine, it’s a coin toss as to whether they sound decent.

Previous Versions:
v1.0.0 (Release), 10th June 2016, Here.

11 Likes

:ok_hand:

Instead of changing sharps and flats to the natural counterpart, is it possible to transpose the entire song to the key of C? I feel that might clear up a lot of black notes in songs right now, excluding non-chord tones.

1 Like

@Cakemagic That could be a viable solution for now, I’ll have a look into it and see what I can come up with.

This just holds all the keys it tries to play down for me and doesn’t play the song for and mid/midi I tried.
Video: https://dl.dropboxusercontent.com/u/157593752/Recordings/2016-06-10-1113-43.mp4

1 Like

It worked for me, although the song I used was in the key of D so it was pretty off in a lot of parts due to heavy black key usage, but for the most part it worked.

@prodigalist

This is a problem with formatting of some midi files.
Basically a midi file contains values for note_on and note_off with a timing to tell the software how long to keep that note on for, however some files don’t contain values for note_off hence why you’re seeing keys stay stuck down.

I’m not sure how many midi files this will affect as from what I’ve seen it mainly happens when playing files which aren’t piano specific (for example a lot of the Runescape music you will find), however I can look into adding support for them as well once I work out how to process them properly.

1 Like

Damn, I’m using midi files from the original Ultima Online release and some from other games and encountered the same issue. I just always wanted to be able to play alot of these rather than actual piano songs, it seems like the player picks up the right keys but the note_on/note_off stuff is all that’s preventing it.
It would be cool to have a feature like the midi to piano sheet converter had where you can disable certain midi layers from playing too.

Are you planning on releasing the source code? Would be interesting to see how it works.

@GreenGiant, I wasn’t really planning to. It’d need re-factoring before I’d release it since it’s not my best work, I was mainly concerned with getting it to work properly first.
When I get around to adding in multi-track selection I’ll have to chop and change half of the code so I’ll re-factor it all when I do that.
Sorry if that’s not what you wanted to hear :innocent:

EDIT:
I had some free time to look into track selection and it seems fairly doable, I’ll start work on it soon but I won’t have an ETA on it for a little while.
As for transposing it looks very involved, I’ll be putting most of my effort into fixing the ongoing black-key problem since that will sort out the problem more elegantly (If I can actually solve it…).

2 Likes

Three cheers for updates!
Today I’ve added hotkey support, pressing F1 will force the file to stop playing and clear your keyboard buffer.
It’s nothing ground-breaking but I know one or two people who have been having trouble with runaway songs.
Download link in the OP.

I’ll add more hotkeys in the future, this was all I had time for today.

If this is going to be something that you’re going to update periodically, do you think you could make an SVN?

1 Like

It wasn’t my intention to release updates too frequently but as it is a possibility I’ll move everything over to a git repository for subsequent work.
The only reason I didn’t start off this way is that from past experience GitHub can be a pain in the backside sometimes.

I just started using this, and it works fine except for one major bug. Whenever it plays a key, the key sticks and it can’t play that key again. I can get the key unstuck by manually pressing it on my keyboard, but that’s not going to do any good. Am I doing something wrong?

1 Like

It’s not you, it’s the midi, sometimes, the way midis work is that the midi is telling a key to play at a certain time and for a certain amount of time, the player knows that the midi is telling the player to play a key, so it does, but midis can be in different formats where its not telling it where to stop relative to the whole timeline, but to stop after a duration of the note. Hope I explained that right.

I understand. I figured it was something to do with the actual file.

Long time no see friends.
Work has died down enough that I have been able to have a look into this again and it looks like I may be on to a lead regarding the shift-key problem.
Now assuming that nobody else has solved this yet then I will be rebuilding this program in C++ and simulating a USB input device rather than trying to input keystrokes through the input buffer, hopefully this will lead to a successful shift-key modifier and thus give us sharp notes!

I will release a version of this soon™ but note that it will most likely feature only a command line interface for now.

Since I haven’t been here in a while I’m unsure whether or not somebody else has already achieved this so if they have please say so that I don’t waste my life on a pointless task.

I’m curious how this and stuff like keyboard macros will be handled due to the EULA and the recent crackdowns on people using automation. Would really suck to see stuff like this go.

Oh shoot, you got a huge point there

If they make Macro detection a server thing, then it shouldnt affect condos I dont think

Since my last post in September I have been fiddling with this on and off and have yet to find a solution that works for windows.

So far the black keys remain out of reach for virtual keys, the only solution thus-far with any sort of potential being the emulation of a physical keyboard over IP, which is difficult to get working at the best of times on a machine where I have full administrative access - not something that is possible when distributing this software to a wider audience.

Unfortunately it looks like the reason for the above is that the virtual piano inside TU is coded in such a way that it will not acknowledge the following virtual keys with the win32 api:
0x10 - Shift
0xA0 - LShift
0xA1 - RShift

My tin foil hat is telling me that it was designed specifically to stop us from having automated piano players that work properly :frowning:.

I will open this software up to everybody through github so that anybody with some smart ideas can see if they have some cheeky work arounds that… work. (I am a Linux SA, naturally you should not expect the most efficient nor well structured code. I make things that work* ;))

*sometimes.

2 Likes