Skip to main content

piano2sheet

·2 mins
Check out the code on Github!

Converts Synthesia videos to sheet music.

Demo #

Demo showing that the keyboard notes are being tracked as they are played

Learning objectives #

The story behind this project is that both myself and a friend were interested in the field of Computer Science; however, neither of us knew the first thing about coding. This was the very first project we worked on to see if we had the motivation to learn a new skill on our own time.

  • Attempt to learn a programming language (Python) through online resources
  • Share the knowledge we’ve learned and encourage each other
  • Wrap up a project together - unfortunately, we got as far as detecting the notes, as seen in the .gif above!
  • Determine whether or not this is a career we could see ourselves pursuing - the answer to this is an emphatic YES

Technologies used #

TechnologyDescription
Pythonused in conjunction with Jupyter to develop the script
OpenCVan open-source library with many computer vision tools that were helpful in detecting the keyboard notes being played

How does it work #

As MIDI keyboards are capable of exporting key presses to Synthesia in a very systematic manner, we can use this to detect which keys are being played, and when.

1. The video output is consistently ordered

There are 52 white keys and 36 black keys on a standard piano.

Picture of a Synthesia keyboard

2. The key portion can be extracted

We can crop and threshold the image to identify the keys.

Cropped and thresholding image of the keyboard

3. We can run detection algorithms on the thresholded image

Check out this GIF that highlights the detected black keys. This can be similarly performed for the white keys.

Animation of the black keys being deteced

4. From any image, we can perform the same thresholding

Side-by-side comparison of the raw image and thesholded image.

Notes played in Synthesia
Thresholded image

5. Fully connected notes need to be segmented

This image shows two distinctly coloured notes that can be thresholded by using a histogram and identifying the peak.

Two overlapping notes

The result is:

First note detected
Second note detected

6. And the full detection run on the image

Detection on all notes

7. Perform this on every frame of the video

Check out the .gif above