| 1 |
Music Macro Language evaluator |
| 2 |
================================= |
| 3 |
|
| 4 |
.. currentmodule:: pyo |
| 5 |
|
| 6 |
.. highlight:: none |
| 7 |
|
| 8 |
The MML object implements acustom MML evaluator to allow simple and efficient |
| 9 |
music composition within pyo. The language's rules are explained below. |
| 10 |
|
| 11 |
The MML object generates triggers on new notes with additional streams to |
| 12 |
handle frequency, amplitude, duration and custom parameters. See the object |
| 13 |
documentation for more details. |
| 14 |
|
| 15 |
Objects in this category |
| 16 |
------------------------------ |
| 17 |
|
| 18 |
- :py:class:`MML` : Generates music sequences based on a custom MML notation. |
| 19 |
|
| 20 |
**API documentation** |
| 21 |
--------------------- |
| 22 |
|
| 23 |
- The space separates the tokens in a music sequence (a token can be a note value, |
| 24 |
an amplitude control, a tempo statement, etc.). |
| 25 |
|
| 26 |
Pre-Processing on music text |
| 27 |
---------------------------- |
| 28 |
|
| 29 |
- A comment starts with a semicolon ( **;** ) and ends at the end of the line. This |
| 30 |
text will be removed before starting to evaluate the sequences. |
| 31 |
|
| 32 |
- A musical voice is represented by a single line of code. |
| 33 |
|
| 34 |
- We can break a long line into multiple short lines with the backslash ( **\\** ). |
| 35 |
|
| 36 |
- The symbol equal ( **=** ), preceded by a variable name in UPPER CASE, creates a |
| 37 |
macro. The remaining part of the line is the macro body. Anywhere the |
| 38 |
pre-processor finds the variable name in the music, it will be replaced by the |
| 39 |
macro's body. |
| 40 |
|
| 41 |
Realtime Processing of the music |
| 42 |
-------------------------------- |
| 43 |
|
| 44 |
**Voice number** |
| 45 |
|
| 46 |
- The symbol #, followed by a number indicates the voice number for the line. This should be |
| 47 |
the first token of a line. If missing, the line defaults to voice number 0. |
| 48 |
|
| 49 |
**Notes** |
| 50 |
|
| 51 |
- The letters **a** to **g** correspond to the musical pitches and cause the |
| 52 |
corresponding note to be played. |
| 53 |
|
| 54 |
- Sharp notes are produced by appending a **+** to the pitch value, and flat notes |
| 55 |
by appending a **-** to the pitch value. |
| 56 |
|
| 57 |
- The length of a note is specified by an integer following the note name. If a |
| 58 |
note doesn't have a duration, the last specified duration is used. Default |
| 59 |
duration is the Sixteenth note. Length values are: |
| 60 |
|
| 61 |
- 0 = Thirty-second note |
| 62 |
- 1 = Sixteenth note |
| 63 |
- 2 = Dotted sixteenth note |
| 64 |
- 3 = Eighth note |
| 65 |
- 4 = Dotted eighth note |
| 66 |
- 5 = Quarter note |
| 67 |
- 6 = Dotted quarter note |
| 68 |
- 7 = Half note |
| 69 |
- 8 = Dotted half note |
| 70 |
- 9 = Whole note |
| 71 |
|
| 72 |
- The letter **r** corresponds to a rest. The length of the rest is specified in |
| 73 |
the same manner as the length of a note. |
| 74 |
|
| 75 |
- The letter **o**, followed by a number, selects the octave the instrument will play in. |
| 76 |
If the letter **o** is followed by the symbol **+**, the octave steps up by one. If followed |
| 77 |
by the symbol **-**, the octave steps down by one. If a number follows the symbol **+** or **-**, |
| 78 |
the octave steps up or down by the given amount of octaves. |
| 79 |
|
| 80 |
**Tuplets** |
| 81 |
|
| 82 |
- Notes surrounded by brakets ( **(** and **)** ) act as tuplet. Tuplet length is specified |
| 83 |
just after the closing bracket using the same values as for a note duration. Length of |
| 84 |
each note in tuplet will evenly be <note length of tuplet> / <count of notes in tuplet>. |
| 85 |
If not specified, tuplet duration defaults to 5 (quarter note). |
| 86 |
|
| 87 |
**Tempo** |
| 88 |
|
| 89 |
- The letter **t**, followed by a number, sets the tempo in beats-per-minute. |
| 90 |
If the letter **t** is followed by the symbol **+**, the tempo increases by one. If followed |
| 91 |
by the symbol **-**, the tempo decreases by one. If a number follows the symbol **+** or **-**, |
| 92 |
the tempo increases or decreases by the given amount of BPM. |
| 93 |
|
| 94 |
**Volume** |
| 95 |
|
| 96 |
- The letter **v**, followed by a number between 0 and 100, sets the volume for the following |
| 97 |
notes. If the letter **v** is followed by the symbol **+**, the volume increases by one. If |
| 98 |
followed by the symbol **-**, the volume decreases by one. If a number follows the symbol |
| 99 |
**+** or **-**, the volume increases or decreases by the given amount. |
| 100 |
|
| 101 |
**User variables** |
| 102 |
|
| 103 |
- The letters **x**, **y** an **z**, followed by a real number, are user-defined parameters. They |
| 104 |
can be used to control specific parameters of the synthesizer. |
| 105 |
If the letter is followed by the symbol **+**, the value increases by 0.01. If followed |
| 106 |
by the symbol **-**, the value decreases by 0.01. If a number follows the symbol **+** or **-**, |
| 107 |
the value increases or decreases by the given amount. |
| 108 |
|
| 109 |
**Random selection** |
| 110 |
|
| 111 |
- Random choice within a set of values can be done with the **?** symbol, followed by the |
| 112 |
possible values inside square brackets. |
| 113 |
Ex. ?[c e g b-] ; the note is a random choice between c e g and b-. |
| 114 |
|
| 115 |
- Random choice between a range can be done with the **?** symbol, followed by the range inside |
| 116 |
curly brackets. If two values are presents, they are the minimum and maximum of the range. |
| 117 |
If there is only one value, the range is 0 to this value and if the brackets are empty, the |
| 118 |
range is 0 to 1. |
| 119 |
Ex. v?{40 70} ; volume is set randomly between 40 and 70. |
| 120 |
|
| 121 |
**Looping segments** |
| 122 |
|
| 123 |
- The symbol **|:** starts a looped segment and the symbol **:|** ends it. A number right after the |
| 124 |
last symbol indicates how many loops to perform. If missing, the number of loops is two (the |
| 125 |
first pass + one repetition). It is possible to use loops inside other loops. There is no |
| 126 |
limit to the number of levels of loop embedding. |
| 127 |
|
| 128 |
.. highlight:: python |
| 129 |
|
| 130 |
**Objects** |
| 131 |
----------- |
| 132 |
|
| 133 |
*MML* |
| 134 |
---------- |
| 135 |
|
| 136 |
.. autoclass:: MML |
| 137 |
:members: |
| 138 |
|
| 139 |
.. autoclasstoc:: |