Learn Guitar Via Python Programming (MIDI Parsing)

Rishabh Shah (~rishabh104)




Ever wanted to play your favourite song on guitar quickly even when you don’t know how to play guitar? Our Python based MIDI to guitar tabs Transcriber can help you do that:

• Find your song in MIDI format (with .mid as file extension)

• Let our Python Transcriber do its magic

• Enjoy the tablatures

Transcribing MIDI files directly to tablature creation ready JSON

A lot of people take to learning the guitar every year. But most of them give up mid-way because of one or more of the following reasons:

  • Guitar is a difficult instrument to learn
  • People want to learn guitar by playing songs but are unable to do so right from the beginning
  • Results are often not visible immediately depending on a person's existing knowledge of music and willingness to learn guitar

Enter Python

Though it seems to be quite easy to manually create and make the app read guitar tablatures for songs, the following challenges need to be addressed:

  • Readiness of the output to support playback of a song along with tablatures - this essentially means storing the timing for each note/chord (when many notes are played together) in order to play the song exactly as it is
  • The whole process would be incredibly time consuming

In order to overcome these challenges, a simple yet efficient solution was derived - to convert a MIDI file directly into guitar tablatures.

Python was chosen for implementation of the solution for the following reasons:

  • Python has a very efficient and time saving file I/O mechanism and the current use case operates completely on MIDI files and the Transcriber outputs a JSON file, which in turn is served to the client.
  • More libraries to read MIDI files and present them in an understandable manner than any other language and their ease of use. These libraries, when used in conjunction with each other offer all the features that Java's javax.sound.midi package offers.
  • Availability of renowned libraries such as numpy and scipy for the algorithm to determine most optimal finger positions
  • A plethora of options for using a server side framework to host the Transcriber as a service
  • Since Python is an interpreted language, it is really useful for quick experimentation with tools like IPython unlike languages like Java in which complete programs need to be compiled beforehand. This saved us a lot of time.

...Where Credit is Due

The solution could not be achieved without the use of the fantastic libraries used below for reading MIDI files:

The authors have our gratitude.

How the Transcriber Works

The high level working of the Transcriber is as follows:

  • MIDI files are read and all the guitar parts in the song (commonly referred to as guitar tracks) are extracted in the form of notes and chords
  • An algorithm calculates the best possible finger placement on the guitar fretboard for these notes and chords
  • A time driven JSON is generated for use by any platform that can parse JSON to do one or more of the following:
    • Play the song
    • Display guitar tabs in sync along with song playback
    • Only display guitar tabs

Why Use the Transcriber?

Some work has already been done in this area and there are existing open source solutions like TuxGuitar and a few others. But the Transcriber here produces up to 70% better results than any of these solutions.

By better, the following is meant:

  • Transcriber generates more easily playable tablatures
  • The tablatures also mimic up to 60% of most of the original tablatures


  • Core python
  • Ability to integrate and use third party libraries

Content URLs:

Slides Url

Speaker Info:

  1. RIshabh Shah

    Rishabh has around 4 years of python programming experience, he has developed an array of applications of which one was this Transcriber. Inputs from real world guitar players have been quite useful while developing the Transcriber. He developed this transcriber with one of his colleagues Srinivas Kalyani 2. Srinivas Kalyani

Srinivas has around 3 years of technical experience with nearly 1.5 years of experience in Python. He has worked primarily on Django and entered the world of Core Python while writing the Transcriber.

Section: Data science
Type: Talks
Target Audience: Intermediate
Last Updated:

Cool! Looking forward to try this out.

Anand B Pillai (~pythonhacker)

Cool! Looking forward to try this out.

Anand B Pillai (~pythonhacker)
The comment is marked as spam.


Login to add a new comment.