Show HN: RoboPianist, a piano playing robot simulation in the browser
kevinzakka.github.io
kevinzakka.github.io
What part of this is pre-coded? What part is being generated? Is the goal to give a program some sheet music (maybe a MIDI file) and it figures out the fingerings[1] and then translates the fingerings into kinematics?
Because if that's the goal... Holy forking shirtballs that would be amazing. One of the trickiest things for me as a novice pianist is figuring out the fingerings to a piece. It's like a puzzle you work at until you've figured out what's comfortable. It's all about lookahead. "This section generally goes down so I probably want to begin with my pinky and not my thumb."
And if it got really good at that, not only are the fingerings useful, but maybe we could get feedback on how physically demanding a piece is. Another challenge I've discovered as a novice is that it can be surprisingly tricky to look at sheet music or hear a piece and determine if it's as easy as it sounds. Some pieces require some very complex fingering.
[1] what pianists call the determination of what fingers go where, not just to play certain notes together, but to ensure you can fluidly and comfortably play the next notes as well.
I'll use a piece that I am practicing right now to illustrate: Chopin Etude Op 25 #1 ("Aeolian Harp").
Sheet music: https://imslp.org/wiki/Special:ReverseLookup/112921 (the Herrmann Scholtz one) Performance: https://www.youtube.com/watch?v=Ob0AQLp3a5s
For intermediate pianists (perhaps even beginners), the possible fingerings are actually really obvious just from looking at the notes, especially when using the suggested fingerings as a guide. This piece is structured around playing broken chords in circles, so there aren't really any fingering tricks here.
Notice the chords like the first right hand chord on the second bar on the second line, or the simpler left hand 4-note chords on the third line of the second page. Despite the obvious fingerings, somehow you need to figure out how play a broken chord that spans 15 keys, a distance that no one can comfortably cover by just stretching thumb and pinky. And that is because this piece is a study in the circular motion of the wrist (and really, the entire arm). If you do not realize this and try to simply try to stretch your fingers to go from key to key, not only will that limit your ability to increase your speed, but will build tension in your wrist as you go through this piece and eventually lead to injury. Not to mention that it really hurts to stretch your fingers with a static wrist.
(In my Jan Ekier edition of this piece, some of these ~15 key chords have two fingering suggestions that you can play with to decide which one you prefer.)
It may eventually be solvable, but this is a multiple dimensional problem, and a useful AI for this will need to give you a solution in multiple dimensions. If an AI can teach me all the motions of Chopin's etudes and allow me to just think about how to voice these pieces, maybe I won't need a teacher anymore.
The demo you are watching is an agent trained from scratch with reinforcement learning. It has roughly 6 days of experience (10M steps at 20 Hz). The Javascript demo is replaying the policy open loop which is why it's not super robust to disturbances.
Re:fingering: we actually use fingering information to create a dense reward for the agent (otherwise it makes exploration super hard). It would be an exciting future direction to have the agent discover and optimize for fingering that best suits its kinematics :) And beyond that, having RL inform pianists about the difficulty of a piece or even more optimal fingering would be amazing.
We trained a bunch of these policies on roughly 150 songs (baroque, romantic, classical) and we did some analysis in the paper if you're interested: https://kzakka.com/robopianist/robopianist.pdf
Horowitz famously leaves his pinky curled most of the time: https://youtu.be/9LqdfjZYEVE
Watch closely how Gould will press a key with his ring finger and then switch to the pinky to hold it: https://youtu.be/p4yAB37wG5s
It's also strange that all fingers are always parallel, but I guess that adding that freedom makes the search space huge.
Another question: The pinky finger is not shorter than the other fingers. Can it be a problem for the robot to use the human fingering?
If you crack this in a deterministic way it would be super useful as a library.
There are two motions in particular that pianists use constantly that don't seem to be represented in the robot model, if you're looking to get closer to the way that human limbs and digits operate. (Naturally there are plenty of other goals, but if you can imitate human playing you can do things like suggest fingerings or assess difficulty, as you say.)
1) turning at the elbow (so that your forearm can make an angle with the piano keyboard instead of always being perpendicular to it). It looks like you translate the forearm back and forth instead, which I assume must be a lot easier to handle because of course it's not how human arms work.
2) rotating the forearm/wrist (like turning a doorknob). Pianists do this on basically every note to a greater or lesser extent. To take an extreme example, if you alternate notes with your thumb and pinky you are almost completely using your wrist and not your fingers. Without this degree of freedom it is not really possible to emulate a competent pianist, if that is one of the eventual goals.
We ended up picking a minimal subset of forearm DoFs that wouldn't impact training speed too much.
I had been playing with the idea of creating a browser-based virtual piano for when I'm travelling and don't have access to a real piano but have my laptop with me. The idea would be to point the webcam down at the table between me and the laptop, and play on the table as if a piano were there. Then use the mediapipe framework [1] to capture finger positions, and use those to update a virtual environment like the one you have here.
I put it on hold due to the significant engineering required, but it seems you have already implemented (and open sourced!) the browser-based piano simulation component.
A quick scan through your repo indicates that this is all implemented in Python. I see that you are using mujoco_wasm [2]. Can you please comment on what is required to compile your project to work in the browser?
Thank you again!
After that it seemed to work OK.
I say, Computer?
Uh. you just have to use the _keyboard_
ah, a keyboard, how quaint!
-
How many words a minute can it type?
and while the refinements in movement finess and control are obviously a needed thing, out of ignorance, what other abilities will this allow?
I assume that it will allow for a much more finessed touch control of hands/digits, and, coupled with sensors, as they evolve, be able for much more fine crafts - such as embroidery?
Uncaught Error: buffer is either not set or not loaded
ti https://unpkg.com/tone@14.7.77:1
start https://unpkg.com/tone@14.7.77:21
triggerAttack https://unpkg.com/tone@14.7.77:21
triggerAttack https://unpkg.com/tone@14.7.77:21
processPianoState https://kevinzakka.github.io/robopianist-demo/examples/main.js:174
render https://kevinzakka.github.io/robopianist-demo/examples/main.js:255
onAnimationFrame https://kevinzakka.github.io/robopianist-demo/node_modules/three/build/three.module.js:27951
onAnimationFrame https://kevinzakka.github.io/robopianist-demo/node_modules/three/build/three.module.js:12661
This is in a recent Firefox.They claim to be able to generate fingerings and animations from raw audio. The video demos give an idea of the output, but they seem to be shutting down.
In particular, there seems to be not much ability to move each finger left or right. For example, actuator 14 lets the baby finger swing outwards - but now try to stretch your baby finger out, and you see it can swing much further than this robot finger can swing out, and the pivot is closer to your wrist, allowing more reach.
It would be equivalent to you trying to play a holographic piano in the air in front of you. I suspect you'd adopt a very different hand position too.
The keys are actually implemented using a spring mechanism, but springs in MuJoCo are currently linear, which isn't the case in the real world.
From their whitepaper: "Fingerings in the dataset were provided by experienced pianists who graduated from a music college or who had played the piano for more than twenty years. The pianists were asked to choose pieces that they could play and provided the fingering that they had actually used for the performance."