Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

I love that the keys actually move differently for every song. I don't know what wizardry you actually used but converting a MIDI file to the actual piano keys being pressed is incredible.

This can be used so for many situation, for example even for a horror game this could be cool where a creepy songs starts playing and the piano keys actually move by themselves.

Overall really cool and creative idea for a tool and amazingly well done.

____________________________________________________________________________________

The project intrigued me so much I even had to have a look at the source code. I did see that you used DRYWETMIDI to handle midi files. I can also see that you watched the Pause in Unity WITHOUT Timescale video for your Pausing ;P and I appreciate how much your worked with Custom Editors to simplify your workflow (recently got into that as well).

Overall really cool project I do hope it wasn't to tedious tough to enter the animation state for all the keys tough XD.

Btw. I would recommend putting your files into a separate assembly so it doesn't bog down compile speed when a user that uses the package makes changes to their code.

____________________________________________________________________________________

PS. the title might be a bit confusing tough I'd rather choose something like "MIDI piano animator" or something in that direction, because currently the title makes you think that you can press the keys yourself even tough what you currently have is, in my opinion, much cooler.

(+1)

Thanks for the awesome review :D

Getting the piano keys from the MIDI file was actually not that hard, as the DRYWETMIDI library handled most of the work for me; all I did was just add some coroutines that wait until the note is played in the MIDI file and trigger the appropriate unity events. Significantly harder was the job of syncing the audio source to the MIDI, as audio runs on a separate thread and triggering all the coroutines takes a significant amount of time. D:
Originally I used WaitForSecondsRealtime (just WaitForSeconds didn't even work in the slightest), but then I noticed that a coroutine that was parsed at the beginning  triggered at a different apparent time than one at the end. The final implementation involved me actually looking up the source code of WaitForSecondsRealtime (unity does that btw) to see how it was implemented. Turns out they use Time.realtimeSinceStartup which I cached before starting all the coroutines and made them WaitUntil their place in the midi file was reached, but taking into account this Time.realtimeSinceStartup. The difference between the cached and current realtime is then sent as the starting point to the audio source, which is then asked to play from there. :0 (took me ages to get right ):

Animation was done procedurally: I started by recording my digital piano with my phone, going frame by frame to see how a real key looks like when pressed and plotting that against the velocity of the key. I then used THE POWER OF MATHS  to get an exponential function to determine how much time it takes until the key is depressed and used that in the PianoKeyAnimator script. I also found that the real keys will bounce back a little bit when pressed and overshoot when released and added a bit of that to the aforementioned script.

I also wanted to make it all work with custom implementations, so instead of for example hard coding the PianoKeyAnimator script to the PianoKey, I use unity events, in case someone wanted to add a custom implementation. But I was having trouble with hooking up all 88 keys, which is why I tried to make it easier with custom editor scripts (this is my first project with them :0) The video you mentioned is one I actually had not seen, but I suppose great minds must think alike :P

The assembly tip is one I wasn't aware of, but seems super useful and will definitely be using in the future. :D

The title was chosen as my goal to what this project will become - a truly interactive piano - I only had enough time to add the MIDI support in this jam (adding a sampler seems like a ton of work D:), however I very much intend to add functionality like the pressing of keys to this tool. Scenarios like your horror game is just one that I want to support, developers should be able to then decide for example whether or not they want players to be able to press the keys.
You can think of this as a demo of what is to come in that sense, Let me know if there's anything else along those lines you think could fit in here! (I've got my eyes on adding  recording support as well for example) :D

Thanks again for taking the time to write about this! :D  I can't wait to improve it!