Skip to main content

CLI tool to convert chords written in simple text to musicxml files that can be used with a music notation software

Project description

txt2musicxml

A simple tool to convert chords from text to musicxml. Musicxml files can be opened with most notation software (for example MuseScore, which is free and open source).

Install

use pipx

pipx install txt2musicxml

Usage

pipe a string of chords into the cli

echo -n 'Cmaj7 A7 | Dm9 G7b9,13 |' | txt2musicxml

or redirect input/output from/to a file

txt2musicxml < path/to/Thriller.crd > path/to/Thriller.musicxml

Syntax Example

Aguas de Marco - Elis Regina & Tom Jobim:

Bb/Ab | % |
Bb/Ab | Gm6 Cm7b5/Gb |
Bbmaj7/F E9b5 | Ebmaj9 Ab9 |
Bbmaj7 Bb7 | C7/E Ebm6 |
Bbmaj7/F Bb7 | C7/E Ebm6 :||

Export to PDF (with MuseScore)

Install MuseScore 3 and make sure to add mscore to your PATH. Not fully tested with v4. % doesn't work in v3.

TMPSUFFIX=.musicxml; mscore -o path/to/output.pdf =(txt2musicxml < path/to/input.crd)

Developing Locally

Dependencies

In order to change the grammer and regenerate lexer/parser/etc:

For other development:

  • python ^3.9
    • I suggest using pyenv to manage multiple python versions on your machine
  • poetry - to manage virtual env
  • Make - to help run useful commands

Updating and Debugging

Grammer is defined in txt2musicxml/grammer/Chords.g4. To generate antlr python classes (Lexer, Parser, Visitor, Listener) from the grammer file, run:

antlr4 -Dlanguage=Python3 txt2musicxml/grammer/Chords.g4 -visitor

Those classes are direct dependencies of the application, they must exist for the main program to run.

To use the built-in antlr GUI and debug your grammer, first compile those java classes, and then run the gui:

javac txt2musicxml/grammer/.antlr/Chords*.java
cd txt2musicxml/grammer/.antlr && grun Chords sheet -gui

Then enter some text and hit ^D (on mac) to indicate EOF, and see the parse tree get generated!

NOTE: Chords and sheet are names unique to the program (grammer name, root element), if you change the grammer file, the commands you run should change as well.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

txt2musicxml-0.1.8.tar.gz (40.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

txt2musicxml-0.1.8-py3-none-any.whl (54.1 kB view details)

Uploaded Python 3

File details

Details for the file txt2musicxml-0.1.8.tar.gz.

File metadata

  • Download URL: txt2musicxml-0.1.8.tar.gz
  • Upload date:
  • Size: 40.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.7 Darwin/23.6.0

File hashes

Hashes for txt2musicxml-0.1.8.tar.gz
Algorithm Hash digest
SHA256 d42b5623b2b00ba0d483609374866da2a24407484fe5afe995425cb10ed8adec
MD5 39f31909375b949742e45f7f74d0b930
BLAKE2b-256 8d64e540700c01efa86f0554cb462f77b263d515c833a082b0c05060abe90f3f

See more details on using hashes here.

File details

Details for the file txt2musicxml-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: txt2musicxml-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 54.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.7 Darwin/23.6.0

File hashes

Hashes for txt2musicxml-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 f400013e025db9a3feca5cfc2f77b37ad28ac3d4e12d2f342a71e11b7dbec012
MD5 c842c503e85ef6a1793f55e3daaddf90
BLAKE2b-256 02315be7423a0491f60e1163ca1a6b8a69d3063849dfbddf4acd5add7255e5bd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page