Skip to content

petern3/guitar_music_converter

Repository files navigation

Guitar Music Converter

A set of tools to convert between guitar music formats

About

This project was initially an attempt to programmatically convert guitar music from plaintext (as in most guitar music websites) to the chordpro format (as chordie and worship together can provide). This is similar to several other git projects, with the difference that it is intended to be easy to add new formats/sources (see below).

File Breakdown

There are four parts of the project:

  1. Command-line program to convert between formats
  2. Parser to read/write to different sources (such as files or URLs)
  3. Parser to read/write to a string from different formats
  4. A intermediate format to store the information regardless of music type

1) Command-line Program

convert_song.py

This hasn't been done properly yet. It doubles as an example of how to use the python packages.

2) Source Parsers

source_parsers/*

Each source_parser converts the music from whatever file format it comes from into a string This string has yet to be converted into the Song format, which the format_parsers do. Sources include:

Text files

URLs**

HTTP/HTTPS**
FTP**

MS Word files**

MS Powerpoint files*

(This is because I have lots of music in an obscure powerpoint format)

*Will be implemented

**May be implemented

3) Format Parsers

format_parsers/*

Each format_parser converts the music from a plaintext string of the song into the Song format. Formats include:

Plaintext

VERSE
Fm            Db
  I have this sinking feeling

Chordpro*

{c:VERSE}          
[Fm]  I have this [Db]sinking feeling

json

(because this is the native format of the Song object, see below for example)

Latex**

HTML** (if not converted by the source_parser)

*Will be implemented

**May be implemented

Full examples can be found in the example_formats folder

4) Internal Song Format

song_object.py
song_primitives.py

The Song object is a structure for containing all the song meta-data (title, author, capo etc) as well as the music itself. The data is all stored in a dictionary/list tree structure so that it is easy to save as a json to debug. The song primitives include classes for: Meta-data, Labels (eg Verses), Chords and Instructions (eg 'Mute').

A sample of what a line looks like is below. It is by no means the most compact or human-readible format, but it shows how the data is stored, and what kind of information it holds.

{
  "line_list": [
    {
      "chord_dict": {
        "0": {
          "bass": null,
          "root": "F",
          "mod": "m"
        },
        "14": {
          "bass": null,
          "root": "Db",
          "mod": null
        }
      },
      "lyric": "  I have this sinking feeling"
    }
  ],
  "label": {
    "alt": null,
    "label_type": "verse",
    "value": null,
    "pre": false
  }
}

Releases

No releases published

Packages

No packages published

Languages