Skip to main content

MMML extension for event based framework for generative art

Project description

mutwo.mmml

Build Status License: GPL v3 PyPI version Code style: black

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

  1. A MMML string consist of only one MMML expression.
  2. Each MMML expression consist of exactly 1 event.
  3. But an event can have children events (it can be nested).

An MMML expression = head + block

  1. An MMML expression has two parts: a head and a block.
  2. The head tells what type of event we have with which arguments.
  3. The block defines all children events that our main event has.
$HEAD
    $BLOCK

The head: main event (= container) definition

  1. An MMML expression head is defined across exactly one line in a text.
  2. It consist of different parts that are separated by one or more white spaces.
  3. 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

  1. 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.
  2. A block is composed of one or more MMML expressions.
  3. 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

Renders to Consecution, its only argument is its 'tag'.

cnc $tag

Renders to Concurrence, its only argument is its 'tag'.

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.

  1. Empty lines are ignored. Empty means 'only white space' or 'nothing at all'.
  2. Any line, where the first character (that's not white space) is '#', is also ignored. Such a line is regarded as a comment.
  3. 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.

sim music


    # It contains two sequences: a violin and a cello voice.

    seq 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


    seq 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

mutwo_mmml-0.7.0.tar.gz (23.2 kB view details)

Uploaded Source

Built Distribution

mutwo.mmml-0.7.0-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

File details

Details for the file mutwo_mmml-0.7.0.tar.gz.

File metadata

  • Download URL: mutwo_mmml-0.7.0.tar.gz
  • Upload date:
  • Size: 23.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.14

File hashes

Hashes for mutwo_mmml-0.7.0.tar.gz
Algorithm Hash digest
SHA256 5a61c5d2374b8ea4ba1fb21999c16b0d4b84d9290c7358919fed5daafc158826
MD5 c012bb6aa1d0bcdc37273a4bab1cd3b6
BLAKE2b-256 f138bcd32d0b47664d79ec640c07149c97594cd7b25bb5973eadd8eec9a9f94d

See more details on using hashes here.

File details

Details for the file mutwo.mmml-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: mutwo.mmml-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 23.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.14

File hashes

Hashes for mutwo.mmml-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1ac6b496aac033d16daf47b2f24920a5a88dee04c254f42718e80f1e111ad528
MD5 570cf08c279eb5e314db5908d48a60c0
BLAKE2b-256 36d8126976c234bb9b7315336086d50792e8486a05dbbc0481cedcb89bbf7163

See more details on using hashes here.

Supported by

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