Skip to main content

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 and txt2musicxml/grammer/FrontMatter.g4. To generate antlr python classes (Lexer, Parser, Visitor, Listener) from the grammer file, run:

antlr4 -Dlanguage=Python3 txt2musicxml/grammer/Chords.g4 -visitor
antlr4 -Dlanguage=Python3 txt2musicxml/grammer/FrontMatter.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
javac txt2musicxml/grammer/.antlr/FrontMatter*.java
cd txt2musicxml/grammer/.antlr && grun Chords sheet -gui
# or: cd txt2musicxml/grammer/.antlr && grun FrontMatter front_matter -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.

Metadata

Release files for txt2musicxml 0.1.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for txt2musicxml 0.1.12
File Size Uploaded Provenance
txt2musicxml-0.1.12.tar.gz 54.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for txt2musicxml 0.1.12
File Interpreter ABI Platform
txt2musicxml-0.1.12-py3-none-any.whl Python 3 none any Details

Total release size: 133.4 kB

Release files / txt2musicxml-0.1.12.tar.gz

Download URL txt2musicxml-0.1.12.tar.gz
Size 54.9 kB
Tags Source
SHA-256 checksum
How to use checksums
3e5ba39a0d3ca8c9c64a8fe29f89f8f90b2061033e5ee70c16bbbf82262bffed
BLAKE2b-256 checksum
How to use checksums
6f53cee563552b9c58caf8505c2d7d2e6c964886937b4fcf56cc8afa47ee47c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.4 CPython/3.12.7 Darwin/23.6.0

Release files / txt2musicxml-0.1.12-py3-none-any.whl

Download URL txt2musicxml-0.1.12-py3-none-any.whl
Size 78.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
97847cf6f254437043bfcbdbc6a1cfb1ab37bce9c0eca0a57329985cac0acfef
BLAKE2b-256 checksum
How to use checksums
fb1a4628dde59bce0c061f12af440de091a20d595b83cfaa082085356c382313
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.4 CPython/3.12.7 Darwin/23.6.0

Security for txt2musicxml 0.1.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page