Skip to content

Generate music21-Python code to reproduce a given musicxml-file.

Notifications You must be signed in to change notification settings

bwagner/music21generator

Repository files navigation

music21generator

Takes a music21-structure and generates the Python code required to replicate this music21-structure.

 Usage: m21gen.py [OPTIONS] MUSICXML_FILE_PATH

╭─ Arguments ────────────────────────────────────────────────────────────────╮
│ *    musicxml_file_path      TEXT  Path to musicxml file [required]        │
╰────────────────────────────────────────────────────────────────────────────╯
╭─ Options ──────────────────────────────────────────────────────────────────╮
│ --omit-boilerplate       -n        Omit boilerplate code [default: False]  │
│ --display-m21-structure  -m        Display m21 structure (for debugging)   │
│ --help                             Show this message and exit.             │
╰────────────────────────────────────────────────────────────────────────────╯

Purpose

Starting your journey using music21 can be daunting. But you might be experienced using a score editor like musescore, finale, sibelius. So, you could start by creating a skeleton score using any of those editors, export it as musicxml, pass it to m21gen.py, which then generates the Python code that reproduces this document. Finally, use this generated skeleton Python script as a stepping stone and add algorithmic ideas.

Installation

git clone https://github.com/bwagner/music21generator.git
cd music21generator
pip install -r requirements.txt

Use

/path/to/music21generator/m21gen.py MUSICXML_FILE > GENERATED_PYTHON_SCRIPT_NAME

# Generates Python code to reproduce the given MUSICXML_FILE on stdout
# and adds some boilerplate to save the music21-structure generated
# by the generated Python script to a new MUSICXML_FILE. In the above incantation,
# stdout is captured in GENERATED_PYTHON_SCRIPT_NAME.

/path/to/music21generator/m21gen.py MUSICXML_FILE | python

# Generates Python code to reproduce the given MUSICXML_FILE and executes it right away.

Limitations

For now, articulations and many other features of music21 are missing. It's uncertain whether these will ever be implemented, since this tool is only supposed to help you get started.

Contributing

git clone https://github.com/bwagner/music21generator.git
cd music21generator
pip install -r requirements.txt -r dev-requirements.txt
pre-commit install

Tests

cd music21generator
pytest

Thanks

About

Generate music21-Python code to reproduce a given musicxml-file.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages