MMML extension for event based framework for generative art
Project description
mutwo.mmml
This package adds parsers and specifications for the 'mutwo music markup language' (short: MMML). With this language it's easy, fast and convenient to write music in a text file. MMML consist of expressions that can be converted to mutwo events. The package also adds reverse parsers, to convert mutwo events back to MMML.
Installation
mutwo.mmml is available on pypi and can be installed via pip:
pip3 install mutwo.mmml
The rules
MMML is a very simple and minimalistic file format with few, but quite strict rules.
1 MMML expression <=> 1 event
- A MMML string consist of only one MMML expression.
- Each MMML expression consist of exactly 1 event.
- But an event can have children events (it can be nested).
An MMML expression = head + block
- An MMML expression has two parts: a head and a block.
- The head tells what type of event we have with which arguments.
- The block defines all children events that our main event has.
$HEAD
$BLOCK
The head: main event (= container) definition
- An MMML expression head is defined across exactly one line in a text.
- It consist of different parts that are separated by one or more white spaces.
- The first part of a head declares the event type, all other parts are arguments for the event. All arguments are optional.
$EVENT_TYPE $ARG_0 $ARG_1 ... $ARG_N
The block: children events definitions
- To start a block after a head, we need to increase the indentation of +4 white spaces compared to the indentation level of the head.
- A block is composed of one or more MMML expressions.
- In this way we can define on or more events that are part of the main event that's defined in the head.
$HEAD
$MMML_EXPRESSION_0
$MMML_EXPRESSION_1
$MMML_EXPRESSION_2
...
$MMML_EXPRESSION_N
Builtin head / event types
mutwo.mmml provides few builtin events:
cns $tag $tempo
Renders to Consecution.
cnc $tag $tempo
Renders to Concurrence.
n $duration $pitch $volume $playing_indicator_collection $notation_indicator_collection $lyric $instument_list
Renders to NoteLike.
r $duration $volume $playing_indicator_collection $notation_indicator_collection $lyric $instument_list
Renders to NoteLike.
Same like n, but without the option to specify pitches.
Extra rules
Besides the basic rules, MMML has a few extra rules to make using the language more convenient. They generally aim to be easily implementable and not making the language too complex.
- Empty lines are ignored. Empty means 'only white space or tabs' or 'nothing at all'.
- Any line, where the first character (that's not white space) is '#', is also ignored. Such a line is regarded as a comment.
- The special head argument
_is always skipped. In this way it's possible to define for instance the fourth argument of an event without necessarily having to declare all three previous arguments.
Example
# We can write comments when starting a line with '#'
# whitespace at the beggining is ignored for comments
# Let's express one simultaneous event that contains our music.
cnc music
# It contains two sequences: a violin and a cello voice.
cns violin
# 'n' is used to express a note.
n 1/4 a5 p
n 1/4 bf5
n 1/4 a5
# We can skip arguments with _
n 1/8 _ _ fermata.type=fermata
# 'r' is used to express a rest.
r 1/4
n 1/4 a5 mf
n 1/4 bf5 mp
n 1/4 a5
r 1/4
cns cello
n 1/2 c3 p
r 1/2
n 1/2 d3 p
r 1/2
Extending mutwo.mmml
mutwo.mmml can easily be appended by new event types.
Already given event types can also be overridden.
For this purpose mutwo.mmml uses a registry as a API.
To understand how this can be used simply check the respective source code.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mutwo_mmml-0.10.0.tar.gz.
File metadata
- Download URL: mutwo_mmml-0.10.0.tar.gz
- Upload date:
- Size: 24.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a00a3cc581ef0df4b78185dd5ab8fdf273cbb3a92cde34dabf0139b1ea4895e
|
|
| MD5 |
18f14d6019d194e78bcbafa9bda9a4d3
|
|
| BLAKE2b-256 |
11e08921c14234fcee458d57044911c8e4be4ef0354fa1ca098d2696a7d8ae9e
|
File details
Details for the file mutwo_mmml-0.10.0-py3-none-any.whl.
File metadata
- Download URL: mutwo_mmml-0.10.0-py3-none-any.whl
- Upload date:
- Size: 24.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5876e6349e7ef210aacf1ff34be98c085c5634c4437eb8f6e18605e03e7f76e4
|
|
| MD5 |
1d21438019d9ff2bc448fd147e679c06
|
|
| BLAKE2b-256 |
8f0ab37b511836843c3391e7c06891b906caba386c2ead4a1053a8cdfda3c561
|